Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 2801 Bytes
1 | # The filters added to this controller will be run for all controllers in the application. |
2 | # Likewise will all the methods added be available for all controllers. |
3 | class ContentController < ApplicationController |
4 | class ExpiryFilter |
5 | def before(controller) |
6 | @request_time = Time.now |
7 | end |
8 | |
9 | def after(controller) |
10 | future_article = |
11 | Article.find(:first, |
12 | :conditions => ['published = ? AND published_at > ?', true, @request_time], |
13 | :order => "published_at ASC" ) |
14 | if future_article |
15 | delta = future_article.published_at - Time.now |
16 | controller.response.lifetime = (delta <= 0) ? 0 : delta |
17 | end |
18 | end |
19 | end |
20 | |
21 | include LoginSystem |
22 | # model :user |
23 | helper :theme |
24 | before_filter :auto_discovery_defaults |
25 | |
26 | def self.caches_action_with_params(*actions) |
27 | super |
28 | around_filter ExpiryFilter.new, :only => actions |
29 | end |
30 | |
31 | def self.cache_page(content, path) |
32 | begin |
33 | # Don't cache the page if there are any questionmark characters in the url |
34 | unless path =~ /\?\w+/ or path =~ /page\d+$/ |
35 | super(content,path) |
36 | PageCache.create(:name => page_cache_file(path)) |
37 | end |
38 | rescue # if there's a caching error, then just return the content. |
39 | content |
40 | end |
41 | end |
42 | |
43 | def self.expire_page(path) |
44 | if cache = PageCache.find(:first, :conditions => ['name = ?', path]) |
45 | cache.destroy |
46 | end |
47 | end |
48 | |
49 | def auto_discovery_defaults |
50 | @auto_discovery_url_rss = |
51 | request.instance_variable_get(:@auto_discovery_url_rss) |
52 | @auto_discovery_url_atom = |
53 | request.instance_variable_get(:@auto_discovery_url_atom) |
54 | unless @auto_discovery_url_rss && @auto_discovery_url_atom |
55 | auto_discovery_feed(:type => 'feed') |
56 | request.instance_variable_set(:@auto_discovery_url_rss, |
57 | @auto_discovery_url_rss) |
58 | request.instance_variable_set(:@auto_discovery_url_atom, |
59 | @auto_discovery_url_atom) |
60 | end |
61 | end |
62 | |
63 | def auto_discovery_feed(options) |
64 | options = {:only_path => false, :action => 'feed', :controller => 'xml'}.merge options |
65 | # Special cased ugliness. Get rid of it when there's a user feed. |
66 | if options[:type] == 'user' |
67 | options[:type] = 'feed' |
68 | options[:id] = nil |
69 | end |
70 | |
71 | @auto_discovery_url_rss = url_for(({:format => 'rss20'}.merge options)) |
72 | @auto_discovery_url_atom = url_for(({:format => 'atom'}.merge options)) |
73 | end |
74 | |
75 | def theme_layout |
76 | this_blog.current_theme.layout |
77 | end |
78 | |
79 | helper_method :contents |
80 | def contents |
81 | if @articles |
82 | @articles |
83 | elsif @article |
84 | [@article] |
85 | elsif @page |
86 | [@page] |
87 | else |
88 | [] |
89 | end |
90 | end |
91 | |
92 | protected |
93 | |
94 | include_protected ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper |
95 | |
96 | end |