Changesets can be listed by changeset number.
The Git repository is here.
Changeset 208
First attempt at Gullery configured for the ROOL site. Unfroze the
Rails revision by deleting vendor/rails; Hub integration by a veneer
in the lib/authenticated_system.rb (Acts As Authenticated) plug-in,
plus some view changes and protection for the Account controller;
rewrote the default layout in .rhtml rather than .mab; plus the
usual set of configuration changes to work from a subdirectory and
with the ROOL database server.
- Comitted by: rool
- Date: Sunday May 20 19:12:33 2007 (over 17 years ago)
Affected files:
- rool/rails/gullery/trunk/app/views/shared/
- rool/rails/gullery/trunk/app/views/layouts/application.rhtml
- rool/rails/gullery/trunk/app/views/shared/_powered.rhtml
- rool/rails/gullery/trunk/app/views/shared/_theme.rhtml
- rool/rails/gullery/trunk/config/database.yml
- rool/rails/gullery/trunk/vendor/rails/
- rool/rails/gullery/trunk/app/views/layouts/application.mab
- rool/rails/gullery/trunk/app/controllers/account_controller.rb (diff)
- rool/rails/gullery/trunk/app/controllers/application.rb (diff)
- rool/rails/gullery/trunk/app/controllers/projects_controller.rb (diff)
- rool/rails/gullery/trunk/app/helpers/application_helper.rb (diff)
- rool/rails/gullery/trunk/app/views/projects/_asset.mab (diff)
- rool/rails/gullery/trunk/app/views/projects/_project.mab (diff)
- rool/rails/gullery/trunk/app/views/projects/index.mab (diff)
- rool/rails/gullery/trunk/app/views/projects/show.mab (diff)
- rool/rails/gullery/trunk/config/environment.rb (diff)
- rool/rails/gullery/trunk/config/routes.rb (diff)
- rool/rails/gullery/trunk/lib/authenticated_system.rb (diff)
- rool/rails/gullery/trunk/public/dispatch.cgi (diff)
- rool/rails/gullery/trunk/public/dispatch.fcgi (diff)
- rool/rails/gullery/trunk/public/dispatch.rb (diff)
- rool/rails/gullery/trunk/public/javascripts/lightbox.js (diff)
- rool/rails/gullery/trunk/public/stylesheets/lightbox.css (diff)
- rool/rails/gullery/trunk/public/stylesheets/site.css (diff)
rool/rails/gullery/trunk/app/controllers/account_controller.rb:
prev. | current | |
include AuthenticatedSystem | ||
observer :user_observer | ||
5 | ||
before_filter :login_required, :only => [:update_description] | ||
7 | @@hubssolib_permissions = HubSsoLib::Permissions.new({ | |
8 | :update_description => [ :admin, :webmaster, :privileged ], | |
9 | :index => [ :admin, :webmaster, :privileged ], | |
10 | :login => [ :admin, :webmaster, :privileged ], | |
11 | :signup => [ :admin, :webmaster, :privileged ], | |
12 | :logout => [ :admin, :webmaster, :privileged ], | |
13 | }) | |
14 | ||
15 | def AccountController.hubssolib_permissions | |
16 | @@hubssolib_permissions | |
17 | end | |
18 | ||
def update_description | ||
current_user.description = @params[:value] | ||
if current_user.save | ||
... | ... | |
end | ||
end | ||
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
def index | ||
redirect_to(:action => 'signup') unless logged_in? or User.count > 0 | ||
end | ||
29 | | |
30 | | |
31 | | |
32 | | |
def login | ||
return unless request.post? | ||
::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 4.weeks.from_now) if params[:remember_me] | ||
... | ... | |
end | ||
end | ||
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
70 | ||
def logout | ||
self.current_user = nil | ||
flash[:notice] = "You have been logged out." |
rool/rails/gullery/trunk/app/controllers/application.rb:
prev. | current | |
# Filters added to this controller will be run for all controllers in the application. | ||
# Likewise, all the methods added will be available for all controllers. | ||
class ApplicationController < ActionController::Base | ||
4 | # Hub single sign-on support. Run the Hub filters for all actions to | |
5 | # ensure activity timeouts etc. work properly. Gullery accounts are | |
6 | # only allowed for privileged Hub users. Gullery uses Acts As | |
7 | # Authenticated itself - the distant parent of Hub itself - so all | |
8 | # we do is put a wrapper around the AAA library code. | |
9 | ||
10 | require 'hub_sso_lib' | |
11 | include HubSsoLib::Core | |
12 | before_filter :hubssolib_beforehand | |
13 | after_filter :hubssolib_afterwards | |
14 | ||
15 | # Gullery's standard preamble | |
16 | ||
include AuthenticatedSystem | ||
helper_method :textilight, :textilize | ||
... | ... | |
r.to_html.gsub(/^\s+/, '') | ||
end | ||
20 | ||
34 | end |
rool/rails/gullery/trunk/app/controllers/projects_controller.rb:
prev. | current | |
class ProjectsController < ApplicationController | ||
2 | | |
2 | include AuthenticatedSystem | |
3 | ||
before_filter :login_required, :only => [:create, :update_description, :destroy, :sort] | ||
4 | | |
5 | ||
def index | ||
if User.count == 0 | ||
redirect_to signup_url | ||
return | ||
end | ||
11 | @logged_in = logged_in? | |
@user = User.find_first | ||
@projects = Project.find :all, :order => 'position, created_at' | ||
end | ||
def show | ||
17 | @logged_in = logged_in? | |
@project = Project.find @params[:id] | ||
end | ||
rool/rails/gullery/trunk/app/helpers/application_helper.rb:
prev. | current | |
module ApplicationHelper | ||
def show_page_title | ||
5 | | |
5 | !@user.nil? && !@user.company.blank? ? @user.company : 'Photo gallery' | |
end | ||
def show_page_nav | ||
user = User.find_first | ||
10 | | |
11 | | |
12 | | |
10 | return 'Photo gallery' if user.nil? | |
11 | nav = link_to(user.company + (@project ? ':' : ''), :controller => '/') | |
12 | nav += ' ' + @project.name if @project | |
nav | ||
end | ||
15 | | |
16 | | |
end |
rool/rails/gullery/trunk/app/views/projects/_asset.mab:
prev. | current | |
@indent = 0 | ||
li :id => "asset_#{asset.id}" do | ||
3 | | |
3 | if @logged_in | |
div.toolbar(:width => Asset.thumbnail_width) do | ||
span.handle { "drag" } | ||
span.rotate do | ||
... | ... | |
span.delete { link_to_remote " delete ×", :url => capture { assets_url(:action => 'destroy', :id => asset.id) }, :confirm => "Do you want to delete this photo?" } | ||
end | ||
end | ||
14 | | |
14 | link_to image_tag(asset.web_path(:thumb), :width => Asset.thumbnail_width, :height => Asset.thumbnail_height), PATH_PREFIX + asset.web_path, :rel => 'lightbox', :title => capture { textilight(asset.caption) } | |
render :partial => 'asset_caption', :locals => {:asset => asset} | ||
16 | | |
16 | if @logged_in | |
in_place_editor "asset_caption_#{asset.id}", :url => capture { assets_url(:action => 'update_caption', :id => asset.id) } | ||
end | ||
end |
rool/rails/gullery/trunk/app/views/projects/_project.mab:
prev. | current | |
li :id => "project_#{project.id}" do | ||
2 | | |
2 | if @logged_in | |
div.toolbar(:width => Asset.thumbnail_width) do | ||
span.handle { "drag" } | ||
span.delete { link_to_remote " delete ×", :url => capture { projects_url(:action => 'destroy', :id => project.id) }, :confirm => "Do you want to delete this entire project?" } |
rool/rails/gullery/trunk/app/views/projects/index.mab:
prev. | current | |
render :partial => 'project', :collection => @projects | ||
end | ||
9 | ||
9 | if @logged_in | |
render(:partial => 'project_form') | ||
in_place_editor "user_description", | ||
:url => capture { account_url(:action => 'update_description') }, |
rool/rails/gullery/trunk/app/views/projects/show.mab:
prev. | current | |
render :partial => 'asset', :collection => @project.assets | ||
end | ||
10 | ||
10 | if @logged_in | |
render(:partial => 'asset_form') | ||
sortable_element 'asset_list', | ||
:url => capture { assets_url(:action => 'sort', :project_id => @project) }, |
rool/rails/gullery/trunk/config/environment.rb:
prev. | current | |
# Bootstrap the Rails environment, frameworks, and default configuration | ||
require File.join(File.dirname(__FILE__), 'boot') | ||
10 | PATH_PREFIX = ENV['RAILS_RELATIVE_URL_ROOT'] | |
11 | ||
Rails::Initializer.run do |config| | ||
13 | # We don't run in the document root, so images etc. must come from | |
14 | # a non-root location too. Hijack the 'asset host' facility to get | |
15 | # helper-based links pointing in the right place. | |
16 | config.action_controller.asset_host = PATH_PREFIX | |
17 | ||
# Settings in config/environments/* take precedence those specified here | ||
# Skip frameworks you're not going to use | ||
... | ... | |
# Force all environments to use the same logger level | ||
# (by default production uses :info, the others :debug) | ||
21 | | |
28 | config.log_level = :warn | |
# Use the database for sessions instead of the file system | ||
# (create the session table with 'rake create_sessions_table') | ||
... | ... | |
# Include your application configuration below | ||
require 'taggable' | ||
63 | ||
64 | ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = 'gulleryapp_session_id' | |
65 |
rool/rails/gullery/trunk/config/routes.rb:
prev. | current | |
1 | PATH_PREFIX ||= '' | |
2 | ||
ActionController::Routing::Routes.draw do |map| | ||
3 | | |
5 | map.connect PATH_PREFIX + '/', :controller => "projects" | |
5 | | |
6 | | |
7 | | |
7 | map.signup PATH_PREFIX + '/signup', :controller => "account", :action => 'signup' | |
8 | map.login PATH_PREFIX + '/login', :controller => "account", :action => 'login' | |
9 | map.logout PATH_PREFIX + '/logout', :controller => "account", :action => 'logout' | |
9 | | |
10 | | |
11 | | |
11 | map.projects PATH_PREFIX + '/projects/:action/:id', :controller => 'projects' | |
12 | map.assets PATH_PREFIX + '/assets/:action/:id', :controller => 'assets', :action => 'show' | |
13 | map.account PATH_PREFIX + '/account/:action', :controller => 'account' | |
# Allow downloading Web Service WSDL as a file with an extension | ||
# instead of a file named 'wsdl' | ||
15 | | |
17 | map.connect PATH_PREFIX + '/:controller/service.wsdl', :action => 'wsdl' | |
# Install the default route as the lowest priority. | ||
18 | | |
20 | map.connect PATH_PREFIX + '/:controller/:action/:id' | |
end |
rool/rails/gullery/trunk/lib/authenticated_system.rb:
prev. | current | |
protected | ||
def logged_in? | ||
6 | | |
6 | (!hubssolib_privileged? || current_user.nil?) ? false : true | |
end | ||
# accesses the current user from the session. | ||
... | ... | |
# user.login != "bob" | ||
# end | ||
def authorized?(user) | ||
42 | | |
42 | hubssolib_privileged? | |
end | ||
# overwrite this method if you only want to protect certain actions of the controller | ||
... | ... | |
# example use : | ||
# a popup window might just close itself for instance | ||
def access_denied | ||
90 | | |
90 | redirect_to '/hub/account/login' | |
end | ||
# store current uri in the session. | ||
... | ... | |
def self.included(base) | ||
base.send :helper_method, :current_user, :logged_in? | ||
end | ||
109 | ||
110 | end |
rool/rails/gullery/trunk/public/dispatch.cgi:
prev. | current | |
1 | ||
1 | #!/bin/env ruby | |
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) | ||
... | ... | |
require "dispatcher" | ||
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) | ||
10 | ||
11 | Dispatcher.dispatch |
rool/rails/gullery/trunk/public/dispatch.fcgi:
prev. | current | |
1 | ||
1 | #!/bin/env ruby | |
# | ||
# You may specify the path to the FastCGI crash log (a log of unhandled | ||
# exceptions which forced the FastCGI instance to exit, great for debugging) |
rool/rails/gullery/trunk/public/dispatch.rb:
prev. | current | |
1 | ||
1 | #!/bin/env ruby | |
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) | ||
... | ... | |
require "dispatcher" | ||
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) | ||
10 | ||
11 | Dispatcher.dispatch |
rool/rails/gullery/trunk/public/javascripts/lightbox.js:
prev. | current | |
// | ||
// If you would like to use a custom loading image or close button reference them in the next two lines. | ||
38 | ||
39 | ||
38 | var loadingImage = '/images/risc_os_open/lightbox/loading.gif'; | |
39 | var closeButton = '/images/risc_os_open/lightbox/close.gif'; | |
... | ... | |
// create keyboard message | ||
var objKeyboardMsg = document.createElement("div"); | ||
objKeyboardMsg.setAttribute('id','keyboardMsg'); | ||
407 | | |
407 | objKeyboardMsg.innerHTML = 'press <a href="#" onclick="hideLightbox(); return false;"><kbd>x</kbd></a> to close'; | |
objLightboxDetails.appendChild(objKeyboardMsg); | ||
... | ... | |
437 | ||
438 | addLoadEvent(initLightbox); // run initLightbox onLoad |
rool/rails/gullery/trunk/public/stylesheets/lightbox.css:
prev. | current | |
1 | ||
2 | | |
3 | | |
4 | | |
5 | ||
6 | | |
7 | | |
8 | | |
9 | ||
10 | ||
11 | ||
1 | /* Modified Lightbox CSS file. Taken originally from: | |
2 | * http://www.huddletogether.com/projects/lightbox/ | |
3 | */ | |
13 | ||
14 | ||
5 | #lightbox | |
6 | { | |
7 | background-color:#eee; | |
8 | padding: 10px; | |
9 | } | |
16 | ||
11 | #lightbox A, | |
12 | #lightbox A:hover, | |
13 | .lightboxplugin A, | |
14 | .lightboxplugin A:hover | |
15 | { | |
16 | border: none; | |
17 | background: inherit; | |
18 | } | |
18 | ||
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
21 | #lightboxDetails | |
22 | { | |
23 | font-size: 100%; | |
24 | padding-top: 0.4em; | |
25 | } | |
26 | ||
27 | #lightboxDetails KBD | |
28 | { | |
29 | font-size: 150%; | |
30 | } | |
31 | ||
32 | #lightboxCaption { float: left; margin-top: 5px } | |
33 | #keyboardMsg { float: right; } | |
34 | #closeButton { top: 0px; right: 0px; } | |
35 | ||
36 | #lightbox IMG { border: none; clear: both;} | |
37 | #overlay IMG { border: none; } | |
38 | ||
39 | #overlay { background-image: url("/images/risc_os_open/lightbox/overlay.png"); } | |
40 | ||
41 | * HTML #overlay | |
42 | { | |
43 | background-color: #333; | |
44 | back\ground-color: transparent; | |
45 | background-image: url("/images/utilities/blank.gif"); | |
46 | filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="/images/risc_$ | |
47 | } |
rool/rails/gullery/trunk/public/stylesheets/site.css:
prev. | current | |
1 | /* RISC OS Open Gullery theme stylesheet. | |
2 | * | |
3 | * Heavily based on the Gullery default theme. | |
4 | */ | |
2 | ||
3 | | |
4 | ||
6 | @import url("/css/risc_os_open.css"); | |
6 | ||
7 | | |
8 | | |
9 | | |
10 | ||
11 | ||
input { | ||
color: black; | ||
} | ||
... | ... | |
#container { | ||
text-align: center; | ||
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
} | ||
29 | ||
30 | | |
31 | ||
33 | ||
34 | | |
35 | | |
36 | | |
37 | ||
38 | ||
39 | ||
40 | | |
41 | ||
42 | ||
43 | ||
44 | ||
45 | | |
46 | ||
47 | ||
48 | ||
49 | | |
50 | | |
51 | | |
52 | | |
53 | ||
54 | ||
55 | ||
/****************************** | ||
* HTML Elements | ||
******************************/ | ||
60 | ||
61 | | |
62 | | |
63 | | |
64 | | |
24 | h2 { | |
25 | text-align: left; | |
} | ||
67 | ||
68 | | |
69 | | |
70 | ||
71 | ||
72 | | |
73 | | |
74 | ||
75 | ||
76 | ||
28 | #container form { | |
display: block; | ||
clear: both; | ||
text-align: center; | ||
padding: 1em; | ||
} | ||
83 | ||
35 | #container input { | |
font-size: 1.2em; | ||
padding: 0.2em; | ||
margin-right: 10px; | ||
margin-top: 5px; | ||
} | ||
90 | ||
91 | | |
92 | ||
93 | ||
94 | ||
42 | #container div.description { | |
text-align: left; | ||
} | ||
... | ... | |
#asset_list li { | ||
float: left; | ||
padding: 8px; | ||
112 | | |
113 | | |
114 | | |
width: 200px; | ||
} | ||
... | ... | |
#asset_list li a:visited img { | ||
display: block; | ||
margin-bottom: 5px; | ||
124 | | |
125 | | |
69 | border: 1px solid black; | |
} | ||
#project_list li a:hover img, | ||
#asset_list li a:hover img { | ||
130 | | |
131 | | |
74 | border: 1px solid #E5FFD4; | |
} | ||
#project_list li small, | ||
... | ... | |
******************************/ | ||
.toolbar { | ||
144 | | |
145 | | |
146 | | |
147 | | |
148 | | |
87 | background-color: #ada; | |
88 | padding-left: 10px; | |
89 | text-align: right; | |
} | ||
.toolbar span { | ||
... | ... | |
.inplaceeditor-form a { | ||
font-size: 0.8em; | ||
} | ||
183 | ||
184 |