tdiary-blogkit 5.0.2 → 5.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 576eb10416dfe7ab894d6a755bb09a4581cb48b3
4
- data.tar.gz: 7930fa8fa513af7ecf9bf7a2db4b1b4fffec5f77
3
+ metadata.gz: c1a9cb95c8d737addc465d075ec1743b1b9a2a46
4
+ data.tar.gz: 5df2585f429e645dac7e2f3a06337e1bf8699cf3
5
5
  SHA512:
6
- metadata.gz: 59c36612af3dc5cf5e8771a7d948be2704154a54a909c7c6bf116c5a328a0d0ea42f9d6638ae8169b60809bd61e17e33c89b67a5142e50242f52636076055316
7
- data.tar.gz: b5c7dfe231f488a68c05ddf346819042b15aedb75ada1b33faf18f881d5fc08c603e9a7502f0454c969d970f7e5ade8c2cdd5787afd5604eb0fabcb408b31a40
6
+ metadata.gz: be5f2ac0801f0411822867c005ac01e74430e876586d037d336de22dc7f44993257adca8f9bbcae286c8f2b3e2232b7e9b4ea3d655913f6726714d32db162750
7
+ data.tar.gz: db0539132cf507242ba491416b881ee1aa87d36dd312cdfdd79478eb0b2b9f08afc7b29381ae076a976d9422598fdb9b07d97b98c7946afd94b8b95090c337a2
@@ -1,5 +1,5 @@
1
1
  module TDiary
2
2
  class Blogkit
3
- VERSION = "5.0.2"
3
+ VERSION = "5.0.3"
4
4
  end
5
5
  end
@@ -10,8 +10,6 @@
10
10
  # Distributed under the GPL
11
11
  #
12
12
 
13
- require 'pstore'
14
-
15
13
  def blog_category
16
14
  cat = @cgi.params['blogcategory'][0]
17
15
  if cat and !cat.empty?
@@ -46,7 +44,7 @@ if /^(latest|month|day|append|replace|comment|showcomment|saveconf|trackbackrece
46
44
  return '' unless @title
47
45
  stripped = @title.sub(/^(\[(.*?)\])+\s*/,'')
48
46
  end
49
-
47
+
50
48
  def categories
51
49
  return [] unless @title
52
50
  cat = /^(\[([^\[]+?)\])+/.match(@title).to_a[0]
@@ -107,27 +105,24 @@ def navi_user
107
105
  end
108
106
 
109
107
  def blog_category_cache
110
- "#{@cache_path}/blog_category"
108
+ "blog_category"
111
109
  end
112
110
 
113
111
  def blog_category_cache_add(diary)
114
- PStore.new(blog_category_cache).transaction do |db|
115
- db['blog_category'] = Hash.new unless db.root?('blog_category')
112
+ transaction(blog_category_cache) do |db|
113
+ cache = JSON.load(db.get('blog_category')) || Hash.new
116
114
  diary.categories.each do |c|
117
- db['blog_category'][c] = Hash.new unless db['blog_category'][c]
118
- db['blog_category'][c][diary.date.strftime('%Y%m%d')] = diary.stripped_title
115
+ cache[c] ||= Hash.new
116
+ cache[c][diary.date.strftime('%Y%m%d')] = diary.stripped_title
119
117
  end
118
+ db.set('blog_category', cache.to_json)
120
119
  end
121
120
  end
122
121
 
123
122
  def blog_category_cache_restore
124
- return nil unless File.exist?(blog_category_cache)
125
- cache = {}
126
- PStore.new(blog_category_cache).transaction do |db|
127
- cache.update(db['blog_category'])
128
- db.abort
123
+ transaction(blog_category_cache) do |db|
124
+ JSON.load(db.get('blog_category'))
129
125
  end
130
- cache
131
126
  end
132
127
 
133
128
  def blog_category_entry(limit = 20)
@@ -179,20 +174,21 @@ def blog_category_cache_initialize
179
174
  cgi = CGI::new
180
175
  def cgi.referer; nil; end
181
176
 
182
- PStore.new(blog_category_cache).transaction do |db|
183
- db['blog_category'] = Hash.new
177
+ transaction(blog_category_cache) do |db|
178
+ cache = Hash.new
184
179
  @years.each do |y, ms|
185
180
  ms.each do |m|
186
181
  cgi.params['date'] = ["#{y}#{m}"]
187
182
  m = TDiaryMonth.new(cgi, '', @conf)
188
183
  m.diaries.each do |k, diary|
189
184
  diary.categories.each do |c|
190
- db['blog_category'][c] = Hash.new unless db['blog_category'][c]
191
- db['blog_category'][c][diary.date.strftime('%Y%m%d')] = diary.stripped_title
185
+ cache[c] ||= Hash.new
186
+ cache[c][diary.date.strftime('%Y%m%d')] = diary.stripped_title
192
187
  end
193
188
  end
194
189
  end
195
190
  end
191
+ db.set('blog_category', cache.to_json)
196
192
  end
197
193
  end
198
194
 
@@ -24,14 +24,13 @@
24
24
  # Copyright (c) 2002 by TADA Tadashi <sho@spc.gr.jp>
25
25
  # Distributed under the GPL
26
26
  #
27
- require 'pstore'
28
27
 
29
28
  def whatsnew_list( max = 5, limit = 20 )
30
29
  return 'DO NOT USE IN SECURE MODE' if @conf.secure
31
30
 
32
31
  max = max.to_i
33
32
  limit = limit.to_i
34
-
33
+
35
34
  wl = "#{@cache_path}/whatsnew-list"
36
35
  begin
37
36
  if @mode == 'latest' then
@@ -42,15 +41,14 @@ def whatsnew_list( max = 5, limit = 20 )
42
41
  end
43
42
 
44
43
  r = "<ul>\n"
45
- PStore::new( wl ).transaction do |db|
44
+ transaction( 'whatsnew-list' ) do |db|
46
45
  begin
47
- wn = db['whatsnew']
46
+ wn = JSON.load( db.get( 'whatsnew' ) ) || []
48
47
  wn.each_with_index do |item,i|
49
48
  break if i >= max
50
49
  title = @conf.shorten( apply_plugin( item[1] ).gsub( /^(\[.*?\])+\s*/, '' ).gsub( /<.*?>/, '' ), limit )
51
50
  r << %Q|<li><a href="#{h @index}#{anchor item[0]}">#{title}</a></li>\n|
52
51
  end
53
- db.abort
54
52
  rescue
55
53
  end
56
54
  end
@@ -70,7 +68,7 @@ add_conf_proc( 'whatsnew_list', "What's New List", 'update' ) do
70
68
  rescue Errno::EACCES
71
69
  @conf['whatsnew_list.rdf.out'] = false
72
70
  error_message = %Q|<p class="message">#{rdf}#{@whatsnew_list_msg_access}</p>|
73
-
71
+
74
72
  end
75
73
  else
76
74
  @conf['whatsnew_list.rdf.out'] = false
@@ -209,17 +207,14 @@ def whatsnew_list_update
209
207
  @whatsnew_list_in_feed = false
210
208
 
211
209
  new_item = [diary.date.strftime('%Y%m%d'), title, Time::now.strftime("%Y-%m-%dT%H:%M:%S#{zone}"), desc]
212
- PStore::new( "#{@cache_path}/whatsnew-list" ).transaction do |db|
210
+ transaction( 'whatsnew-list' ) do |db|
213
211
  wn = []
214
- begin
215
- (db['whatsnew'] || []).each_with_index do |item, i|
216
- wn << item unless item[0] == new_item[0]
217
- break if i > 15
218
- end
219
- rescue PStore::Error
212
+ (JSON.load( db.get( 'whatsnew' ) ) || []).each_with_index do |item, i|
213
+ wn << item unless item[0] == new_item[0]
214
+ break if i > 15
220
215
  end
221
216
  wn.unshift new_item if diary.visible?
222
- db['whatsnew'] = wn
217
+ db.set( 'whatsnew', wn.to_json )
223
218
 
224
219
  rdf = whatsnew_list_rdf_file
225
220
  if @conf['whatsnew_list.rdf.out'] then
@@ -253,6 +248,10 @@ add_edit_proc do
253
248
  HTML
254
249
  end
255
250
 
251
+ add_startup_proc do
252
+ whatsnew_list_update
253
+ end
254
+
256
255
  # Local Variables:
257
256
  # mode: ruby
258
257
  # indent-tabs-mode: t
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary-blogkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tDiary contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hikidoc
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.5.1
158
+ rubygems_version: 2.6.8
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: tDiary blogkit package.