mirror of
https://github.com/neocities/neocities.git
synced 2025-07-20 09:36:00 +02:00
RSS/Atom feed for sites
This commit is contained in:
parent
b47997a030
commit
5edeba9495
3 changed files with 30 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
require 'tilt'
|
||||
require 'rss'
|
||||
|
||||
class Site < Sequel::Model
|
||||
include Sequel::ParanoidDelete
|
||||
|
@ -456,7 +457,7 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def title
|
||||
values[:title] || values[:username]
|
||||
values[:title] || "#{values[:username]}.neocities.org"
|
||||
end
|
||||
|
||||
def hits_english
|
||||
|
@ -510,4 +511,23 @@ class Site < Sequel::Model
|
|||
ext = File.extname(filename).gsub('.', '').match(LOSSY_IMAGE_REGEX) ? 'jpg' : 'png'
|
||||
"#{THUMBNAILS_URL_ROOT}/#{values[:username]}/#{filename}.#{resolution}.#{ext}"
|
||||
end
|
||||
|
||||
def to_rss
|
||||
RSS::Maker.make("atom") do |maker|
|
||||
maker.channel.title = title
|
||||
maker.channel.updated = updated_at
|
||||
maker.channel.author = username
|
||||
maker.channel.id = "#{username}.neocities.org"
|
||||
|
||||
latest_events.each do |event|
|
||||
if event.site_change_id
|
||||
maker.items.new_item do |item|
|
||||
item.link = "http://#{username}.neocities.org"
|
||||
item.title = "#{username}.neocities.org has been updated"
|
||||
item.updated = event.site_change.created_at
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue