tdiary 5.6.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi
@@ -307,7 +307,7 @@ files:
307
307
  - misc/plugin/ChangeLog.DO_NOT_UPDATE
308
308
  - misc/plugin/a.rb
309
309
  - misc/plugin/amazon.rb
310
- - misc/plugin/amp.rb
310
+ - misc/plugin/amazon_rakuten.rb
311
311
  - misc/plugin/append-css.rb
312
312
  - misc/plugin/bq.rb
313
313
  - misc/plugin/calendar2.rb
@@ -1030,7 +1030,6 @@ files:
1030
1030
  - vendor/bundle/ruby/3.4.0/specifications/rake-13.4.2.gemspec
1031
1031
  - vendor/bundle/ruby/3.4.0/specifications/thor-1.5.0.gemspec
1032
1032
  - vendor/bundle/ruby/3.4.0/specifications/timeout-0.6.1.gemspec
1033
- - views/amp.rhtml
1034
1033
  - views/category.rhtml
1035
1034
  - views/conf.rhtml
1036
1035
  - views/day.rhtml
data/misc/plugin/amp.rb DELETED
@@ -1,118 +0,0 @@
1
- # amp.rb
2
- #
3
- # generate AMP style HTML
4
- #
5
- # Copyright (c) 2016 MATSUOKA Kohei
6
- # Distributed under the GPL2 or any later version.
7
- #
8
- module AMP
9
- def amp_header_procs
10
- @amp_header_procs ||= []
11
- end
12
-
13
- def amp_body_enter_procs
14
- @amp_body_enter_procs ||= []
15
- end
16
-
17
- def add_amp_header_proc(&block)
18
- amp_header_procs << block if block_given?
19
- end
20
-
21
- def add_amp_body_enter_proc(&block)
22
- amp_body_enter_procs << block if block_given?
23
- end
24
-
25
- def amp_header_proc
26
- amp_header_procs.map{|proc| proc.call }.join("\n")
27
- end
28
-
29
- def amp_body_enter_proc
30
- amp_body_enter_procs.map {|proc| proc.call }.join("\n")
31
- end
32
- end
33
- extend AMP
34
-
35
- add_header_proc do
36
- if @mode == 'day'
37
- begin
38
- diary = @diaries[@date.strftime('%Y%m%d')]
39
- %Q|<link rel="amphtml" href="#{amp_html_url(diary)}">|
40
- rescue NoMethodError
41
- ''
42
- end
43
- end
44
- end
45
-
46
- add_content_proc('amp') do |date|
47
- begin
48
- diary = @diaries[date]
49
- template = File.read(File.join(TDiary::root, "views/amp.rhtml"))
50
- ERB.new(template).result(binding)
51
- rescue NoMethodError
52
- raise TDiary::NotFound
53
- end
54
- end
55
-
56
- def amp_body(diary)
57
- apply_plugin(diary.to_html)
58
- .gsub(/<img\s/, '<amp-img layout="responsive" ')
59
- .gsub(/<script[^<]+<\/script>/, '')
60
- end
61
-
62
- def amp_canonical_url(diary)
63
- URI.join(@conf.base_url, anchor(diary.date.strftime('%Y%m%d')))
64
- end
65
-
66
- def amp_day_title(diary)
67
- title_proc(Time::at(@date.to_i), diary.title)
68
- end
69
-
70
- def amp_html_url(diary)
71
- uri = amp_canonical_url(diary)
72
- uri.query = [uri.query, "plugin=amp"].compact.join '&'
73
- uri
74
- end
75
-
76
- def amp_style
77
- base_css = amp_base_css
78
- theme_css = amp_theme_css
79
- .gsub(/^@charset.*$/, '')
80
- .gsub(/!important/, '')
81
-
82
- <<-EOL
83
- #{base_css}
84
- #{theme_css}
85
- EOL
86
- end
87
-
88
- def amp_base_css
89
- base_css_path = theme_paths_local.map {|path|
90
- File.join(File.dirname(path), "base.css")
91
- }.find {|path|
92
- File.exist?(path)
93
- }
94
- base_css_path ? File.read(base_css_path) : ''
95
- end
96
-
97
- def amp_theme_css
98
- _, location, theme = @conf.theme.match(%r|(\w+)/(\w+)|).to_a
99
- case location
100
- when 'online'
101
- require 'uri'
102
- require 'open-uri'
103
- uri = URI.parse(theme_url_online(theme))
104
- uri.scheme ||= 'https'
105
- URI.parse(uri.to_s).read
106
- when 'local'
107
- theme_path = theme_paths_local.map {|path|
108
- File.join(File.dirname(path), "#{theme}/#{theme}.css")
109
- }.find {|path|
110
- File.exist?(path)
111
- }
112
- theme_path ? File.read(theme_path) : ''
113
- end
114
- end
115
-
116
- def amp_title
117
- @conf.html_title
118
- end
data/views/amp.rhtml DELETED
@@ -1,34 +0,0 @@
1
- <!doctype html>
2
- <html ⚡ lang="ja">
3
- <head>
4
- <meta charset="utf-8">
5
- <%= amp_header_proc %>
6
- <script async src="https://cdn.ampproject.org/v0.js"></script>
7
- <title><%= amp_title %></title>
8
- <link rel="canonical" href="<%= amp_canonical_url(diary) %>" />
9
- <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
10
- <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
11
- <style amp-custom>
12
- <%= amp_style %>
13
- </style>
14
- </head>
15
- <body>
16
- <%= amp_body_enter_proc %>
17
- <div class="whole-content">
18
- <div class="adminmenu">
19
- <%= navi_user %>
20
- </div>
21
- <div class="content">
22
- <h1><a href="<%= amp_canonical_url(diary) %>"><%= amp_title %></a></h1>
23
- <div class="day">
24
- <h2><%= amp_day_title(diary) %></h2>
25
- <div class="body">
26
- <%= amp_body(diary) %>
27
- </div>
28
- </div>
29
- </div>
30
- <div class="footer">
31
- </div>
32
- </div>
33
- </body>
34
- </html>