Permalink
Browse files

Changes to make local install of jsbin much easier - in particular fo…

…r subdirectory hosting.
  • Loading branch information...
remy committed Jun 24, 2011
1 parent d2a918e commit d03b9661e06c06fc648f060820b7e9c06c6ca009
Showing with 5,899 additions and 39 deletions.
  1. +0 −3 .gitmodules
  2. +9 −7 app.php
  3. +15 −15 css/style.css
  4. +14 −13 index.php
  5. +5,853 −0 js/vendor/jshint/jshint.js
  6. +8 −1 sprocketize.php
View
@@ -1,3 +0,0 @@
-[submodule "js/vendor/jshint"]
- path = js/vendor/jshint
- url = https://github.com/jshint/jshint.git
View
16 app.php
@@ -1,8 +1,10 @@
<?php
include('config.php'); // contains DB & important versioning
+$host = 'http://' . $_SERVER['HTTP_HOST'];
+
$pos = strpos($_SERVER['REQUEST_URI'], ROOT);
-if ($pos !== false) $pos++;
+if ($pos !== false) $pos = strlen(ROOT);
$request_uri = substr($_SERVER['REQUEST_URI'], $pos);
$home = isset($_COOKIE['home']) ? $_COOKIE['home'] : '';
@@ -67,7 +69,7 @@
if ($action == 'js') {
echo $javascript;
} else {
- $url = HOST . $code_id . ($revision == 1 ? '' : '/' . $revision);
+ $url = $host . ROOT . $code_id . ($revision == 1 ? '' : '/' . $revision);
if (!$ajax) {
echo 'var template = ';
}
@@ -129,7 +131,7 @@
if (@$_REQUEST['callback']) {
echo $_REQUEST['callback'] . '("';
}
- $url = HOST . $code_id . ($revision == 1 ? '' : '/' . $revision);
+ $url = $host . ROOT . $code_id . ($revision == 1 ? '' : '/' . $revision);
if (isset($_REQUEST['format']) && strtolower($_REQUEST['format']) == 'plain') {
echo $url;
} else {
@@ -150,9 +152,9 @@
// code was saved, so lets do a location redirect to the newly saved code
$edit_mode = false;
if ($revision == 1) {
- header('Location: /' . $code_id . '/edit');
+ header('Location: ' . ROOT . $code_id . '/edit');
} else {
- header('Location: /' . $code_id . '/' . $revision . '/edit');
+ header('Location: ' . ROOT . $code_id . '/' . $revision . '/edit');
}
}
@@ -195,7 +197,7 @@
}
if (!$html && !$ajax) {
- $javascript = "/*\n Created using " . HOST . "\n Source can be edit via " . HOST . "$code_id/edit\n*/\n\n" . $javascript;
+ $javascript = "/*\n Created using " . $host . ROOT . "\n Source can be edit via " . $host . ROOT . "$code_id/edit\n*/\n\n" . $javascript;
}
if (!$html) {
@@ -258,7 +260,7 @@ function formatCompletedCode($html, $javascript, $code_id, $revision) {
if (!$ajax && $code_id != 'jsbin') {
$code_id .= $revision == 1 ? '' : '/' . $revision;
- $html = preg_replace('/<html(.*)/', "<html$1\n<!--\n\n Created using " . HOST . "\n Source can be edited via " . HOST . "$code_id/edit\n\n-->", $html);
+ $html = preg_replace('/<html(.*)/', "<html$1\n<!--\n\n Created using " . $host . ROOT . "\n Source can be edited via " . $host . ROOT . "$code_id/edit\n\n-->", $html);
}
return array($html, $javascript);
View
@@ -1,11 +1,11 @@
/* Font via http://robey.lag.net/2010/06/21/mensch-font.html */
@font-face {
font-family: 'MenschRegular';
- src: url('/font/mensch-webfont.eot');
- src: url('/font/mensch-webfont.eot?#iefix') format('eot'),
- url('/font/mensch-webfont.woff') format('woff'),
- url('/font/mensch-webfont.ttf') format('truetype'),
- url('/font/mensch-webfont.svg#webfont0UwCC656') format('svg');
+ src: url('../font/mensch-webfont.eot');
+ src: url('../font/mensch-webfont.eot?#iefix') format('eot'),
+ url('../font/mensch-webfont.woff') format('woff'),
+ url('../font/mensch-webfont.ttf') format('truetype'),
+ url('../font/mensch-webfont.svg#webfont0UwCC656') format('svg');
font-weight: normal;
font-style: normal;
}
@@ -17,7 +17,7 @@ body {
font-size: 13px;
min-width: 976px;
overflow: hidden;
- background: url(/images/jsbin-bg.gif) repeat-x 0 -10px;
+ background: url(../images/jsbin-bg.gif) repeat-x 0 -10px;
}
p {
@@ -364,7 +364,7 @@ div.tall:hover {
text-align: center;
height: 18px;
line-height: 14px;
- background: url(/images/down.png) no-repeat 90% center;
+ background: url(../images/down.png) no-repeat 90% center;
padding-right: 26px;
font-weight: normal;
text-decoration: none;
@@ -373,7 +373,7 @@ div.tall:hover {
}
#control div.group:hover .title {
- background: #eee url(/images/down-hover.png) no-repeat 90% center;
+ background: #eee url(../images/down-hover.png) no-repeat 90% center;
}
#control div.group .button {
@@ -525,12 +525,12 @@ body.preview #source select {
.video {
padding-left: 20px;
- background: url(/images/play.gif) no-repeat left center;
+ background: url(../images/play.gif) no-repeat left center;
}
#info {
display: inline-block;
- background: url(/images/info.gif) no-repeat bottom left;
+ background: url(../images/info.gif) no-repeat bottom left;
color: #fff;
font-weight: bold;
font-style: italic;
@@ -544,7 +544,7 @@ body.preview #source select {
}
#info:hover {
- background: url(/images/info.gif) no-repeat top left;
+ background: url(../images/info.gif) no-repeat top left;
}
#startingpoint {
@@ -642,7 +642,7 @@ div.javascript {
width: 100%;
height: 100%;
z-index: 99;
- background: url(/images/op7.png) repeat;
+ background: url(../images/op7.png) repeat;
}
.hud .outercontainer {
@@ -884,13 +884,13 @@ ie6, li {
.button.download {
padding-left: 24px;
/* background-image: url(/images/arrow_down_12x12.png);*/
- background-image: url(/images/download.png);
+ background-image: url(../images/download.png);
background-repeat: no-repeat;
background-position: 8px -33px;
}
.button.download:hover {
- background-image: url(/images/download.png);
+ background-image: url(../images/download.png);
background-repeat: no-repeat;
background-position: 8px 7px;
}
@@ -917,7 +917,7 @@ ie6, li {
}
#live {
- background: white url(/images/jsbin-bg.gif) repeat-x 0 -62px;
+ background: white url(../images/jsbin-bg.gif) repeat-x 0 -62px;
top: 0;
left: 67%;
border-top: 0;
View
@@ -20,17 +20,18 @@
if ($revision != 1 && $revision) {
$code_id .= '/' . $revision;
}
-$code_id_path = '';
+$code_id_path = ROOT;
if ($code_id) {
- $code_id_path = '/' . $code_id;
+ $code_id_path = ROOT . $code_id . '/';
}
+
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>JS Bin - Collaborative JavaScript Debugging</title>
-<link rel="stylesheet" href="/css/style.css?<?=VERSION?>" type="text/css" />
+<link rel="stylesheet" href="<?=ROOT?>css/style.css?<?=VERSION?>" type="text/css" />
</head>
<!--[if lt IE 7 ]><body class="source ie ie6"><![endif]-->
<!--[if lt IE 8 ]><body class="source ie ie7"><![endif]-->
@@ -41,20 +42,20 @@
<div class="buttons">
<a class="tab button source group left" accesskey="1" href="#source">Code</a>
<a class="tab button preview group right gap" accesskey="2" href="#preview" title="Run with alerts, prompts, etc">Render</a>
- <a title="Revert" class="button light group left" id="revert" href="#"><img class="enabled" src="/images/revert.png" /><img class="disabled" src="/images/revert-disabled.png" /></a>
+ <a title="Revert" class="button light group left" id="revert" href="#"><img class="enabled" src="<?=ROOT?>images/revert.png" /><img class="disabled" src="<?=ROOT?>images/revert-disabled.png" /></a>
<?php if ($code_id) : ?>
- <a id="jsbinurl" class="button group light left" href="http://<?=$_SERVER['HTTP_HOST'] . '/' . $code_id?>">http://<?=$_SERVER['HTTP_HOST'] . '/' . $code_id?></a>
+ <a id="jsbinurl" class="button group light left" href="http://<?=$_SERVER['HTTP_HOST'] . ROOT . $code_id?>">http://<?=$_SERVER['HTTP_HOST'] . ROOT . $code_id?></a>
<div class="button group gap right tall">
- <a href="/save" class="save title">Save</a>
- <a id="clone" title="Create a new copy" class="button clone group light" href="/clone">Clone</a>
- <a id="save" title="Save new a new revision" class="button light save group" href="<?=$code_id_path?>/save">Save</a>
+ <a href="<?=ROOT?>save" class="save title">Save</a>
+ <a id="clone" title="Create a new copy" class="button clone group light" href="<?=ROOT?>clone">Clone</a>
+ <a id="save" title="Save new a new revision" class="button light save group" href="<?=$code_id_path?>save">Save</a>
<?php else : ?>
<div class="button group gap left right">
- <a href="/save" class="save title">Save</a>
- <a id="save" title="Save new bin" class="button save group" href="/save">Save</a>
+ <a href="<?=ROOT?>save" class="save title">Save</a>
+ <a id="save" title="Save new bin" class="button save group" href="<?=ROOT?>save">Save</a>
<?php endif ?>
- <a id="download" title="Save to drive" class="button download group light" href="/download">Download</a>
+ <a id="download" title="Save to drive" class="button download group light" href="<?=ROOT?>download">Download</a>
</div>
<span id="panelsvisible" class="gap">View:
@@ -101,7 +102,7 @@
</div>
<div id="live" class="stretch livepreview"><!-- <span class="close"></span> --></div>
<div id="preview" class="binview stretch"></div>
- <form method="post" action="<?=$code_id_path?>/save">
+ <form method="post" action="<?=$code_id_path?>save">
<input type="hidden" name="method" />
</form>
</div>
@@ -175,7 +176,7 @@
?>
</script>
<script>jsbin = { version: "<?=VERSION?>" }; tips = <?=file_get_contents('tips.json')?>;</script>
-<script src="/js/<?=VERSION?>/jsbin.js"></script>
+<script src="<?=ROOT?>js/<?=VERSION?>/jsbin.js"></script>
<?php if (!OFFLINE) : ?>
<script>
var _gaq = _gaq || [];
Oops, something went wrong.

4 comments on commit d03b966

Think twice about using shortcut tags for echoing data in PHP (i.e., )

Alot of people have this disabled in their configs, as well as it's disabled by default in recent PHP releases.

Owner

remy replied Jun 24, 2011

Hmm, really? Darn, it's all over the index file. You think I should change it then to the full <?php nonsense?

I could fork and submit a pull request if you'd like

Owner

remy replied Jun 24, 2011

I'm in the code right now, so it's not a problem.

Please sign in to comment.