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:
- 2009 Bytes
1 | class Category < ActiveRecord::Base |
2 | acts_as_list |
3 | has_many :categorizations |
4 | has_many :articles, :through => :categorizations, |
5 | :order => "published_at DESC, created_at DESC" |
6 | |
7 | def self.find_all_with_article_counters(maxcount=nil) |
8 | self.find_by_sql([%{ |
9 | SELECT categories.id, categories.name, categories.permalink, categories.position, COUNT(articles.id) AS article_counter |
10 | FROM #{Category.table_name} categories |
11 | LEFT OUTER JOIN #{Category.table_name_prefix}categorizations#{Category.table_name_suffix} articles_categories |
12 | ON articles_categories.category_id = categories.id |
13 | LEFT OUTER JOIN #{Article.table_name} articles |
14 | ON (articles_categories.article_id = articles.id AND articles.published = ?) |
15 | GROUP BY categories.id, categories.name, categories.position, categories.permalink |
16 | ORDER BY position |
17 | }, true]).each {|item| item.article_counter = item.article_counter.to_i } |
18 | end |
19 | |
20 | def self.find(*args) |
21 | with_scope :find => {:order => 'position ASC'} do |
22 | super |
23 | end |
24 | end |
25 | |
26 | def self.find_by_permalink(*args) |
27 | super || new |
28 | end |
29 | |
30 | def self.to_prefix |
31 | 'category' |
32 | end |
33 | |
34 | def stripped_name |
35 | self.name.to_url |
36 | end |
37 | |
38 | def self.reorder(serialized_list) |
39 | self.transaction do |
40 | serialized_list.each_with_index do |cid,index| |
41 | find(cid).update_attribute "position", index |
42 | end |
43 | end |
44 | end |
45 | |
46 | def self.reorder_alpha |
47 | reorder find(:all, :order => 'UPPER(name)').collect { |c| c.id } |
48 | end |
49 | |
50 | def published_articles |
51 | self.articles.find_already_published |
52 | end |
53 | |
54 | def display_name |
55 | name |
56 | end |
57 | |
58 | def permalink_url(anchor=nil, only_path=true) |
59 | blog = Blog.find(1) # remove me... |
60 | |
61 | blog.url_for( |
62 | :controller => '/articles', |
63 | :action => 'category', |
64 | :id => permalink |
65 | ) |
66 | end |
67 | |
68 | protected |
69 | |
70 | before_save :set_defaults |
71 | |
72 | def set_defaults |
73 | self.permalink ||= self.stripped_name |
74 | end |
75 | |
76 | validates_presence_of :name |
77 | validates_uniqueness_of :name, :on => :create |
78 | end |
79 |