Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
15,479 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
* text eol=lf | |||
*.ico binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
#----------------------------- | |||
# SYSTEM | |||
#----------------------------- | |||
.DS_Store | |||
|
|||
#----------------------------- | |||
# INVALID FILES | |||
# (for cross OS compatibility) | |||
#----------------------------- | |||
*[\<\>\:\"\/\\\|\?\*]* | |||
|
|||
#----------------------------- | |||
# WORKSPACE | |||
#----------------------------- | |||
.idea/ | |||
*.sublime-project | |||
*.sublime-workspace | |||
|
|||
#----------------------------- | |||
# BUILD/DEBUGGING | |||
#----------------------------- | |||
node_modules/ | |||
.sass-cache/ | |||
build/ | |||
|
|||
#----------------------------- | |||
# PROJECT SPECIFIC | |||
#----------------------------- | |||
_db.php | |||
regexr.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
RewriteEngine on | |||
RewriteCond %{REQUEST_FILENAME} !-d | |||
RewriteCond %{REQUEST_FILENAME} !-f | |||
RewriteRule . / [L] | |||
|
|||
# BEGIN GZIP | |||
<ifmodule mod_deflate.c> | |||
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript | |||
</ifmodule> | |||
# END GZIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,191 @@ | |||
var path = require("path"); | |||
var uglify = require('uglify-js'); | |||
|
|||
var folderMount = function folderMount(connect, point) { | |||
return connect.static(path.resolve(point)); | |||
}; | |||
|
|||
module.exports = function (grunt) { | |||
|
|||
grunt.initConfig({ | |||
pkg: grunt.file.readJSON("package.json"), | |||
deployFolder: 'build/', | |||
|
|||
'min': { | |||
options: { | |||
report: false | |||
}, | |||
'build': { | |||
'src': getScripts().app, | |||
'dest': '<%= deployFolder %>js/scripts.min.js' | |||
} | |||
}, | |||
|
|||
sass: { | |||
build:{ | |||
options: { | |||
compass: true, | |||
style: 'compact', // Can be nested, compact, compressed, expanded | |||
precision: 2, | |||
}, | |||
files: { | |||
"css/regexr.css":"scss/regexr.scss" | |||
} | |||
} | |||
}, | |||
|
|||
watchSass: { | |||
run: { | |||
options: { | |||
compass: true, | |||
// In prep-tasks, we change the style for a build, to compressed; | |||
style: "nested", // Can be nested, compact, compressed, expanded | |||
"line-numbers": true, | |||
precision: 2, | |||
}, | |||
files: { | |||
"css/regexr.css":"scss/regexr.scss" | |||
} | |||
} | |||
}, | |||
|
|||
'cssmin': { | |||
options: { | |||
report: false | |||
}, | |||
'build': { | |||
'src': "css/regexr.css", | |||
'dest': '<%= deployFolder %>css/regexr.css' | |||
} | |||
}, | |||
|
|||
copy: { | |||
build: { | |||
files: [ | |||
{ | |||
expand: true, | |||
src:[ | |||
'assets/**', | |||
'php/**', | |||
'*.ico', | |||
'.htaccess', | |||
'manifest.json' | |||
], | |||
dest: "<%= deployFolder %>" | |||
} | |||
] | |||
} | |||
}, | |||
|
|||
connect: { | |||
build: { | |||
options: { | |||
hostname: '*', | |||
keepalive:true, | |||
middleware: function (connect, options) { | |||
return [folderMount(connect, grunt.config.get("deployFolder"))] | |||
} | |||
} | |||
} | |||
}, | |||
|
|||
htmlmin: { | |||
options: { | |||
removeComments: true, | |||
collapseWhitespace: true | |||
}, | |||
build: { | |||
files:[{src: '<%= deployFolder %>index.html.tmp', dest: '<%= deployFolder %>index.html'}], | |||
} | |||
}, | |||
|
|||
clean: { | |||
build: ["<%= deployFolder %>!(v1|.git|php)**"], | |||
postBuild: ["<%= deployFolder %>**/*.tmp"] | |||
} | |||
}); | |||
|
|||
/** | |||
* Loads our scripts.json file. | |||
* | |||
*/ | |||
function getScripts() { | |||
var scripts = grunt.file.readJSON('scripts.json'); | |||
var missing = []; | |||
for (var n in scripts) { | |||
var arr = scripts[n]; | |||
arr.forEach(function(item, index, array) { | |||
if (!grunt.file.exists(item)) { | |||
missing.push(n+': '+item); | |||
} | |||
}); | |||
} | |||
|
|||
if (missing.length) { | |||
// \x07 == beep sound in the terminal. | |||
grunt.log.warn('\x07Missing ', missing.length + ' scripts.\n\t' + missing.join('\n\t')); | |||
} | |||
|
|||
return scripts; | |||
} | |||
|
|||
/** | |||
* Utility function. | |||
* Returns an minified version of a javascript string, file or files. | |||
* | |||
* @param script {String|Array} Either a Javascript string, | |||
* or an array of paths to Javascript files. | |||
* | |||
* Returns a minified version of the script(s) passed in. | |||
*/ | |||
function minifyJS(script) { | |||
var uglifyConfig = {}; | |||
if (typeof script == "string") { | |||
uglifyConfig.fromString = true; | |||
} | |||
|
|||
var result = uglify.minify(script, uglifyConfig); | |||
return result.code; | |||
} | |||
|
|||
/** | |||
* Runs the index.html file through grunts template system. | |||
* | |||
*/ | |||
grunt.registerTask("parse-index", function (type) { | |||
var templateFile = grunt.file.read("index.html"); | |||
var indexJs = minifyJS(grunt.file.read("js/index.template.js")); | |||
var buildIndexTag = "<script>"+indexJs+"</script>"; | |||
|
|||
var output = grunt.template.process(templateFile, {data:{build:true, index:buildIndexTag, noCache:Date.now()}}) | |||
|
|||
//Write a temp html file, the htmlmin task will minify it to index.html | |||
grunt.file.write(grunt.config.get("deployFolder")+"index.html.tmp", output); | |||
}); | |||
|
|||
grunt.registerTask("build", [ | |||
"clean:build", | |||
"sass", | |||
"cssmin", | |||
"min", | |||
"parse-index", | |||
"htmlmin", | |||
"copy", | |||
"clean:postBuild", | |||
"connect:build" | |||
]); | |||
|
|||
/* | |||
Load all the tasks we need | |||
Usually we use uglifyJS for code minification. | |||
However uglify breaks the Unicode characters Codemirror uses in its RegEx expressions, | |||
whereas yui does not. | |||
*/ | |||
grunt.loadNpmTasks("grunt-yui-compressor"); | |||
grunt.loadNpmTasks("grunt-contrib-sass"); | |||
grunt.loadNpmTasks("grunt-contrib-connect"); | |||
grunt.loadNpmTasks('grunt-contrib-clean'); | |||
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | |||
grunt.loadNpmTasks('grunt-contrib-copy'); | |||
grunt.loadTasks('tasks/'); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,8 +1,58 @@ | |||
RegExr | RegExr | ||
====== | ====== | ||
|
|
||
# About | |||
This is the source for [RegExr.com](http://regexr.com/) | |||
RegExr is a HTML/JS based tool for creating, testing, and learning about Regular Expressions. | RegExr is a HTML/JS based tool for creating, testing, and learning about Regular Expressions. | ||
|
|
||
It launched on Mar 26, 2014 at [RegExr.com](http://regexr.com/) | # Build | ||
## RegExr uses [Grunt](http://gruntjs.com/) to manage the build process. | |||
|
|
||
We are going to take a bit of time to clean up and organize the code before releasing it here. Until then this repo will be used to track bugs and feedback. | ## To use | ||
|
|||
Note that this requires a familiarity with using the command line. | |||
The example commands shown are for use with the OSX Terminal. | |||
|
|||
### Install dependencies | |||
|
|||
Node (0.10.24 or greater is required): | |||
|
|||
# check the version via the command line | |||
node -v | |||
|
|||
If your Node install is out of date, get the latest from [NodeJS.org](http://nodejs.org/) | |||
|
|||
After node is setup, install the other dependencies. You may want to familiarize yourself with the Node Packager Manager (NPM) before proceeding. | |||
|
|||
# Install the grunt command line utility globally | |||
sudo npm install grunt-cli -g | |||
|
|||
# Install all the dependencies from package.json | |||
npm install | |||
|
|||
### Setup | |||
#### Compile sass | |||
The only requirement for development is to compile the sass files. This can be achieved manually via ```grunt sass;``` | |||
or for development you can watch for changes use ```grunt watchSass;``` | |||
You can also use any third-party sass compiler. Examples are; Using a WebStorm watcher or CodeKits built compiler. | |||
|
|||
#### Other setup | |||
There is no other setup required, grunt build mainly prepares the source for deployment. | |||
|
|||
### Building | |||
To prepare the site for a deploy run: | |||
|
|||
grunt build; | |||
|
|||
This command will: | |||
|
|||
* Copy all required assets to the build/ folder. | |||
* Combine and minify the *.js files | |||
* Compile and minify the sass | |||
* Inject js/index.template.js into the index.html file | |||
* Minify the index.html file | |||
|
|||
# Code Style | |||
If you would like to contribute back to RegExr.com please send us pull requests. | |||
Please make sure they are well formatted and follow the style specified out in the existing files. | |||
Mainly just keep your white space as tabs, and all line breaks as \n. |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.