summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2014-01-14 17:32:07 +0100
committerAlex Legler <alex@a3li.li>2014-01-14 17:32:07 +0100
commitef5de35fb5e5b9ccb9119d311dccbe5e926864d4 (patch)
treef4074e9682536432ec3ab6de1cf5a91152b4e6db
parentRescue JSON parse failures (diff)
downloadinfra-status-ef5de35fb5e5b9ccb9119d311dccbe5e926864d4.tar.gz
infra-status-ef5de35fb5e5b9ccb9119d311dccbe5e926864d4.tar.bz2
infra-status-ef5de35fb5e5b9ccb9119d311dccbe5e926864d4.zip
Use proper update times
Read the notice's mtime. Just used for the Atom feed right now.
-rw-r--r--infra-status.rb2
-rw-r--r--lib/notice_store.rb5
2 files changed, 5 insertions, 2 deletions
diff --git a/infra-status.rb b/infra-status.rb
index b3bec91..0029579 100644
--- a/infra-status.rb
+++ b/infra-status.rb
@@ -50,7 +50,7 @@ get '/feed.atom' do
maker.items.new_item do |item|
item.link = MY_URL + 'notice/' + notice['id']
item.title = notice['title']
- item.updated = notice['created_at'].to_s
+ item.updated = notice['updated_at'].to_s
item.description = markdown(notice.get_content)
end
end
diff --git a/lib/notice_store.rb b/lib/notice_store.rb
index 77b1edc..1d29fdd 100644
--- a/lib/notice_store.rb
+++ b/lib/notice_store.rb
@@ -69,7 +69,10 @@ end
class Notice
def self.from_file(filename)
content = File.read(filename)
- new(File.basename(filename, '.txt'), YAML.load(content), content.split('---')[2].strip)
+ metadata = YAML.load(content) || {}
+ metadata['updated_at'] = File.mtime(filename)
+
+ new(File.basename(filename, '.txt'), metadata, content.split('---')[2].strip)
end
def [](what)