Skip to content

Commit

Permalink
fix error of amp plugin on the day is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
tdtds committed Jun 15, 2017
1 parent cf7aebe commit 0ad4a47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2017-06-15 Tada, Tadashi <t@tdtds.jp>
* plugin/amp.rb: fix error on the day was empty

2017-03-29 Tada, Tadashi <t@tdtds.jp>
* release 5.0.4

Expand Down
2 changes: 1 addition & 1 deletion lib/tdiary/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TDiary
VERSION = '5.0.4'
VERSION = '5.0.4.20170615'
end
18 changes: 13 additions & 5 deletions misc/plugin/amp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ def amp_body_enter_proc

add_header_proc do
if @mode == 'day'
diary = @diaries[@date.strftime('%Y%m%d')]
%Q|<link rel="amphtml" href="#{amp_html_url(diary)}">|
begin
diary = @diaries[@date.strftime('%Y%m%d')]
%Q|<link rel="amphtml" href="#{amp_html_url(diary)}">|
rescue NoMethodError
''
end
end
end

add_content_proc('amp') do |date|
diary = @diaries[date]
template = File.read(File.join(TDiary::root, "views/amp.rhtml"))
ERB.new(template).result(binding)
begin
diary = @diaries[date]
template = File.read(File.join(TDiary::root, "views/amp.rhtml"))
ERB.new(template).result(binding)
rescue NoMethodError
raise TDiary::NotFound
end
end

def amp_body(diary)
Expand Down

0 comments on commit 0ad4a47

Please sign in to comment.