Skip to content

Commit

Permalink
Merge pull request #35 from mrjoelkemp/no-cache
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
mrjoelkemp committed Mar 8, 2015
2 parents 26b8b43 + eb116b2 commit 9cdb2cf
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 148 deletions.
4 changes: 3 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"mocha" : true,
"globals" : {
"window": false,
"document": false
"document": false,
"$": false,
"moment": false
}
}
180 changes: 73 additions & 107 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,119 +1,85 @@
module.exports = function (grunt) {
var path = require('path'),
fs = require('fs');
var path = require('path'),
fs = require('fs');

require('load-grunt-tasks')(grunt);
require('load-grunt-tasks')(grunt);

grunt.initConfig({
"sass": {
"dist": {
"files": [
{
"expand": true,
"src": [
"**/*.{scss, sass}",
"!node_modules/**/*.{scss, sass}"
],
"ext": ".css"
}
]
}
grunt.initConfig({
cacheBust: {
options: {
deleteOriginals: true
},
"browserify": {
"dist": {
"files": {
"dist/phpepl.js": ["src/phpepl.js"]
assets: {
files: [{
src: ['index.html']
}]
}
},
sass: {
dist: {
files: [
{
expand: true,
src: [
"**/*.{scss, sass}",
"!node_modules/**/*.{scss, sass}"
],
ext: ".css"
}
}
]
}
},
browserify: {
options: {
exclude: [
'js/vendor/jquery-2.1.3.min.js',
'js/vendor/moment.min.js'
]
},
"uglify": {
"options": {
"sourceMap": true,
"sourceMapIncludeSources": true
},
"dist": {
"files": {
"dist/phpepl.js": ['dist/phpepl.js']
}
dist: {
files: {
"dist/phpepl.js": ["js/phpepl.js"]
}
}
},
uglify: {
options: {
sourceMap: true,
sourceMapIncludeSources: true
},
"watch": {
"sass": {
"files": [
"**/*.scss",
"!node_modules/**/*.scss",
"!.git/**/*.scss",
"!.sass-cache/**/*.scss",
"!bower_components/**/*.scss",
"!vendor/**/*.scss"
],
"tasks": [
"newer:sass"
]
},
"js": {
"files": [
"src/**/*.js"
],
"tasks": [
"browserify",
"uglify"
]
},
"all": {
"files": [
"**/*",
"!node_modules/**/*",
"!.git/**/*",
"!.sass-cache/**/*",
"!bower_components/**/*",
"!vendor/**/*"
],
"tasks": [
"noop"
],
"options": {
"cwd": "./",
"spawn": false,
"event": [
"added"
]
}
dist: {
files: {
"dist/phpepl.js": ['dist/phpepl.js']
}
}
});

grunt.registerTask('default', ['watch']);

// Handle new files with that have a new, supported preprocessor
grunt.event.on('watch', function(action, filepath) {
var ext = path.extname(filepath);

// Ignore directories
if (fs.lstatSync(filepath).isDirectory()) return;

if (action === 'added') {
// This is a special message that's parsed by YA
// to determine if support for an additional preprocessor is necessary
// Note: this allows us to avoid controlling grunt manually within YA
console.log('EXTADDED:' + ext);

// Note: we don't do anything for newly added .js files
// A new js file can't be the root unless it's changed to require
// the current root and saved/changed
} else if (action === 'changed' || action === 'deleted') {
if (ext === '.js') {
// Ignore bundles
if (/.+bundle.js/g.test(filepath)) return;

// Notify YA to recompute the roots and
// generate a configuration
console.log('JSCHANGED:' + filepath);
}
},
watch: {
sass: {
files: [
"**/*.scss",
"!node_modules/**/*.scss",
"!.git/**/*.scss",
"!.sass-cache/**/*.scss",
"!bower_components/**/*.scss",
"!vendor/**/*.scss"
],
tasks: [
"newer:sass"
]
},
js: {
files: [
"js/**/*.js",
"!js/vendor/**/*.js"
],
tasks: [
"browserify",
"uglify",
'cacheBust'
]
}
});
}
});

// For watching entire directories but allowing
// the grunt.event binding to take care of it
grunt.registerTask('noop', function () {});
}
grunt.registerTask('default', ['watch']);
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ If you'd like to tinker around with the code, you can do the following:
* `grunt`
* Point your browser to your localhost (assuming you have the app being [served locally](#running-it-locally))

`src/phpepl.js` is the main script for the website. This gets built into `dist/phpepl.js`
which is referenced by `phpepl/index.html`.
`js/phpepl.js` is the main script for the website. This gets built into a hashed `dist/phpepl.js`
which is referenced by `index.html`.

The php evaluation code is in `src/eval/index.php`.
The php evaluation code is in `eval/index.php`.

That endpoint checks for the existence of a `PHPEPL_PROD` environment variable
(which is set on the production hosts) for sandboxing. Locally, you won't
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions dist/phpepl.6dea5a8de69bec15.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions dist/phpepl.js

This file was deleted.

2 changes: 1 addition & 1 deletion dist/phpepl.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/eval/index.php → eval/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Only production environments will have this set – turning on sandboxing
// DEP_VERSION is for cloud control
$sandbox_me = isset($_ENV['PHPEPL_PROD']) || isset($_ENV['DEP_VERSION']);
require_once('../../vendor/autoload.php');
require_once('../vendor/autoload.php');

// Turn off errors since eval will throw them on invalid syntax
@ini_set('log_errors', false);
Expand Down
Binary file added favicon.a7a02ef2032fea1a.ico
Binary file not shown.
Binary file removed favicon.ico
Binary file not shown.
31 changes: 17 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

<title>PHPepl: The PHP REPL</title>

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/favicon.a7a02ef2032fea1a.ico" type="image/x-icon">
<link rel="icon" href="/favicon.a7a02ef2032fea1a.ico" type="image/x-icon">

<link href='js/vendor/codemirror/lib/codemirror.css?ver=4.5' rel='stylesheet'>
<link href='css/styles.css?ver=1.10' rel='stylesheet'>
<link href='js/vendor/codemirror/lib/codemirror.69882100f431f700.css' rel='stylesheet'>
<link href='css/styles.8ed83c9a1f6526ce.css' rel='stylesheet'>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36055599-1']);
Expand Down Expand Up @@ -99,15 +99,18 @@
</a>
</div>
</body>
<script src='js/vendor/codemirror/lib/codemirror.js?ver=4.5'></script>
<script src='js/vendor/codemirror/addon/edit/closebrackets.js?ver=4.5'></script>
<script src='js/vendor/codemirror/addon/edit/matchbrackets.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/htmlmixed/htmlmixed.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/xml/xml.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/javascript/javascript.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/css/css.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/clike/clike.js?ver=4.5'></script>
<script src='js/vendor/codemirror/mode/php/php.js?ver=4.5'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js'></script>

<script src='dist/phpepl.js?ver=1.11'></script>
<script src='js/vendor/codemirror/lib/codemirror.7a9280b40de09030.js'></script>
<script src='js/vendor/codemirror/addon/edit/closebrackets.99fbd700c4b1dde0.js'></script>
<script src='js/vendor/codemirror/addon/edit/matchbrackets.7c67d671b0ae64eb.js'></script>
<script src='js/vendor/codemirror/mode/htmlmixed/htmlmixed.70e9c6691f93ae5a.js'></script>
<script src='js/vendor/codemirror/mode/xml/xml.b10ab61307626443.js'></script>
<script src='js/vendor/codemirror/mode/javascript/javascript.201d73044f63833b.js'></script>
<script src='js/vendor/codemirror/mode/css/css.623a12754234c2f0.js'></script>
<script src='js/vendor/codemirror/mode/clike/clike.a38e006a81a7baab.js'></script>
<script src='js/vendor/codemirror/mode/php/php.ce287cd834646250.js'></script>

<script src='dist/phpepl.6dea5a8de69bec15.js'></script>
</html>
2 changes: 0 additions & 2 deletions src/editor.js → js/editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var $ = require('jquery');

module.exports = window.CodeMirror($('#editor')[0], {
lineNumbers: true,
matchBrackets: true,
Expand Down
3 changes: 0 additions & 3 deletions src/helpers/EditorHelpers.js → js/helpers/EditorHelpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
var moment = require('moment');
var $ = require('jquery');

// Set the html of the output div
module.exports.setOutput = function(text) {
var isError = !!arguments[1];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var editor = require('../editor');
var $ = require('jquery');

module.exports.saveCode = function() {
if (!window.localStorage) { return; }
Expand Down
4 changes: 1 addition & 3 deletions src/phpepl.js → js/phpepl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

var $ = window.$ = window.jQuery = require('jquery');

var evalURL = 'src/eval/index.php';
var evalURL = 'eval/index.php';

var mixpanel = window.mixpanel || {};
var editor = require('./editor');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"description": "The PHP repl",
"version": "2.2.1",
"author": "Joel Kemp <joel@mrjoelkemp.com>",
"dependencies": {
"jquery": "1.x",
"moment": "*"
},
"dependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/mrjoelkemp/phpepl"
Expand All @@ -21,10 +18,9 @@
"npm": "1.2.x"
},
"devDependencies": {
"browserify": "~3.31.2",
"browserify-shim": "~3.3.0",
"grunt": "^0.4.5",
"grunt-browserify": "~3.2.1",
"grunt-cache-bust": "~0.4.13",
"grunt-cli": "^0.1.13",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "~0.6.0",
Expand All @@ -36,6 +32,6 @@
},
"main": "./src/phpepl.js",
"scripts": {
"test": "jscs -p google src/ && jshint src"
"test": "jscs -p google js/*.js js/helpers && jshint js/*.js js/helpers"
}
}

0 comments on commit 9cdb2cf

Please sign in to comment.