Changesets can be listed by changeset number.
The Git repository is here.
Changeset 6
Configured for temporary /rails/instiki location on Alpha.
Added auto_export field in database with support in snippets and
relevant changes to views - allows snippets to be sent out to the
filesystem when created or modified (incomplete). Added
filter_help_links for filter help implementation that requires an
additional 'help' method in filters (optional), with relevant
view changes. Might change to a behavior-style description method
in future. Added ERB Filter and Behavior.
- Comitted by: adh
- Date: Saturday July 22 18:38:46 2006 (over 18 years ago)
Affected files:
- rool/rails/radiant/trunk/app/behaviors/erb_behavior.rb
- rool/rails/radiant/trunk/app/filters/erb_filter.rb
- rool/rails/radiant/trunk/config/database.yml
- rool/rails/radiant/trunk/test/unit/behaviors/erb_behavior_test.rb
- rool/rails/radiant/trunk/test/unit/filters/erb_filter_test.rb
- rool/rails/radiant/trunk/CHANGELOG (diff)
- rool/rails/radiant/trunk/app/controllers/admin/snippet_controller.rb (diff)
- rool/rails/radiant/trunk/app/filters/markdown_filter.rb (diff)
- rool/rails/radiant/trunk/app/filters/textile_filter.rb (diff)
- rool/rails/radiant/trunk/app/helpers/application_helper.rb (diff)
- rool/rails/radiant/trunk/app/models/snippet.rb (diff)
- rool/rails/radiant/trunk/app/models/text_filter.rb (diff)
- rool/rails/radiant/trunk/app/views/admin/page/_part.rhtml (diff)
- rool/rails/radiant/trunk/app/views/admin/snippet/new.rhtml (diff)
- rool/rails/radiant/trunk/config/environment.rb (diff)
- rool/rails/radiant/trunk/config/routes.rb (diff)
- rool/rails/radiant/trunk/db/migrate/001_create_radiant_tables.rb (diff)
- rool/rails/radiant/trunk/db/migrate/002_insert_initial_data.rb (diff)
- rool/rails/radiant/trunk/db/schema.rb (diff)
- rool/rails/radiant/trunk/lib/generators/filter/templates/model.rb.template (diff)
- rool/rails/radiant/trunk/public/dispatch.cgi (diff)
- rool/rails/radiant/trunk/public/dispatch.fcgi (diff)
- rool/rails/radiant/trunk/public/dispatch.rb (diff)
rool/rails/radiant/trunk/CHANGELOG:
prev. | current | |
= Change Log -* Migrations are now repaired so that you can run `rake migrate` to create the initial database. (`script/setup_database` is still the recommended method.) (closes ticket #46) [Daniel Shepherd] -* When you collapse a branch in the admin page tree view and move to another tab the collapsed status is now saved so that when you return, the collapsed status is preserved. Also the status of collapsed branches is preserved when collapsing and expanding parent nodes. (closes ticket #29) [Daniel Shepherd] - === 0.5.0 Grindstone (June 28, 2006) * First release. |
rool/rails/radiant/trunk/app/controllers/admin/snippet_controller.rb:
prev. | current | |
class Admin::SnippetController < Admin::AbstractModelController | ||
model :snippet | ||
6 | ||
7 | def save | |
8 | if (@snippet && @snippet.auto_export && @snippet.auto_export != '') | |
9 | f = File.new(@snippet.auto_export, "wb") | |
10 | raise "Error writing snippet to '#{@snippet.auto_export}'" if (f.write(@snippet.content) != @snippet.content.length) | |
11 | end | |
12 | super | |
13 | end | |
end | ||
rool/rails/radiant/trunk/app/filters/markdown_filter.rb:
prev. | current | |
def filter(text) | ||
BlueCloth.new(text).to_html | ||
end | ||
9 | ||
10 | def self.help | |
11 | '<a href="http://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown</a>' | |
12 | end | |
end | ||
rool/rails/radiant/trunk/app/filters/textile_filter.rb:
prev. | current | |
def filter(text) | ||
RedCloth.new(text).to_html | ||
end | ||
9 | ||
10 | def self.help | |
11 | '<a href="http://hobix.com/textile/quick.html" target="_blank">Textile</a>' | |
12 | end | |
end | ||
rool/rails/radiant/trunk/app/helpers/application_helper.rb:
prev. | current | |
def config | ||
Radiant::Config | ||
end | ||
7 | | |
7 | ||
def default_page_title | ||
title + ' - ' + subtitle | ||
end | ||
11 | | |
11 | ||
def title | ||
config['admin.title'] || 'Radiant CMS' | ||
end | ||
15 | | |
15 | ||
def subtitle | ||
config['admin.subtitle'] || 'Publishing for Small Teams' | ||
end | ||
19 | | |
19 | ||
def logged_in? | ||
session[:user] ? true : false | ||
end | ||
... | ... | |
end | ||
submit_tag label, :class => 'button' | ||
end | ||
32 | | |
32 | ||
def save_model_and_continue_editing_button(model) | ||
submit_tag 'Save and Continue Editing', :name => 'continue', :class => 'button' | ||
end | ||
... | ... | |
singular + "s" | ||
end | ||
end | ||
50 | | |
50 | ||
def links_for_navigation | ||
tabs = [] | ||
tabs << nav_link_to('Pages', page_index_url) | ||
tabs << nav_link_to('Snippets', snippet_index_url) | ||
55 | | |
55 | tabs << nav_link_to('Layouts', layout_index_url) if developer? | |
tabs.join(separator) | ||
end | ||
58 | | |
58 | ||
def separator | ||
%{ <span class="separator"> | </span> } | ||
end | ||
62 | | |
62 | ||
def current_url?(options) | ||
url = case | ||
when Hash | ||
... | ... | |
end | ||
request.request_uri =~ Regexp.new('^' + Regexp.quote(clean(url))) | ||
end | ||
72 | | |
72 | ||
def clean(url) | ||
uri = URI.parse(url) | ||
uri.path.gsub(%r{/+}, '/').gsub(%r{/$}, '') | ||
end | ||
77 | | |
77 | ||
def nav_link_to(name, options) | ||
logger.debug 'options are: ' + options.to_s | ||
if current_url?(options) | ||
... | ... | |
link_to name, options | ||
end | ||
end | ||
86 | | |
86 | ||
def admin? | ||
user = session[:user] | ||
user and user.admin? | ||
end | ||
91 | | |
91 | ||
def developer? | ||
user = session[:user] | ||
user and (user.developer? or user.admin?) | ||
end | ||
96 | | |
96 | ||
def focus(field_name) | ||
%{ | ||
<script type="text/javascript"> | ||
... | ... | |
</script> | ||
} | ||
end | ||
106 | | |
106 | ||
def updated_stamp(model) | ||
unless model.new_record? | ||
updated_by = (model.updated_by || model.created_by) | ||
login = updated_by ? updated_by.login : nil | ||
time = (model.updated_at || model.created_at) | ||
if login or time | ||
113 | | |
113 | html = %{<p style="clear: left"><small>Last updated } | |
html << %{by #{login} } if login | ||
html << %{at #{ time.strftime("%I:%M <small>%p</small> on %B %d, %Y") }} if time | ||
html << %{</small></p>} | ||
... | ... | |
%{<p class="clear"> </p>} | ||
end | ||
end | ||
123 | | |
123 | ||
def meta_visible(symbol) | ||
v = case symbol | ||
when :meta_more | ||
... | ... | |
end | ||
' style="display: none"' unless v | ||
end | ||
133 | | |
133 | ||
def meta_errors? | ||
false | ||
end | ||
137 | | |
137 | ||
def toggle_javascript_for(id) | ||
"javascript:Element.toggle('#{id}', 'more-#{id}', 'less-#{id}')" | ||
end | ||
141 | ||
142 | def filter_help_links | |
143 | # Find all filters creating an array; run 'help' on each item to | |
144 | # create a new array; join the array items to form a string. Allow | |
145 | # filters that don't have help and cope with the case where no | |
146 | # registered filters provide it. | |
147 | ||
148 | @links = TextFilter.find_all.map { |filter| | |
149 | filter.respond_to?(:help) ? filter.help : nil | |
150 | }.compact.join(', ') | |
151 | ||
152 | @links != '' ? @links : 'No help available' | |
153 | end | |
end |
rool/rails/radiant/trunk/app/models/snippet.rb:
prev. | current | |
validates_presence_of :name, :message => 'required' | ||
validates_length_of :name, :maximum => 100, :message => '%d-character limit' | ||
validates_length_of :filter_id, :maximum => 25, :allow_nil => true, :message => '%d-character limit' | ||
11 | validates_length_of :auto_export, :maximum => 512, :allow_nil => true, :message => '%d-character limit' | |
validates_format_of :name, :with => %r{^\S*$}, :message => 'cannot contain spaces or tabs' | ||
validates_uniqueness_of :name, :message => 'name already in use' | ||
13 | | |
14 | ||
registered_attr :filter, TextFilter | ||
end |
rool/rails/radiant/trunk/app/models/text_filter.rb:
prev. | current | |
module TextFilter | ||
include Registerable | ||
5 | | |
5 | ||
class Base | ||
def filter(text) | ||
text | ||
end | ||
10 | ||
11 | def help | |
12 | self.name + ': No help available' | |
13 | end | |
end | ||
end | ||
rool/rails/radiant/trunk/app/views/admin/page/_part.rhtml:
prev. | current | |
<p> | ||
<label for="part[<%= @index - 1 %>}][filter_id]">Filter</label> | ||
<%= select_tag "part[#{@index - 1}][filter_id]", options_for_select([['<none>', '']] + TextFilter.find_all.map { |s| s.registered_id }, @part.filter_id) %> | ||
11 | ||
12 | - Filter help: <%= filter_help_links %> | |
</p> | ||
<div><%= text_area_tag "part[#{@index - 1}][content]", h(@part.content), :class => "textarea", :style => "width: 100%" %></div> | ||
</div> |
rool/rails/radiant/trunk/app/views/admin/snippet/new.rhtml:
prev. | current | |
<label for="snippet_name">Name</label> | ||
<%= text_field "snippet", "name", :class => 'textbox', :maxlength => 100 %> | ||
</p> | ||
13 | ||
13 | <div id="extended-metadata" class="row"<%= meta_visible(:meta) %>> | |
14 | <table class="fieldset" cellpadding="0" cellspacing="0" border="0"> | |
15 | <tr> | |
16 | <td><label for="snippet_auto_export">Export to file when altered</label></td> | |
17 | <td class="field"><%= text_field "snippet", "auto_export", :class => 'textbox', :maxlength => 512 %></td> | |
18 | </tr> | |
19 | </table> | |
20 | </div> | |
21 | <p> | |
22 | <small> | |
23 | <a id="more-extended-metadata" href="<%= toggle_javascript_for('extended-metadata') %>"<%= meta_visible(:meta_more) %>>More</a> | |
24 | <a id="less-extended-metadata" href="<%= toggle_javascript_for('extended-metadata') %>"<%= meta_visible(:meta_less) %>>Less</a> | |
25 | </small> | |
26 | </p> | |
<p class="content"> | ||
<label for="snippet_content">Body</label> | ||
<%= text_area "snippet", "content", :class => "textarea", :style => "width: 100%" %></p> | ||
<p> | ||
<label for="snippet_filter">Filter</label> | ||
<%= select_tag "snippet[filter_id]", options_for_select([['none', '']] + TextFilter.find_all.map { |f| f.registered_id }, @snippet.filter_id) %> | ||
33 | ||
34 | - Filter help: <%= filter_help_links %> | |
</p> | ||
<%= updated_stamp @snippet %> | ||
</div> |
rool/rails/radiant/trunk/config/environment.rb:
prev. | current | |
# Rails Gem Version | ||
RAILS_GEM_VERSION = '1.1.2' | ||
6 | ||
6 | # Uncomment below to force Rails into production mode when | |
# you don't control web/app server and can't set it the proper way | ||
# ENV['RAILS_ENV'] ||= 'production' | ||
... | ... | |
require 'radius' | ||
Rails::Initializer.run do |config| | ||
16 | # We don't run in the document root, so images etc. must come from | |
17 | # a non-root location too. Hijack the 'asset host' facility to get | |
18 | # helper-based links pointing in the right place. | |
19 | config.action_controller.asset_host = "/rails/radiant" | |
20 | ||
# Settings in config/environments/* take precedence those specified here | ||
17 | | |
22 | ||
# Skip frameworks you're not going to use | ||
config.frameworks -= [ :action_web_service, :action_mailer ] | ||
... | ... | |
).map { |path| File.join(RADIANT_ROOT, path) } | ||
config.controller_paths << File.join(RADIANT_ROOT, 'app', 'controllers') | ||
config.view_path = File.join(RADIANT_ROOT, 'app', 'views') | ||
32 | | |
33 | | |
37 | ||
38 | # Force all environments to use the same logger level | |
# (by default production uses :info, the others :debug) | ||
35 | | |
40 | config.log_level = :warn | |
# Use the database for sessions instead of the file system | ||
# (create the session table with 'rake create_sessions_table') | ||
... | ... | |
# Make Active Record use UTC-base instead of local time | ||
config.active_record.default_timezone = :utc | ||
48 | | |
53 | ||
# Make sure plugins are loaded from lib and vendor | ||
config.plugin_paths = ["#{RAILS_ROOT}/vendor/plugins", "#{RADIANT_ROOT}/lib/plugins", | ||
"#{RADIANT_ROOT}/vendor/plugins"] | ||
... | ... | |
# See Rails::Configuration for more options | ||
end | ||
61 | # Allow multiple Rails applications by giving the session cookie a | |
62 | # unique prefix. | |
63 | ||
64 | ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = 'radiantapp_session_id' | |
65 | ||
# Add new inflection rules using the following format: | ||
Inflector.inflections do |inflect| | ||
inflect.uncountable 'config' |
rool/rails/radiant/trunk/config/routes.rb:
prev. | current | |
# Admin Routes | ||
map.with_options(:controller => 'admin/welcome') do |welcome| | ||
5 | | |
6 | | |
7 | | |
8 | | |
5 | welcome.admin '/rails/radiant/admin', :action => 'index' | |
6 | welcome.welcome '/rails/radiant/admin/welcome', :action => 'index' | |
7 | welcome.login '/rails/radiant/admin/login', :action => 'login' | |
8 | welcome.logout '/rails/radiant/admin/logout', :action => 'logout' | |
end | ||
10 | | |
10 | ||
# Export Routes | ||
map.with_options(:controller => 'admin/export') do |export| | ||
13 | | |
14 | | |
13 | export.export '/rails/radiant/admin/export', :action => 'yaml' | |
14 | export.export_yaml '/rails/radiant/admin/export/yaml', :action => 'yaml' | |
end | ||
# Page Routes | ||
map.with_options(:controller => 'admin/page') do |page| | ||
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
19 | page.page_index '/rails/radiant/admin/pages', :action => 'index' | |
20 | page.page_edit '/rails/radiant/admin/pages/edit/:id', :action => 'edit' | |
21 | page.page_new '/rails/radiant/admin/pages/:parent_id/child/new', :action => 'new' | |
22 | page.homepage_new '/rails/radiant/admin/pages/new/homepage', :action => 'new', :slug => '/', :breadcrumb => 'Home' | |
23 | page.page_remove '/rails/radiant/admin/pages/remove/:id', :action => 'remove' | |
24 | page.page_add_part '/rails/radiant/admin/ui/pages/part/add', :action => 'add_part' | |
25 | page.page_children '/rails/radiant/admin/ui/pages/children/:id/:level', :action => 'children', :level => '1' | |
26 | page.clear_cache '/rails/radiant/admin/pages/cache/clear', :action => 'clear_cache' | |
end | ||
# Layouts Routes | ||
map.with_options(:controller => 'admin/layout') do |layout| | ||
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
31 | layout.layout_index '/rails/radiant/admin/layouts', :action => 'index' | |
32 | layout.layout_edit '/rails/radiant/admin/layouts/edit/:id', :action => 'edit' | |
33 | layout.layout_new '/rails/radiant/admin/layouts/new', :action => 'new' | |
34 | layout.layout_remove '/rails/radiant/admin/layouts/remove/:id', :action => 'remove' | |
35 | end | |
36 | ||
# Snippets Routes | ||
map.with_options(:controller => 'admin/snippet') do |snippet| | ||
39 | | |
40 | | |
41 | | |
42 | | |
39 | snippet.snippet_index '/rails/radiant/admin/snippets', :action => 'index' | |
40 | snippet.snippet_edit '/rails/radiant/admin/snippets/edit/:id', :action => 'edit' | |
41 | snippet.snippet_new '/rails/radiant/admin/snippets/new', :action => 'new' | |
42 | snippet.snippet_remove '/rails/radiant/admin/snippets/remove/:id', :action => 'remove' | |
end | ||
44 | | |
44 | ||
# Users Routes | ||
map.with_options(:controller => 'admin/user') do |user| | ||
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
47 | user.user_index '/rails/radiant/admin/users', :action => 'index' | |
48 | user.user_edit '/rails/radiant/admin/users/edit/:id', :action => 'edit' | |
49 | user.user_new '/rails/radiant/admin/users/new', :action => 'new' | |
50 | user.user_remove '/rails/radiant/admin/users/remove/:id', :action => 'remove' | |
51 | user.user_preferences '/rails/radiant/admin/preferences', :action => 'preferences' | |
end | ||
53 | | |
53 | ||
# Site URLs | ||
map.with_options(:controller => 'site') do |site| | ||
56 | | |
57 | | |
58 | | |
56 | site.homepage '/rails/radiant/', :action => 'show_page', :url => '/' | |
57 | site.not_found '/rails/radiant/error/404', :action => 'not_found' | |
58 | site.error '/rails/radiant/error/500', :action => 'error' | |
# Everything else | ||
61 | | |
61 | site.connect '/rails/radiant/*url', :action => 'show_page' | |
end | ||
63 | | |
63 | ||
end | ||
rool/rails/radiant/trunk/db/migrate/001_create_radiant_tables.rb:
prev. | current | |
t.column "key", :string, :limit => 40, :default => "", :null => false | ||
t.column "value", :string, :default => "" | ||
end | ||
7 | | |
create_table "pages" do |t| | ||
t.column "title", :string | ||
... | ... | |
drop_table "snippets" | ||
drop_table "layouts" | ||
drop_table "users" | ||
73 | | |
end | ||
end |
rool/rails/radiant/trunk/db/migrate/002_insert_initial_data.rb:
prev. | current | |
class InsertInitialData < ActiveRecord::Migration | ||
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
def self.up | ||
now = Time.now | ||
puts "Creating the user 'admin' with the password 'radiant'..." | ||
15 | | |
16 | | |
17 | | |
6 | admin = User.create :name => 'Administrator', :login => 'admin', :password => 'radiant', :password_confirmation => 'radiant', :admin => true, :created_at => now, :updated_at => now | |
7 | admin.created_by = admin | |
8 | admin.updated_by = admin | |
9 | admin.save | |
10 | ||
puts "Initializing configuration..." | ||
Radiant::Config['admin.title' ] = 'Radiant CMS' | ||
Radiant::Config['admin.subtitle'] = 'Publishing for Small Teams' |
rool/rails/radiant/trunk/db/schema.rb:
prev. | current | |
create_table "layouts", :force => true do |t| | ||
t.column "name", :string, :limit => 100 | ||
t.column "content", :text | ||
17 | t.column "content_type", :string, :limit => 40 | |
t.column "created_at", :datetime | ||
t.column "updated_at", :datetime | ||
t.column "created_by", :integer | ||
t.column "updated_by", :integer | ||
21 | | |
end | ||
create_table "page_parts", :force => true do |t| | ||
... | ... | |
t.column "title", :string | ||
t.column "slug", :string, :limit => 100 | ||
t.column "breadcrumb", :string, :limit => 160 | ||
35 | t.column "parent_id", :integer | |
36 | t.column "layout_id", :integer | |
t.column "behavior_id", :string, :limit => 25 | ||
t.column "status_id", :integer, :default => 1, :null => false | ||
37 | | |
38 | | |
t.column "created_at", :datetime | ||
t.column "updated_at", :datetime | ||
t.column "published_at", :datetime |
rool/rails/radiant/trunk/lib/generators/filter/templates/model.rb.template:
prev. | current | |
# filter text here | ||
text | ||
end | ||
8 | ||
9 | def self.help | |
10 | # insert appropriate link below | |
11 | '<a href="" target="_blank"><%= filter_name %></a>' | |
12 | end | |
end |
rool/rails/radiant/trunk/public/dispatch.cgi:
prev. | current | |
1 | ||
1 | #!/bin/ruby | |
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) | ||
rool/rails/radiant/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/radiant/trunk/public/dispatch.rb:
prev. | current | |
1 | ||
1 | #!/bin/ruby | |
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) | ||