Class: Thoth::MainController
- Inherits:
-
Controller
- Object
- Ramaze::Controller
- Controller
- Thoth::MainController
- Defined in:
- lib/thoth/controller/main.rb
Instance Method Summary collapse
-
#archives(page = 1) ⇒ Object
Legacy redirect to /archive/
page
. -
#article(name) ⇒ Object
Legacy redirect to /post/
name
. - #atom ⇒ Object
-
#comments ⇒ Object
(also: #recent-comments)
Legacy redirect to /comment.
- #index ⇒ Object
- #rss ⇒ Object
- #sitemap ⇒ Object
Methods inherited from Controller
Instance Method Details
#archives(page = 1) ⇒ Object
Legacy redirect to /archive/page
.
173 174 175 |
# File 'lib/thoth/controller/main.rb', line 173 def archives(page = 1) redirect ArchiveController.r(:/, page), :status => 301 end |
#article(name) ⇒ Object
Legacy redirect to /post/name
.
178 179 180 |
# File 'lib/thoth/controller/main.rb', line 178 def article(name) redirect PostController.r(:/, name), :status => 301 end |
#atom ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/thoth/controller/main.rb', line 55 def atom response['Content-Type'] = 'application/atom+xml' x = Builder::XmlMarkup.new(:indent => 2) x.instruct! x.feed(:xmlns => 'http://www.w3.org/2005/Atom') { x.id Config.site['url'] x.title Config.site['name'] x.subtitle Config.site['desc'] x.updated Time.now.xmlschema # TODO: use modification time of the last post x.link :href => Config.site['url'] x.link :href => Config.site['url'].chomp('/') + rs(:atom).to_s, :rel => 'self' x. { x.name Config.admin['name'] x.email Config.admin['email'] x.uri Config.site['url'] } Post.recent.all.each do |post| x.entry { x.id post.url x.title post.title x.published post.created_at.xmlschema x.updated post.updated_at.xmlschema x.link :href => post.url, :rel => 'alternate' x.content post.body_rendered, :type => 'html' post..each do |tag| x.category :term => tag.name, :label => tag.name, :scheme => tag.url end } end } throw(:respond, x.target!) end |
#comments ⇒ Object Also known as: recent-comments
Legacy redirect to /comment.
183 184 185 186 187 188 189 |
# File 'lib/thoth/controller/main.rb', line 183 def comments if type = request[:type] redirect CommentController.r(:/, type), :status => 301 else redirect CommentController.r(), :status => 301 end end |
#index ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/thoth/controller/main.rb', line 44 def index # Check for legacy feed requests and redirect if necessary. if type = request[:type] redirect rs(type), :status => 301 end @title = Config.site['name'] @posts = Post.recent @pager = pager(@posts, rs(:archive, '__page__')) end |
#rss ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/thoth/controller/main.rb', line 96 def rss response['Content-Type'] = 'application/rss+xml' x = Builder::XmlMarkup.new(:indent => 2) x.instruct! x.rss(:version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom') { x.channel { x.title Config.site['name'] x.link Config.site['url'] x.description Config.site['desc'] x.managingEditor "#{Config.admin['email']} (#{Config.admin['name']})" x.webMaster "#{Config.admin['email']} (#{Config.admin['name']})" x.docs 'http://backend.userland.com/rss/' x.ttl 60 x.atom :link, :rel => 'self', :type => 'application/rss+xml', :href => Config.site['url'].chomp('/') + rs(:rss).to_s Post.recent.all.each do |post| x.item { x.title post.title x.link post.url x.guid post.url, :isPermaLink => 'true' x.pubDate post.created_at.rfc2822 x.description post.body_rendered post..each do |tag| x.category tag.name, :domain => tag.url end } end } } throw(:respond, x.target!) end |
#sitemap ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/thoth/controller/main.rb', line 135 def sitemap error_404 unless Config.site['enable_sitemap'] response['Content-Type'] = 'text/xml' x = Builder::XmlMarkup.new(:indent => 2) x.instruct! x.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') { x.url { x.loc Config.site['url'] x.changefreq 'hourly' x.priority '1.0' } Page.reverse_order(:updated_at).all do |page| x.url { x.loc page.url x.lastmod page.updated_at.xmlschema x.changefreq 'weekly' x.priority '0.7' } end Post.filter(:is_draft => false).reverse_order(:updated_at).all do |post| x.url { x.loc post.url x.lastmod post.updated_at.xmlschema x.changefreq 'weekly' x.priority '0.6' } end } throw(:respond, x.target!) end |