Commit:    42958479f8d6a4dcc37ebb38c169d2bb64861c5b
Author:    Hannes Magnusson <[email protected]>         Mon, 30 Dec 2013 
18:58:09 -0800
Parents:   1471bf399966e3ae1c53e361a684b6a15391104e
Branches:  master

Link:       
http://git.php.net/?p=web/shared.git;a=commitdiff;h=42958479f8d6a4dcc37ebb38c169d2bb64861c5b

Log:
Point to shared.php.net when on prod server (e.g. '.php.net' hostname)

For local development, clone this repo into folder called "shared"

Changed paths:
  M  templates/footer.inc
  M  templates/header.inc


Diff:
diff --git a/templates/footer.inc b/templates/footer.inc
index d8c375e..04f7272 100644
--- a/templates/footer.inc
+++ b/templates/footer.inc
@@ -4,11 +4,13 @@
  *
  * Required variables:
  *
- *   $JS = array("//example.com/external.js", "/shared/js/local.js");
+ *   // Relative to /share, or prefixed with // for external js
+ *   $JS = array("//example.com/external.js", "/js/local.js");
  */
 
 isset($JS) || $JS = array();
 isset($SECONDSCREEN) || $SECONDSCREEN = "";
+$ROOT = substr($_SERVER["SERVER_NAME"], -8) == ".php.net" ? "//shared.php.net" 
: "/shared";
 ?>
 
 <?php if ($SECONDSCREEN): ?>
@@ -28,7 +30,11 @@ isset($SECONDSCREEN) || $SECONDSCREEN = "";
 </footer>
 
 <?php foreach($JS as $script) :?>
-<script type="text/javascript" src="<?=$script?>"></script>
+  <?php if (strncmp($script, "//", 2) == 0): ?>
+    <script type="text/javascript" src="<?php echo $script?>"></script>
+  <?php else: ?>
+    <script type="text/javascript" src="<?php echo $ROOT ?><?php echo 
$script?>"></script>
+  <?php endif ?>
 <?php endforeach ?>
 </body>
 </html>
diff --git a/templates/header.inc b/templates/header.inc
index 7e7a8a3..13d615e 100644
--- a/templates/header.inc
+++ b/templates/header.inc
@@ -10,7 +10,7 @@
  *   $HEAD_RAND = ""; // Random extra values needed for in <head>
  *                  array("href" => "/link.php", "text" => "Link text")
  *                ); // Menu menu links
- *   $CSS       = array("//example.com/external.css", 
"/shared/styles/local.js");
+ *   $CSS       = array("/styles/local.css"); // (relative to /shared)
  *   $SEARCH    = array(
  *                  "method"      => "get",
  *                  "action"      => "/search.php",
@@ -25,6 +25,7 @@ isset($LINKS)     || $LINKS     = array();
 isset($HEAD_RAND) || $HEAD_RAND = "";
 isset($CSS)       || $CSS       = array();
 isset($SEARCH)    || $SEARCH    = array();
+$ROOT = substr($_SERVER["SERVER_NAME"], -8) == ".php.net" ? "//shared.php.net" 
: "/shared";
 ?>
 <!DOCTYPE html>
 <html>
@@ -33,10 +34,10 @@ isset($SEARCH)    || $SEARCH    = array();
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
   <title>PHP: <?=$TITLE ?></title>
-  <link type="text/css" media="all" rel="stylesheet" 
href="/shared/styles/defaults.css">
+  <link type="text/css" media="all" rel="stylesheet" href="<?php echo 
$ROOT?>/styles/defaults.css">
 
 <?php foreach($CSS as $style): ?>
-  <link type="text/css" media="all" rel="stylesheet" href="<?=$style?>">
+  <link type="text/css" media="all" rel="stylesheet" href="<?php echo 
$ROOT?><?php echo $style?>">
 <?php endforeach ?>
 
   <link 
href="//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,400italic,600italic|Source+Code+Pro&subset=latin,latin-ext"
 rel="stylesheet" type="text/css">


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to