Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Build script simplified and HOST PHP var used across the app, so it s…

…hould be easier to deploy to your own machine.
  • Loading branch information...
commit dec0c731bc08d5fe1bafb8b687d0f0f7d7899405 1 parent 84e5196
@remy remy authored
View
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "js/vendor/jshint"]
+ path = js/vendor/jshint
+ url = https://github.com/jshint/jshint.git
View
2  Makefile
@@ -0,0 +1,2 @@
+all:
+ php ./build/build.php
View
6 app.php
@@ -69,7 +69,7 @@
if (@$_REQUEST['callback']) {
echo $_REQUEST['callback'] . '("';
}
- $url = 'http://jsbin.com/' . $code_id . ($revision == 1 ? '' : '/' . $revision);
+ $url = HOST . $code_id . ($revision == 1 ? '' : '/' . $revision);
if (isset($_REQUEST['format']) && strtolower($_REQUEST['format']) == 'plain') {
echo $url;
} else {
@@ -126,7 +126,7 @@
if (!$ajax) {
- $html = preg_replace('/<html(.*)/', "<html$1\n\n<!--\n\n Created using http://jsbin.com\n Source can be edited via http://jsbin.com/$code_id/edit\n\n-->\n", $html);
+ $html = preg_replace('/<html(.*)/', "<html$1\n\n<!--\n\n Created using " . HOST . "\n Source can be edited via " . HOST . "$code_id/edit\n\n-->\n", $html);
}
if (false) {
@@ -139,7 +139,7 @@
}
if (!$html && !$ajax) {
- $javascript = "/*\n Created using http://jsbin.com\n Source can be edit via http://jsbin.com/$code_id/edit\n*/\n\n" . $javascript;
+ $javascript = "/*\n Created using " . HOST . "\n Source can be edit via " . HOST . "$code_id/edit\n*/\n\n" . $javascript;
}
if (!$html) {
View
26 phpMake → build/build.php
@@ -12,11 +12,11 @@
$filePath = './js/jsbin.js';
// prepare sprocket
$sprocket = new Sprocket($filePath, array(
- 'contentType' => '', // keeps debug quiet
- 'baseUri' => '../js',
+ 'contentType' => '', // keeps debug quiet
+ 'baseUri' => '../js',
'baseFolder' => array('./js/vendor', './js/vendor/codemirror'),
'assetFolder' => '..',
- 'debugMode' => true, // forces to always show
+ 'debugMode' => true, // forces to always show
'autoRender' => false
));
@@ -31,6 +31,26 @@
echo "Writing concatenated file...\n";
file_put_contents(SPROCKETIZED, $js);
+// neeed to build the base files for codemirror
+$filePath = './js/editors/codemirror.js';
+// prepare sprocket
+$sprocket = new Sprocket($filePath, array(
+ 'contentType' => '', // keeps debug quiet
+ 'baseUri' => '../js',
+ 'baseFolder' => array('./js/vendor', './js/vendor/codemirror'),
+ 'assetFolder' => '..',
+ 'debugMode' => true, // forces to always show
+ 'autoRender' => false
+));
+
+echo "Rendering code mirror basefile...\n";
+$js = $sprocket->render(true);
+
+// write concat to js dir
+echo "Writing codemirror basefile...\n";
+file_put_contents('./js/vendor/codemirror/basefiles.js', $js);
+
+
// google compile in to jsbin.VERSION.js
echo "Google compiler compressing...\n";
system('java -jar "./lib/compiler.jar" --js="' . SPROCKETIZED . '" --js_output_file="' . PRODUCTION . '" --warning_level=QUIET');
View
8 lib/sql/jsbin.sql → build/jsbin.sql
@@ -1,4 +1,4 @@
-CREATE TABLE `sandbox` (
+CREATE TABLE IF NOT EXISTS `sandbox` (
`id` int(11) NOT NULL auto_increment,
`javascript` text,
`html` text,
@@ -10,9 +10,13 @@ CREATE TABLE `sandbox` (
`streaming_read_key` char(32) NOT NULL,
`active_tab` varchar(10) NOT NULL,
`active_cursor` int(11) NOT NULL,
+
+ `revision` int(11) default 1,
+
PRIMARY KEY (`id`),
KEY `viewed` (`last_viewed`),
KEY `url` (`url`),
KEY `streaming_key` (`streaming_key`),
- KEY `spam` (`created`,`last_viewed`)
+ KEY `spam` (`created`,`last_viewed`),
+ KEY `revision` (`url`, `revision`)
);
View
13 index.php
@@ -2,8 +2,9 @@
if ($revision != 1 && $revision) {
$code_id .= '/' . $revision;
}
+$code_id_path = '';
if ($code_id) {
- $code_id = '/' . $code_id;
+ $code_id_path = '/' . $code_id;
}
?>
<!DOCTYPE html>
@@ -22,11 +23,11 @@
<a class="tab button preview group right gap" accesskey="2" href="#preview">Preview</a>
<a title="Revert" class="button light group left enable" id="revert" href="#"><img class="enabled" src="/images/revert.png" /><img class="disabled" src="/images/revert-disabled.png" /></a>
<?php if ($code_id) : ?>
- <a class="button group light left" href="http://jsbin.com<?=$code_id?>">http://jsbin.com<?=$code_id?></a>
+ <a class="button group light left" href="<?=HOST . $code_id?>"><?=HOST . $code_id?></a>
<?php else : ?>
<a id="save" class="button save group left right gap" href="/save">Save</a>
<?php endif ?>
- <?php if ($code_id) : ?><a id="save" class="button gap light save group right" href="<?=$code_id?>/save">Save changes</a><?php endif ?>
+ <?php if ($code_id) : ?><a id="save" class="button gap light save group right" href="<?=$code_id_path?>/save">Save changes</a><?php endif ?>
<a id="stream" class="button left right" href="#stream">Stream</a>
</div>
</div>
@@ -45,7 +46,7 @@
<div id="bin" class="stretch">
<div id="source" class="binview stretch">
<div class="code stretch javascript">
- <div class="label"><p>JavaScript<span> (<span class="hide">hide</span><span class="show">show</span> HTML)</span></p></div>
+ <div class="label"><p><strong id="jslabel">JavaScript</strong><span> (<span class="hide">hide</span><span class="show">show</span> HTML)</span></p></div>
<textarea id="javascript"></textarea>
</div>
<div class="code stretch html">
@@ -68,7 +69,7 @@
</div>
</div>
<div id="preview" class="binview stretch"></div>
- <form method="post" action="<?=$code_id?>/save"></form>
+ <form method="post" action="<?=$code_id_path?>/save"></form>
</div>
<div id="help"><p><a href="/help/index.html">Help Menu</a></p><div id="content"></div></div>
<?php
@@ -96,7 +97,7 @@
?>
<script>var template = { html : <?=$html?>, javascript: '' };</script>
<?php else : ?>
-<script src="<?=$code_id ? $code_id : '' ?>/source/<?=$qs?>"></script>
+<script src="<?=$code_id_path ?>/source/<?=$qs?>"></script>
<?php endif ?>
<script src="http://forbind.net/js/?apikey=2796bc83070164231a3ab8c90227dbca"></script>
<script src="/js/<?=VERSION?>/jsbin.js"></script>
View
5,999 js/vendor/jquery-1.4.0.js
0 additions, 5,999 deletions not shown
1  js/vendor/jshint
@@ -0,0 +1 @@
+Subproject commit afc94f255d7a3036dbd46c9dae3dde6027d2c94a
View
2  lib/sql/revisions.sql
@@ -1,2 +0,0 @@
-alter table sandbox add column revision int default 1;
-alter table sandbox add index revision (url, revision);
Please sign in to comment.
Something went wrong with that request. Please try again.