Skip to content

Commit 8de7df8

Browse files
committed
Initial RegExr.com source.
1 parent e80f30b commit 8de7df8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+15479
-3
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text eol=lf
2+
*.ico binary

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#-----------------------------
2+
# SYSTEM
3+
#-----------------------------
4+
.DS_Store
5+
6+
#-----------------------------
7+
# INVALID FILES
8+
# (for cross OS compatibility)
9+
#-----------------------------
10+
*[\<\>\:\"\/\\\|\?\*]*
11+
12+
#-----------------------------
13+
# WORKSPACE
14+
#-----------------------------
15+
.idea/
16+
*.sublime-project
17+
*.sublime-workspace
18+
19+
#-----------------------------
20+
# BUILD/DEBUGGING
21+
#-----------------------------
22+
node_modules/
23+
.sass-cache/
24+
build/
25+
26+
#-----------------------------
27+
# PROJECT SPECIFIC
28+
#-----------------------------
29+
_db.php
30+
regexr.css

.htaccess

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RewriteEngine on
2+
RewriteCond %{REQUEST_FILENAME} !-d
3+
RewriteCond %{REQUEST_FILENAME} !-f
4+
RewriteRule . / [L]
5+
6+
# BEGIN GZIP
7+
<ifmodule mod_deflate.c>
8+
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
9+
</ifmodule>
10+
# END GZIP

Gruntfile.js

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
var path = require("path");
2+
var uglify = require('uglify-js');
3+
4+
var folderMount = function folderMount(connect, point) {
5+
return connect.static(path.resolve(point));
6+
};
7+
8+
module.exports = function (grunt) {
9+
10+
grunt.initConfig({
11+
pkg: grunt.file.readJSON("package.json"),
12+
deployFolder: 'build/',
13+
14+
'min': {
15+
options: {
16+
report: false
17+
},
18+
'build': {
19+
'src': getScripts().app,
20+
'dest': '<%= deployFolder %>js/scripts.min.js'
21+
}
22+
},
23+
24+
sass: {
25+
build:{
26+
options: {
27+
compass: true,
28+
style: 'compact', // Can be nested, compact, compressed, expanded
29+
precision: 2,
30+
},
31+
files: {
32+
"css/regexr.css":"scss/regexr.scss"
33+
}
34+
}
35+
},
36+
37+
watchSass: {
38+
run: {
39+
options: {
40+
compass: true,
41+
// In prep-tasks, we change the style for a build, to compressed;
42+
style: "nested", // Can be nested, compact, compressed, expanded
43+
"line-numbers": true,
44+
precision: 2,
45+
},
46+
files: {
47+
"css/regexr.css":"scss/regexr.scss"
48+
}
49+
}
50+
},
51+
52+
'cssmin': {
53+
options: {
54+
report: false
55+
},
56+
'build': {
57+
'src': "css/regexr.css",
58+
'dest': '<%= deployFolder %>css/regexr.css'
59+
}
60+
},
61+
62+
copy: {
63+
build: {
64+
files: [
65+
{
66+
expand: true,
67+
src:[
68+
'assets/**',
69+
'php/**',
70+
'*.ico',
71+
'.htaccess',
72+
'manifest.json'
73+
],
74+
dest: "<%= deployFolder %>"
75+
}
76+
]
77+
}
78+
},
79+
80+
connect: {
81+
build: {
82+
options: {
83+
hostname: '*',
84+
keepalive:true,
85+
middleware: function (connect, options) {
86+
return [folderMount(connect, grunt.config.get("deployFolder"))]
87+
}
88+
}
89+
}
90+
},
91+
92+
htmlmin: {
93+
options: {
94+
removeComments: true,
95+
collapseWhitespace: true
96+
},
97+
build: {
98+
files:[{src: '<%= deployFolder %>index.html.tmp', dest: '<%= deployFolder %>index.html'}],
99+
}
100+
},
101+
102+
clean: {
103+
build: ["<%= deployFolder %>!(v1|.git|php)**"],
104+
postBuild: ["<%= deployFolder %>**/*.tmp"]
105+
}
106+
});
107+
108+
/**
109+
* Loads our scripts.json file.
110+
*
111+
*/
112+
function getScripts() {
113+
var scripts = grunt.file.readJSON('scripts.json');
114+
var missing = [];
115+
for (var n in scripts) {
116+
var arr = scripts[n];
117+
arr.forEach(function(item, index, array) {
118+
if (!grunt.file.exists(item)) {
119+
missing.push(n+': '+item);
120+
}
121+
});
122+
}
123+
124+
if (missing.length) {
125+
// \x07 == beep sound in the terminal.
126+
grunt.log.warn('\x07Missing ', missing.length + ' scripts.\n\t' + missing.join('\n\t'));
127+
}
128+
129+
return scripts;
130+
}
131+
132+
/**
133+
* Utility function.
134+
* Returns an minified version of a javascript string, file or files.
135+
*
136+
* @param script {String|Array} Either a Javascript string,
137+
* or an array of paths to Javascript files.
138+
*
139+
* Returns a minified version of the script(s) passed in.
140+
*/
141+
function minifyJS(script) {
142+
var uglifyConfig = {};
143+
if (typeof script == "string") {
144+
uglifyConfig.fromString = true;
145+
}
146+
147+
var result = uglify.minify(script, uglifyConfig);
148+
return result.code;
149+
}
150+
151+
/**
152+
* Runs the index.html file through grunts template system.
153+
*
154+
*/
155+
grunt.registerTask("parse-index", function (type) {
156+
var templateFile = grunt.file.read("index.html");
157+
var indexJs = minifyJS(grunt.file.read("js/index.template.js"));
158+
var buildIndexTag = "<script>"+indexJs+"</script>";
159+
160+
var output = grunt.template.process(templateFile, {data:{build:true, index:buildIndexTag, noCache:Date.now()}})
161+
162+
//Write a temp html file, the htmlmin task will minify it to index.html
163+
grunt.file.write(grunt.config.get("deployFolder")+"index.html.tmp", output);
164+
});
165+
166+
grunt.registerTask("build", [
167+
"clean:build",
168+
"sass",
169+
"cssmin",
170+
"min",
171+
"parse-index",
172+
"htmlmin",
173+
"copy",
174+
"clean:postBuild",
175+
"connect:build"
176+
]);
177+
178+
/*
179+
Load all the tasks we need
180+
Usually we use uglifyJS for code minification.
181+
However uglify breaks the Unicode characters Codemirror uses in its RegEx expressions,
182+
whereas yui does not.
183+
*/
184+
grunt.loadNpmTasks("grunt-yui-compressor");
185+
grunt.loadNpmTasks("grunt-contrib-sass");
186+
grunt.loadNpmTasks("grunt-contrib-connect");
187+
grunt.loadNpmTasks('grunt-contrib-clean');
188+
grunt.loadNpmTasks('grunt-contrib-htmlmin');
189+
grunt.loadNpmTasks('grunt-contrib-copy');
190+
grunt.loadTasks('tasks/');
191+
};

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,58 @@
11
RegExr
22
======
33

4+
# About
5+
This is the source for [RegExr.com](http://regexr.com/)
46
RegExr is a HTML/JS based tool for creating, testing, and learning about Regular Expressions.
57

6-
It launched on Mar 26, 2014 at [RegExr.com](http://regexr.com/)
8+
# Build
9+
## RegExr uses [Grunt](http://gruntjs.com/) to manage the build process.
710

8-
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.
11+
## To use
12+
13+
Note that this requires a familiarity with using the command line.
14+
The example commands shown are for use with the OSX Terminal.
15+
16+
### Install dependencies
17+
18+
Node (0.10.24 or greater is required):
19+
20+
# check the version via the command line
21+
node -v
22+
23+
If your Node install is out of date, get the latest from [NodeJS.org](http://nodejs.org/)
24+
25+
After node is setup, install the other dependencies. You may want to familiarize yourself with the Node Packager Manager (NPM) before proceeding.
26+
27+
# Install the grunt command line utility globally
28+
sudo npm install grunt-cli -g
29+
30+
# Install all the dependencies from package.json
31+
npm install
32+
33+
### Setup
34+
#### Compile sass
35+
The only requirement for development is to compile the sass files. This can be achieved manually via ```grunt sass;```
36+
or for development you can watch for changes use ```grunt watchSass;```
37+
You can also use any third-party sass compiler. Examples are; Using a WebStorm watcher or CodeKits built compiler.
38+
39+
#### Other setup
40+
There is no other setup required, grunt build mainly prepares the source for deployment.
41+
42+
### Building
43+
To prepare the site for a deploy run:
44+
45+
grunt build;
46+
47+
This command will:
48+
49+
* Copy all required assets to the build/ folder.
50+
* Combine and minify the *.js files
51+
* Compile and minify the sass
52+
* Inject js/index.template.js into the index.html file
53+
* Minify the index.html file
54+
55+
# Code Style
56+
If you would like to contribute back to RegExr.com please send us pull requests.
57+
Please make sure they are well formatted and follow the style specified out in the existing files.
58+
Mainly just keep your white space as tabs, and all line breaks as \n.

assets/ZeroClipboard.swf

1.88 KB
Binary file not shown.

assets/regexr-icons.eot

5.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)