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:
- 2060 Bytes
1 | class Tag < ActiveRecord::Base |
2 | has_and_belongs_to_many :articles, :order => 'created_at DESC' |
3 | validates_uniqueness_of :name |
4 | |
5 | def self.get(name) |
6 | tagname = name.tr(' ', '').downcase |
7 | tag = find_by_name_or_display_name(tagname, name) |
8 | if tag.nil? |
9 | tag = Tag.create(:name => tagname, :display_name => name) |
10 | end |
11 | |
12 | tag |
13 | end |
14 | |
15 | def self.find_by_name_or_display_name(tagname, name) |
16 | self.find(:first, :conditions => [%{name = ? OR display_name = ? OR display_name = ?}, tagname, tagname, name]) |
17 | end |
18 | |
19 | def self.find_by_name(name, *args) |
20 | self.send(:method_missing, :find_by_name, name, *args) || |
21 | self.new(:name => name) |
22 | end |
23 | |
24 | def ensure_naming_conventions |
25 | if self.display_name.blank? |
26 | self.display_name = self.name |
27 | end |
28 | self.name = self.name.tr(' ', '').downcase |
29 | end |
30 | |
31 | before_save :ensure_naming_conventions |
32 | |
33 | def self.find_all_with_article_counters(limit = 20) |
34 | # Only count published articles |
35 | self.find_by_sql([%{ |
36 | SELECT tags.id, tags.name, tags.display_name, COUNT(articles_tags.article_id) AS article_counter |
37 | FROM #{Tag.table_name} tags LEFT OUTER JOIN #{Tag.table_name_prefix}articles_tags#{Tag.table_name_suffix} articles_tags |
38 | ON articles_tags.tag_id = tags.id |
39 | LEFT OUTER JOIN #{Tag.table_name_prefix + Article.table_name + Tag.table_name_prefix} articles |
40 | ON articles_tags.article_id = articles.id |
41 | WHERE articles.published = ? |
42 | GROUP BY tags.id, tags.name, tags.display_name |
43 | ORDER BY article_counter DESC |
44 | LIMIT ? |
45 | },true, limit]).each{|item| item.article_counter = item.article_counter.to_i } |
46 | end |
47 | |
48 | def self.find_by_permalink(*args) |
49 | self.find_by_name(*args) |
50 | end |
51 | |
52 | def self.to_prefix |
53 | 'tag' |
54 | end |
55 | |
56 | def published_articles |
57 | articles.find_already_published |
58 | end |
59 | |
60 | def permalink |
61 | self.name |
62 | end |
63 | |
64 | def permalink_url(anchor=nil, only_path=true) |
65 | blog = Blog.find(1) # remove me... |
66 | |
67 | blog.url_for( |
68 | :controller => '/articles', |
69 | :action => 'tag', |
70 | :id => permalink |
71 | ) |
72 | end |
73 | |
74 | end |