myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2322] trunk: initial support for tailored themes


From: noreply
Subject: [myexperiment-hackers] [2322] trunk: initial support for tailored themes
Date: Wed, 27 Jan 2010 10:40:06 -0500 (EST)

Revision
2322
Author
dgc
Date
2010-01-27 10:40:05 -0500 (Wed, 27 Jan 2010)

Log Message

initial support for tailored themes

Modified Paths

Added Paths

Diff

Modified: trunk/app/controllers/application.rb (2321 => 2322)


--- trunk/app/controllers/application.rb	2010-01-23 10:18:44 UTC (rev 2321)
+++ trunk/app/controllers/application.rb	2010-01-27 15:40:05 UTC (rev 2322)
@@ -12,6 +12,8 @@
   
   WhiteListHelper.tags.merge %w(table tr td th div span)
   
+  before_filter :set_configuration
+
   include AuthenticatedSystem
   before_filter :login_from_cookie
   
@@ -39,8 +41,11 @@
     
     return res
   end
-  
 
+  def set_configuration
+    Conf.set_configuration(request, session)
+  end
+
   def formatted_timespan(time_period)
     # Takes a period of time in seconds and returns it in human-readable form (down to minutes)
     # from (http://www.postal-code.com/binarycode/category/devruby/)

Added: trunk/app/views/layouts/_myexperiment.rhtml (0 => 2322)


--- trunk/app/views/layouts/_myexperiment.rhtml	                        (rev 0)
+++ trunk/app/views/layouts/_myexperiment.rhtml	2010-01-27 15:40:05 UTC (rev 2322)
@@ -0,0 +1,117 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+		<%= t :site => "#{Conf.sitename} &#45; #{controller_visible_name(controller.controller_name.humanize)}", :separator => "&#45;" %>
+		<link rel="shortcut icon" href="" type="image/x-icon"/>
+		<%= stylesheet_link_tag 'reset-fonts-grids' %>
+		<%= stylesheet_link_tag 'base-min' %>
+		<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
+		<%= stylesheet_link_tag 'star_rating' %>
+		<%= stylesheet_link_tag Conf.stylesheet %>
+		<%= stylesheet_link_tag 'gadgets' %>
+		
+		<% if ["workflows", "users"].include?(controller.controller_name.downcase) and ["comments_timeline", "timeline"].include?(controller.action_name.downcase) -%>
+			<script src="" type="text/_javascript_"></script>
+		<% end -%>
+		
+		<%= _javascript__include_tag :defaults %>
+		<%= _javascript__include_tag "boxover.js" %>
+		
+		<%= render :partial => "layouts/feed_link_tags" %>
+	</head>
+	<body>
+		<div id="doc2" class="yui-t4">
+			<div id="hd">
+	  			<div id="myexp_header">
+	  				<div class="logo">
+						<%= link_to image_tag(Conf.site_logo), "/" %>
+					</div>
+					<div class="links">
+						<div style="text-align: left; float: left; width: 34%; padding-top: 6px;">
+							<span><b><%= link_to "About", "http://wiki.myexperiment.org/", :target => '_blank' %></b></span>
+							<span>&nbsp;|&nbsp;</span>
+							<span><b><%= link_to "Mailing List", "http://lists.nongnu.org/mailman/listinfo/myexperiment-discuss", :target => '_blank' %></b></span>
+							<span>&nbsp;|&nbsp;</span>
+							<span><b><%= link_to "Publications", "http://wiki.myexperiment.org/index.php/Papers", :target => '_blank' %></b></span>
+						</div>
+						<div style="text-align: right; float: right; width: 64%;">
+							<% if logged_in? -%>
+								<span><b><%= signout_link -%></b></span>
+							<% else -%>
+								<span><b><%= icon "login", new_session_url, nil, nil, "Log in" -%></b></span>
+								<span>&nbsp;|&nbsp;</span>
+								<span><b><%= icon "user", new_user_url, nil, nil, "Register" -%></b></span>
+							<% end %>
+							<span>&nbsp;|&nbsp;</span>
+							<span><b><%= icon "feedback", "/feedback", nil, nil, "Give us Feedback" -%></b></span>
+							<span>&nbsp;|&nbsp;</span>
+							<span><b><%= icon "user-invite", invite_users_path, nil, nil, "Invite" -%></b></span>
+						</div>
+						<div class="clearer">&nbsp;</div>
+					</div>
+					<div class="clearer">&nbsp;</div>
+				</div>
+				<div>
+					<ul class="tabnav">
+                                          <% Conf.main_tabs.each do |tab| %>
+                                            <li <%= (tab['controller'] && controller.controller_name.match(tab['controller'])) ? 'id="selected_tabnav"' : '' %>>
+                                              <%= link_to(tab['label'], tab['link']) -%>
+                                            </li>
+                                          <% end %>
+					</ul>
+				</div>
+	  			<div id="myexp_searchbar"><%= render :partial => "layouts/search" %></div>
+			</div>
+			<div id="bd">
+				<div id="yui-main"> 
+	  				<div class="yui-b">
+					    <div id="myexp_breadcrumbs_bar">
+								<%= render :partial => "layouts/breadcrumbs_bar" %>
+							</div>
+							
+              <pre>Woaa</pre>
+
+	    				<div id="myexp_content">
+								<% if flash[:error] %>
+									<div id="error_flash" class="box_standout" style="color: red; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
+										<%= link_to_function image_tag("close.gif", :style => "float: right;"), 
+																				 visual_effect(:toggle_slide, "error_flash", :duration => 0.3) %>
+										<%= white_list flash[:error] %>
+									</div>
+								<% end %>
+		    				<% if flash[:notice] %>
+									<div id="notice_flash" class="box_standout" style="color: green; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
+										<%= link_to_function image_tag("close.gif", :style => "float: right;"), 
+																				 visual_effect(:toggle_slide, "notice_flash", :duration => 0.3) %>
+										<%= white_list flash[:notice] %>
+									</div>
+								<% end %>
+								
+		    				<%= render :partial => "subnav" %>
+		    				
+								<%= yield :layout %>
+						</div>
+					</div>
+				</div>
+				<div id="myexp_sidebar" class="yui-b">
+					<%= render :partial => "layouts/sidebar" %>
+				</div>
+			</div>
+			<% cache(:controller => 'global_cache', :action ="" 'footer') do -%>
+				<div id="ft">
+					<%= render :partial => "layouts/footer" %>
+				</div>
+			<% end -%>
+			
+			<%= render :partial => "layouts/debug" if Conf.show_debug %> 
+		</div>
+		
+		<%= _javascript__include_tag "tabs.js" %>
+		<%= _javascript__include_tag "folds.js" %>
+		
+		<%= render :partial => "layouts/web_analytics" if Conf.google_web_analytics["enable"] %>
+	</body>
+</html>

Modified: trunk/app/views/layouts/application.rhtml (2321 => 2322)


--- trunk/app/views/layouts/application.rhtml	2010-01-23 10:18:44 UTC (rev 2321)
+++ trunk/app/views/layouts/application.rhtml	2010-01-27 15:40:05 UTC (rev 2322)
@@ -1,115 +1 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-	<head>
-		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
-		<%= t :site => "#{Conf.sitename} &#45; #{controller_visible_name(controller.controller_name.humanize)}", :separator => "&#45;" %>
-		<link rel="shortcut icon" href="" type="image/x-icon"/>
-		<%= stylesheet_link_tag 'reset-fonts-grids' %>
-		<%= stylesheet_link_tag 'base-min' %>
-		<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
-		<%= stylesheet_link_tag 'star_rating' %>
-		<%= stylesheet_link_tag 'styles' %>
-		<%= stylesheet_link_tag 'gadgets' %>
-		
-		<% if ["workflows", "users"].include?(controller.controller_name.downcase) and ["comments_timeline", "timeline"].include?(controller.action_name.downcase) -%>
-			<script src="" type="text/_javascript_"></script>
-		<% end -%>
-		
-		<%= _javascript__include_tag :defaults %>
-		<%= _javascript__include_tag "boxover.js" %>
-		
-		<%= render :partial => "layouts/feed_link_tags" %>
-	</head>
-	<body>
-		<div id="doc2" class="yui-t4">
-			<div id="hd">
-	  			<div id="myexp_header">
-	  				<div class="logo">
-						<%= link_to image_tag(Conf.site_logo), "/" %>
-					</div>
-					<div class="links">
-						<div style="text-align: left; float: left; width: 34%; padding-top: 6px;">
-							<span><b><%= link_to "About", "http://wiki.myexperiment.org/", :target => '_blank' %></b></span>
-							<span>&nbsp;|&nbsp;</span>
-							<span><b><%= link_to "Mailing List", "http://lists.nongnu.org/mailman/listinfo/myexperiment-discuss", :target => '_blank' %></b></span>
-							<span>&nbsp;|&nbsp;</span>
-							<span><b><%= link_to "Publications", "http://wiki.myexperiment.org/index.php/Papers", :target => '_blank' %></b></span>
-						</div>
-						<div style="text-align: right; float: right; width: 64%;">
-							<% if logged_in? -%>
-								<span><b><%= signout_link -%></b></span>
-							<% else -%>
-								<span><b><%= icon "login", new_session_url, nil, nil, "Log in" -%></b></span>
-								<span>&nbsp;|&nbsp;</span>
-								<span><b><%= icon "user", new_user_url, nil, nil, "Register" -%></b></span>
-							<% end %>
-							<span>&nbsp;|&nbsp;</span>
-							<span><b><%= icon "feedback", "/feedback", nil, nil, "Give us Feedback" -%></b></span>
-							<span>&nbsp;|&nbsp;</span>
-							<span><b><%= icon "user-invite", invite_users_path, nil, nil, "Invite" -%></b></span>
-						</div>
-						<div class="clearer">&nbsp;</div>
-					</div>
-					<div class="clearer">&nbsp;</div>
-				</div>
-				<div>
-					<ul class="tabnav">
-                                          <% Conf.main_tabs.each do |tab| %>
-                                            <li <%= (tab['controller'] && controller.controller_name.match(tab['controller'])) ? 'id="selected_tabnav"' : '' %>>
-                                              <%= link_to(tab['label'], tab['link']) -%>
-                                            </li>
-                                          <% end %>
-					</ul>
-				</div>
-	  			<div id="myexp_searchbar"><%= render :partial => "layouts/search" %></div>
-			</div>
-			<div id="bd">
-				<div id="yui-main"> 
-	  				<div class="yui-b">
-					    <div id="myexp_breadcrumbs_bar">
-								<%= render :partial => "layouts/breadcrumbs_bar" %>
-							</div>
-							
-	    				<div id="myexp_content">
-								<% if flash[:error] %>
-									<div id="error_flash" class="box_standout" style="color: red; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
-										<%= link_to_function image_tag("close.gif", :style => "float: right;"), 
-																				 visual_effect(:toggle_slide, "error_flash", :duration => 0.3) %>
-										<%= white_list flash[:error] %>
-									</div>
-								<% end %>
-		    				<% if flash[:notice] %>
-									<div id="notice_flash" class="box_standout" style="color: green; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
-										<%= link_to_function image_tag("close.gif", :style => "float: right;"), 
-																				 visual_effect(:toggle_slide, "notice_flash", :duration => 0.3) %>
-										<%= white_list flash[:notice] %>
-									</div>
-								<% end %>
-								
-		    				<%= render :partial => "subnav" %>
-		    				
-								<%= yield :layout %>
-						</div>
-					</div>
-				</div>
-				<div id="myexp_sidebar" class="yui-b">
-					<%= render :partial => "layouts/sidebar" %>
-				</div>
-			</div>
-			<% cache(:controller => 'global_cache', :action ="" 'footer') do -%>
-				<div id="ft">
-					<%= render :partial => "layouts/footer" %>
-				</div>
-			<% end -%>
-			
-			<%= render :partial => "layouts/debug" if Conf.show_debug %> 
-		</div>
-		
-		<%= _javascript__include_tag "tabs.js" %>
-		<%= _javascript__include_tag "folds.js" %>
-		
-		<%= render :partial => "layouts/web_analytics" if Conf.google_web_analytics["enable"] %>
-	</body>
-</html>
+<%= render :partial => Conf.page_template %>

Modified: trunk/config/default_settings.yml (2321 => 2322)


--- trunk/config/default_settings.yml	2010-01-23 10:18:44 UTC (rev 2321)
+++ trunk/config/default_settings.yml	2010-01-27 15:40:05 UTC (rev 2322)
@@ -33,6 +33,24 @@
 
 site_logo: logo.png
 
+# page_template - This is the page template for all the pages except for
+#                 the front page of the web site.
+#
+#                 Example:
+#
+#                   page_layout: layouts/myexperiment
+
+page_template: layouts/myexperiment
+
+# stylesheet - This is the main stylesheet used for all pages except for the
+#              front page of the web site.
+#
+#              Example:
+#
+#                stylesheet: styles
+
+stylesheet: styles
+
 # base_uri - Set "base_uri" to the main entry point to this installation of
 #            myExperiment.  If you use a load balancing solution to proxy
 #            incoming requests to a cluster, then this is the external address.

Modified: trunk/lib/conf.rb (2321 => 2322)


--- trunk/lib/conf.rb	2010-01-23 10:18:44 UTC (rev 2321)
+++ trunk/lib/conf.rb	2010-01-27 15:40:05 UTC (rev 2322)
@@ -121,17 +121,55 @@
     self.fetch_entry('curation_types')
   end
 
+  def self.page_template
+    self.fetch_entry('page_template')
+  end
+
+  def self.stylesheet
+    self.fetch_entry('stylesheet')
+  end
+
   # This method is required to create an administrator in the test fixtures
 
   def self.admins=(value)
     @settings['admins'] = value
   end
 
+  def self.set_configuration(request, session)
+
+    @config = nil
+
+    if @settings['virtual_hosts']
+      @settings['virtual_hosts'].each do |name, settings|
+
+        if settings['entry_point'] && request.referer && settings['entry_point']
+          if request.referer == settings['entry_point']
+            session["portal"] = name
+          end
+        end
+
+        if settings['host'] && request.host == settings['host']
+          @config = name
+        end
+      end
+    end
+
+    @config = session["portal"] if session["portal"]
+  end
+
 private
 
   def self.fetch_entry(key, default = nil)
+
+    if @config != nil
+      if @settings['virtual_hosts'address@hidden
+        return @settings['virtual_hosts'address@hidden
+      end
+    end
+
     return @settings[key] if @settings[key]
     return @defaults[key] if @defaults[key]
+
     default
   end
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]