Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Added theme support
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Sep 13, 2008
1 parent 9be6d38 commit 9581525
Show file tree
Hide file tree
Showing 51 changed files with 1,412 additions and 5 deletions.
31 changes: 31 additions & 0 deletions app/controllers/admin/site_settings_controller.rb
@@ -0,0 +1,31 @@
class Admin::SiteSettingsController < Admin::BaseController
include ThemesManagementHelper
before_filter :get_settings
before_filter :get_themes, :only => [:edit]

protected
def get_settings
@settings = settings # This is defined in site_settings_helper
end

def get_themes
@themes = list_themes
end

public
def show
end

def edit
end

def update
if @settings.update_attributes(params[:site_setting])
flash[:notice] = "Site Settings were updated successfully."
redirect_to :action => 'show'
else
flash.now[:error] = "There was a problem updating the site settings."
render :action => 'edit'
end
end
end
2 changes: 2 additions & 0 deletions app/controllers/application.rb
@@ -1,7 +1,9 @@
class ApplicationController < ActionController::Base
include AuthenticatedSystem
include SiteSettingsHelper
before_filter :login_from_cookie, :setup_plugin_nav, :set_layout_variables
helper :all
theme :get_theme_setting

def set_layout_variables
@root = Page.root
Expand Down
6 changes: 6 additions & 0 deletions app/models/site_setting.rb
@@ -0,0 +1,6 @@
class SiteSetting < ActiveRecord::Base
def get_theme_setting
theme_setting = self.send(:user_theme_name)
theme_setting.blank? ? 'default' : theme_setting
end
end
5 changes: 3 additions & 2 deletions app/views/admin/_tabs.html.erb
Expand Up @@ -2,8 +2,9 @@
<div id="hd">
<%= render :partial => "admin/page_plugins/admin_plugins_nav" -%>
<ul id='base-links'>
<li><%= create_tab('Manage Pages', '/admin/pages') %></li>
<li><%= create_tab('List Plugins', '/admin/plugins') %></li>
<li><%= create_tab('Manage Pages', '/admin/pages') %></li>
<li><%= create_tab('Site Settings', '/admin/site_settings') %></li>
<li><%= create_tab('List Plugins', '/admin/plugins') %></li>
<li><%= create_tab('Account Settings', '/admin/account/update') %></li>
<li><%= create_tab('Logout', '/admin/account/logout') %></li>
</ul>
Expand Down
7 changes: 7 additions & 0 deletions app/views/admin/site_settings/edit.html.erb
@@ -0,0 +1,7 @@
<h1>Edit Site Settings</h1>
<% form_tag 'update' do -%>
<% fields_for @settings do |f| -%>
<%= f.select(:user_theme_name, @themes) -%>
<%= submit_tag 'Update' -%>
<% end -%>
<% end -%>
5 changes: 5 additions & 0 deletions app/views/admin/site_settings/show.html.erb
@@ -0,0 +1,5 @@
<h1>Site Settings</h1>
<% content_for :sidebar do -%>
<%= link_to 'Edit Settings', edit_admin_site_settings_path -%>
<% end -%>
User Theme: <%= @settings.get_theme_setting -%>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -11,6 +11,7 @@
admin.resources :plugins
admin.resource :account
admin.connect 'account/:action/:id', :controller => 'account'
admin.resource :site_settings
end
map.connect '/admin', :controller => 'admin/pages'

Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20080913132029_create_site_settings.rb
@@ -0,0 +1,14 @@
class CreateSiteSettings < ActiveRecord::Migration
def self.up
create_table :site_settings do |t|
t.string :name
t.string :user_theme_name

t.timestamps
end
end

def self.down
drop_table :site_settings
end
end
13 changes: 13 additions & 0 deletions lib/site_settings_helper.rb
@@ -0,0 +1,13 @@
module SiteSettingsHelper
def get_setting(name)
settings.send(name)
end

def get_theme_setting
settings.get_theme_setting
end

def settings
SiteSetting.find_or_create_by_name(:default)
end
end
2 changes: 1 addition & 1 deletion lib/tasks/utils.rake
Expand Up @@ -10,4 +10,4 @@ namespace :utils do
puts "Initial user already exists, exiting"
end
end
end
end
9 changes: 9 additions & 0 deletions lib/themes_management_helper.rb
@@ -0,0 +1,9 @@
module ThemesManagementHelper
def list_themes
themes_dir.entries.sort.delete_if{|e| e =~ /^\.$|^\.\.$/ }
end

def themes_dir
Dir.new("#{RAILS_ROOT}/themes")
end
end
2 changes: 1 addition & 1 deletion public/stylesheets/admin.css
Expand Up @@ -79,7 +79,7 @@ body{
padding:5px;
width: 71%;
margin-left: 10px;
border-width: 0 2px 4px 0px;
border-width: 0 2px 2px 0px;
border-style: solid;
border-color: #aaa;
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions public/themes/default/stylesheets/stylesheets/base.css
@@ -0,0 +1,129 @@
html {
background:#000;
color: #ddd;
/* background-image: url(/images/background-blue-squares.png); */
/* background-image: url(/images/background-blue-squares-2.png); */
/* background-image: url(/images/background-blue-squares-3.png); */
/* background-image: url(/images/background-blue-squares-4.png); */
/* background-image: url(/images/background-blue-squares-5.png); */
/* background-image: url(/images/background-blue-squares-6.png); */
/* background-image: url(/images/background-blue-squares-7.png); */
background-image: url(/themes/default/images/background-red-squares-7.png);
background-repeat: repeat-x;
}
body{
font-family: "Gill Sans","Franklin Gothic Medium","Lucida Grande",Arial,Helvetica;
}
#main{
width: 800px;
margin: 0 auto;
position: relative;
}
#header{
margin-bottom: 10px;
}
#header h1{
font-size: 260%;
color: #fff;
background-color: #000;
padding: 10px 0;
width: 260px;
}
#header .credits{
display: block;
background-color: #c2c655;
color: #111;
position: absolute;
top: 0;
left: 500px;
padding: 4px 10px 10px 10px;
line-height: 1.4em;
}
#header .credits a{
background-color: #868a1f;
padding: 2px;
color: white;
}
#header h1 span.logo{
padding-left: 20px;
background-image: url(/images/ansuz_logo.png);
background-repeat: no-repeat;
background-position: center;
background-color: #111;
margin-right: 10px;
}
#navigation{
width: 200px;
float: left;
margin: 0 10px 0 0;
}
#navigation h3{
display: none;
}
#navigation li a{
padding: 5px 10px;
background-color: #111;
color: #ccc;
display: block;
text-decoration: none;
}
#navigation li.active a,
#navigation li.active a:hover {
background-color: #c8379a;
color: white;
cursor: default;
}
#navigation li a:hover {
color: white;
border-left: 4px solid #0084ff;
padding-left: 6px;
background-color: #222;
}
div#breadcrumb{
background-color: #222;
margin: -10px -10px 5px -10px;
padding: 10px;
}
#content{
width: 570px;
background-color: #333;
float: left;
padding: 10px;
}
#footer{
margin-top: 10px;
background-color: #111;
color: #aaa;
padding: 10px;
}
div.clear{
clear: both;
}
h2{
font-size: 175%;
color: #0084ff;
}
h3{
font-size: 120%;
color: #0084ff;
background-color: #111;
padding: 6px 10px;
margin: 20px 0 6px;
}
p{
margin-bottom: 10px;
}
ol{
margin-left: 20px;
}
ol li{
list-style-type: decimal;
}
.module{
background-color: #333;
color: #ccc;
padding: 10px;
}
a{
color: #0084FF;
}
7 changes: 7 additions & 0 deletions test/fixtures/site_settings.yml
@@ -0,0 +1,7 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

one:
user_theme_name: MyString

two:
user_theme_name: MyString
8 changes: 8 additions & 0 deletions test/unit/site_setting_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class SiteSettingTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end
1 change: 1 addition & 0 deletions themes/default-pink/about.markdown
@@ -0,0 +1 @@
Default Ansuz Theme
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions themes/default-pink/layouts/application.html.erb
@@ -0,0 +1,43 @@
<!-- Generated Using Ansuz CMS -->
<!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" lang="en" xml:lang="en">
<head>
<title>Ansuz with Themes!</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="description" content="Ansuz Content Management System" />
<meta name="keywords" content="Ansuz Content Management System" />
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
<%= stylesheet_link_tag 'yui-reset-fonts' -%>
<%= stylesheet_link_tag 'base' -%>
<%= stylesheet_link_tag 'sprite' -%>
<%= stylesheet_link_tag 'lightbox' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jqModal', 'jquery.growl.js' -%>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
<div id='wrapper'>
<div id="main">
<div id='header'>
<h1>
<span class='logo'></span>
<span>Ansuz CMS!</span>
</h1>
<span class='credits'>
An open source CMS co-developed by:
<a href="http://www.isotope11.com">Isotope Eleven</a>,
<a href="http://www.isshen.com">Isshen</a>, and
<a href="http://github.com/knewter/ansuz/tree/master">you</a>.
</span>
</div>
<div id='content'>
<%= @content_for_layout -%>
</div>
<div class='clear'></div>
<%= render :partial => "page/footer" -%>
</div>
</div>
</body>
</html>
46 changes: 46 additions & 0 deletions themes/default-pink/layouts/page.html.erb
@@ -0,0 +1,46 @@
<!-- Generated Using Ansuz CMS -->
<!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" lang="en" xml:lang="en">
<head>
<title>Ansuz - <%= @page.title if @page -%> - with themes!</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="description" content="Ansuz Content Management System" />
<meta name="keywords" content="Ansuz Content Management System" />
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
<%= stylesheet_link_tag 'yui-reset-fonts' -%>
<%= theme_stylesheet_link_tag 'base' -%>
<%= stylesheet_link_tag 'sprite' -%>
<%= stylesheet_link_tag 'lightbox' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jqModal', 'jquery.growl.js', 'ansuz/growls' -%>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
<div id='wrapper'>
<div id="main">
<div id='header'>
<h1>
<span class='logo'></span>
<span>Ansuz CMS</span>
</h1>
<span class='credits'>
An open source CMS co-developed by:
<a href="http://www.isotope11.com">Isotope Eleven</a>,
<a href="http://www.isshen.com">Isshen</a>, and
<a href="http://github.com/knewter/ansuz/tree/master">you</a>.
</span>
</div>
<%= render :partial => "page/top_nav" -%>
<div id='content'>
<%= render :partial => "page/breadcrumb" if (@page && (@page != @root)) -%>
<%= @content_for_layout -%>
<%= render :partial => "page/child_nav" if (@page && (!@page.children.empty?)) -%>
</div>
<div class='clear'></div>
<%= render :partial => "page/footer" -%>
</div>
</div>
</body>
</html>

0 comments on commit 9581525

Please sign in to comment.