Skip to content

Commit

Permalink
Initial RegExr.com source.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdamien committed Mar 31, 2014
1 parent e80f30b commit 8de7df8
Show file tree
Hide file tree
Showing 74 changed files with 15,479 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
@@ -0,0 +1,2 @@
* text eol=lf
*.ico binary
30 changes: 30 additions & 0 deletions .gitignore
@@ -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
10 changes: 10 additions & 0 deletions .htaccess
@@ -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
191 changes: 191 additions & 0 deletions Gruntfile.js
@@ -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/');
};
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
54 changes: 52 additions & 2 deletions README.md
@@ -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 added assets/ZeroClipboard.swf
Binary file not shown.
Binary file added assets/regexr-icons.eot
Binary file not shown.

0 comments on commit 8de7df8

Please sign in to comment.