Commits

Greg Slepak committed d7f610d

added web-root function to allow demo site to run in non-root according to INSTALL

  • Participants
  • Parent commits db78b07

Comments (0)

Files changed (7)

File example-site/dragonfly-framework/config.lsp

 ; dragonfly root
 (constant (global 'DRAGONFLY_ROOT) (string DOCUMENT_ROOT "/dragonfly-framework"))
 ; sync any customization of DOCUMENT_ROOT with the 'env'
-; don't modify this line
+; don't modify these two lines
+(constant (global 'ORIGINAL_ROOT) DOCUMENT_ROOT)
 (env "DOCUMENT_ROOT" DOCUMENT_ROOT)
 
 (context 'Dragonfly)

File example-site/dragonfly-framework/dragonfly.lsp

 ; !Public Functions
 ;===============================================================================
 
+(define (web-root path)
+	; WEB_ROOT should have a "/" on the end
+	(string WEB_ROOT path)
+)
+
 (define (view-path viewname)
 	(string VIEWS_PATH "/" viewname (if TEMPLATE_EXTENSION TEMPLATE_EXTENSION ""))
 )
 [/text]
 )
 
+(set 'WEB_ROOT (slice DOCUMENT_ROOT (length ORIGINAL_ROOT)))
+(push "/" WEB_ROOT -1)
+
 (context MAIN)

File example-site/includes/css/twitter.css

 	margin: 0px;
 	padding: 7px 0px 0px 15px;
 	top: 6px;
-	background: transparent url(includes/images/tip.gif) no-repeat 20px 0;
+	background: transparent url(/includes/images/tip.gif) no-repeat 20px 0;
 	font-style: normal;
 }

File example-site/views/404

 			<p><% (title "| marchildmann.com") %><p>
 		</div>
 		
-		<img src="includes/images/houses.jpg" class="border" alt="Houses" width="474" height="267"/>
+		<img src="<%=(web-root "includes/images/houses.jpg")%>" class="border" alt="Houses" width="474" height="267"/>
 		
 		
 		<h1>We did the best we can ...</h1>

File example-site/views/dragonfly_welcome

 			<p><% (title "| Dragonfly web framework") %><p>
 		</div>
 		
-		<img src="includes/images/houses.jpg" class="border" alt="Houses" width="474" height="267"/>
+		<img src="<%=(web-root "includes/images/houses.jpg")%>" class="border" alt="Houses" width="474" height="267"/>
 		
 		<h1>Introduction</h1>
 		<p class="extract">Dragonfly is a <b>web framework for newLISP</b>. Development started in June 2009. It focuses on <b>speed</b>, small memory consumption and a <b>small learning curve</b>. Other goodies are a plug and play architecture for writing own helpers or modules and a very <b>easy deployment</b>. It's possible to use it with the builtin newLISP webserver.

File example-site/views/partials/header

 	<title><% (title "Dragonfly web framework - User Guide") %></title>
 	<% (meta "author" "Marc Hildmann") %>
 	<% (meta "keywords" "newlisp, framework, dragonfly, web framework") %>
-	<% (css "screen" "includes/css/screen.css") %>
-	<% (script "includes/js/dragonfly.js") %>
+	<% (css "screen" (web-root "includes/css/screen.css")) %>
+	<% (script (web-root "includes/js/dragonfly.js")) %>
 	<% (rss "Dragonfly web framework RSS Feed" "/dragonfly_rssfeed/xml") %>
 </head>

File example-site/views/partials/navigation

 <!-- BEGIN NAVIGATION -->
-<img src="includes/images/marchildmann-com.gif" alt="MarcHildmann.com" width="474" height="50"/>
+<img src="<%=(web-root "includes/images/marchildmann-com.gif")%>" alt="MarcHildmann.com" width="474" height="50"/>
 <ul>
 	<li>
 	<a href="index.html" onclick="toggleMenu(); return false;" id="guidesMenu">Dragonfly web framework</a>