Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 71
- Log:
Start of upgrade to Typo 4.0.0, the latest stable release since
2.6.0. Note test/mocks/themes/azure changes from a file to a
directory, so the file has been removed in this revision and
the directory will be added in the next revision.
- Author:
- adh
- Date:
- Mon Aug 07 22:18:11 +0100 2006
- Size:
- 5244 Bytes
1 | # BlogRequest is a fake Request object, created so blog.url_for will work. |
2 | # This isn't enabled yet, but it will be soon... |
3 | class BlogRequest |
4 | include Reloadable |
5 | |
6 | attr_accessor :protocol, :host_with_port, :path, :symbolized_path_parameters, :relative_url_root |
7 | |
8 | def initialize(root) |
9 | @protocol = @host_with_port = @path = '' |
10 | @symbolized_path_parameters = {} |
11 | @relative_url_root = root.gsub(%r{/^},'') |
12 | end |
13 | end |
14 | |
15 | class Blog < ActiveRecord::Base |
16 | include ConfigManager |
17 | |
18 | has_many :contents |
19 | has_many :trackbacks |
20 | has_many :articles |
21 | has_many :comments |
22 | has_many :pages, :order => "id DESC" |
23 | has_many(:published_articles, :class_name => "Article", |
24 | :conditions => ["published = ?", true], |
25 | :include => [:categories, :tags], |
26 | :order => "contents.created_at DESC") do |
27 | def before(date = Time.now) |
28 | find(:all, :conditions => ["contents.created_at < ?", date]) |
29 | end |
30 | end |
31 | |
32 | has_many :pages |
33 | has_many :comments |
34 | |
35 | serialize :settings, Hash |
36 | |
37 | # Description |
38 | setting :blog_name, :string, 'My Shiny Weblog!' |
39 | setting :blog_subtitle, :string, '' |
40 | setting :geourl_location, :string, '' |
41 | setting :canonical_server_url, :string, '' |
42 | |
43 | # Spam |
44 | setting :sp_global, :boolean, false |
45 | setting :sp_article_auto_close, :integer, 0 |
46 | setting :sp_allow_non_ajax_comments, :boolean, true |
47 | setting :sp_url_limit, :integer, 0 |
48 | setting :sp_akismet_key, :string, '' |
49 | |
50 | # Podcasting |
51 | setting :itunes_explicit, :boolean, false |
52 | setting :itunes_author, :string, '' |
53 | setting :itunes_subtitle, :string, '' |
54 | setting :itunes_summary, :string, '' |
55 | setting :itunes_owner, :string, '' |
56 | setting :itunes_email, :string, '' |
57 | setting :itunes_name, :string, '' |
58 | setting :itunes_copyright, :string, '' |
59 | |
60 | # Mostly Behaviour |
61 | setting :text_filter, :string, '' |
62 | setting :comment_text_filter, :string, '' |
63 | setting :limit_article_display, :integer, 10 |
64 | setting :limit_rss_display, :integer, 10 |
65 | setting :default_allow_pings, :boolean, false |
66 | setting :default_allow_comments, :boolean, true |
67 | setting :link_to_author, :boolean, false |
68 | setting :show_extended_on_rss, :boolean, true |
69 | setting :theme, :string, 'azure' |
70 | setting :use_gravatar, :boolean, false |
71 | setting :global_pings_disable, :boolean, false |
72 | setting :ping_urls, :string, "http://rpc.technorati.com/rpc/ping\nhttp://ping.blo.gs/\nhttp://rpc.weblogs.com/RPC2" |
73 | setting :send_outbound_pings, :boolean, true |
74 | setting :email_from, :string, 'typo@example.com' |
75 | |
76 | # Jabber config |
77 | setting :jabber_address, :string, '' |
78 | setting :jabber_password, :string, '' |
79 | |
80 | def find_already_published(content_type) |
81 | self.send(content_type).find_already_published |
82 | end |
83 | |
84 | def ping_article!(settings) |
85 | settings[:blog_id] = self.id |
86 | article_id = settings[:id] |
87 | settings.delete(:id) |
88 | trackback = published_articles.find(article_id).trackbacks.create!(settings) |
89 | |
90 | if trackback.is_spam? |
91 | STDERR.puts "Moderating trackback as spam!" |
92 | trackback.withdraw! |
93 | end |
94 | |
95 | trackback |
96 | end |
97 | |
98 | |
99 | def is_ok? |
100 | settings.has_key?('blog_name') |
101 | end |
102 | |
103 | def [](key) |
104 | self.send(key) |
105 | end |
106 | |
107 | def []=(key, value) |
108 | self.send("#{key}=", value) |
109 | end |
110 | |
111 | def has_key?(key) |
112 | self.class.fields.has_key?(key.to_s) |
113 | end |
114 | |
115 | def initialize(*args) |
116 | super |
117 | self.settings ||= { } |
118 | end |
119 | |
120 | def self.default |
121 | find(:first, :order => 'id') |
122 | end |
123 | |
124 | @@controller_stack = [] |
125 | cattr_accessor :controller_stack |
126 | |
127 | def self.before(controller) |
128 | controller_stack << controller |
129 | end |
130 | |
131 | def self.after(controller) |
132 | unless controller_stack.last == controller |
133 | raise "Controller stack got out of kilter!" |
134 | end |
135 | controller_stack.pop |
136 | end |
137 | |
138 | def controller |
139 | controller_stack.last |
140 | end |
141 | |
142 | def current_theme_path |
143 | Theme.themes_root + "/" + theme |
144 | end |
145 | |
146 | def current_theme |
147 | Theme.theme_from_path(current_theme_path) |
148 | end |
149 | |
150 | def url_for(options = {}, *extra_params) |
151 | case options |
152 | when String then options |
153 | when Hash |
154 | options.reverse_merge!(:only_path => true, :controller => '/articles', |
155 | :action => 'permalink') |
156 | url = ActionController::UrlRewriter.new(request, {}) |
157 | url.rewrite(options) |
158 | else |
159 | options.location(*extra_params) |
160 | end |
161 | end |
162 | |
163 | def article_url(article, only_path = true, anchor = nil) |
164 | url_for(:year => article.published_at.year, |
165 | :month => sprintf("%.2d", article.published_at.month), |
166 | :day => sprintf("%.2d", article.published_at.day), |
167 | :title => article.permalink, :anchor => anchor, |
168 | :only_path => only_path) |
169 | end |
170 | |
171 | def server_url |
172 | if controller |
173 | controller.send :url_for, :only_path => false, :controller => "/" |
174 | else |
175 | settings[:canonical_server_url] |
176 | end |
177 | end |
178 | |
179 | private |
180 | |
181 | def request |
182 | #BlogRequest.new(self.canonical_server_url) |
183 | controller.request rescue ActionController::TestRequest.new |
184 | end |
185 | end |
186 |