runeblog 0.1.54 → 0.1.55

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea5002de3576419be68f651ed79ccd06abb53fcca47deb90601a1d21dadbb093
4
- data.tar.gz: 544e57415acfbae4302bf0b21be89edd7d2fa14390402aa2c342ecc4d7f2986e
3
+ metadata.gz: 5dfb6b74967e6212fc9e8474f483db8da090603d3b69ff77c3bdf0693ba01c77
4
+ data.tar.gz: e33b778ece67830c43c6ef717692e0987071e77c750cae360df7c354ae016b75
5
5
  SHA512:
6
- metadata.gz: 9da4ec096ef6e44aacd9e932407dca5e6aed3a482b0f3b8c47bbf220be98343455676bb31995feab8cc147c9cac9f3c42555d6ba40d345c2b308783b45c75f57
7
- data.tar.gz: c75b09de425a4994bf11a5c29838e58d0ab8306020ff69a0716f0d31bd32da197fd40dcf1b916c2eeb40aa58ac30c9ee4ee6129b6cdf1186eadc47300684e1fb
6
+ metadata.gz: 438cd7ca72a2c3491d37aaab15540f176858b3d63742d2a0803baaaf7b8a038ebdefdff54d228e96a5d6e3c48595ab5a388cc6668733048d1ea8b73e5823a7a3
7
+ data.tar.gz: 95cd3836e734ee3121d00720fd71fbcade3f1920a41c8fb596e2a08aad74b32b495d7807ad8d6d99df0cf7f32e575dec67426ae565fe1a08c103ea6d092c9133
data/lib/liveblog.rb ADDED
@@ -0,0 +1,232 @@
1
+ require 'ostruct'
2
+ require 'pp'
3
+ require 'date'
4
+
5
+ require 'runeblog' # Now depends explicitly
6
+
7
+ def quote
8
+ _passthru "<blockquote>"
9
+ _passthru _body
10
+ _passthru "</blockquote>"
11
+ _optional_blank_line
12
+ end
13
+
14
+ class ::Livetext::Functions # do this differently??
15
+
16
+ def asset # FIXME this is baloney...
17
+ raise "meh"
18
+ param = ::Livetext::Functions.param
19
+ context = ::Livetext::Functions.context
20
+ main = context.eval("@main") rescue "NO MAIN?"
21
+ @meta = main.instance_eval("@main.instance_eval { @meta }")
22
+ @config = main.instance_eval("@main.instance_eval { @config }")
23
+ @root = @config.root
24
+
25
+ text, name = param.split("|")
26
+
27
+ # FIXME how should this work?
28
+ view = @blog.view
29
+ url = find_asset(name)
30
+ "<a href='#{url}'>#{text}</a>"
31
+ end
32
+
33
+ end
34
+
35
+ def categories # does nothing right now
36
+ end
37
+
38
+ ### inset
39
+
40
+ def inset
41
+ lines = _body
42
+ box = ""
43
+ lines.each do |line|
44
+ line = line.dup
45
+ if line[0] == "/" # Only into inset
46
+ line[0] = ' '
47
+ box << line.dup + " "
48
+ line.replace(" ")
49
+ end
50
+ if line[0] == "|" # Into inset and body
51
+ line[0] = ' '
52
+ box << line.dup + " "
53
+ end
54
+ _passthru(line)
55
+ end
56
+ lr = _args.first
57
+ wide = _args[1] || "25"
58
+ _passthru "<div style='float:#{lr}; width: #{wide}%; padding:8px; padding-right:12px; font-family:verdana'>"
59
+ _passthru '<b><i>'
60
+ _passthru box
61
+ _passthru_noline '</i></b></div>'
62
+ _optional_blank_line
63
+ end
64
+
65
+ ### copy_asset
66
+
67
+ def copy_asset(asset)
68
+ vdir = @blog.view.dir
69
+ return if File.exist?(vdir + "/assets/" + asset)
70
+ top = vdir + "/../../assets/"
71
+ if File.exist?(top + asset)
72
+ system("cp #{top}/#{asset} #{vdir}/assets/#{asset}")
73
+ return
74
+ end
75
+ raise "Can't find #{asset.inspect}"
76
+ end
77
+
78
+ #############
79
+
80
+ def init_liveblog # FIXME - a lot of this logic sucks
81
+ @blog, num = Livetext.parameters
82
+ @meta = OpenStruct.new
83
+ @meta.num = num
84
+ @root = @blog.root rescue nil
85
+ @view = @blog.view.name rescue nil
86
+ @vdir = @blog.view.dir rescue nil
87
+ @body = ""
88
+ end
89
+
90
+ def _errout(*args)
91
+ ::STDERR.puts *args
92
+ end
93
+
94
+ def _passthru(line, context = nil)
95
+ return if line.nil?
96
+ line = _formatting(line, context)
97
+ @body << line + "\n"
98
+ @body << "<p>" if line.empty? && ! @_nopara
99
+ end
100
+
101
+ def _passthru_noline(line, context = nil)
102
+ return if line.nil?
103
+ line = _formatting(line, context)
104
+ @body << line
105
+ @body << "<p>" if line.empty? && ! @_nopara
106
+ end
107
+
108
+ def title
109
+ title = @_data.chomp
110
+ @meta.title = title
111
+ @body << "<h1>#{title}</h1>"
112
+ _optional_blank_line
113
+ end
114
+
115
+ def pubdate
116
+ _debug "data = #@_data"
117
+ # Check for discrepancy?
118
+ match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
119
+ junk, y, m, d = match.to_a
120
+ y, m, d = y.to_i, m.to_i, d.to_i
121
+ @meta.date = ::Date.new(y, m, d)
122
+ @meta.pubdate = "%04d-%02d-%02d" % [y, m, d]
123
+ _optional_blank_line
124
+ end
125
+
126
+ def image # primitive so far
127
+ _debug "img: huh? <img src=#{_args.first}></img>"
128
+ fname = _args.first
129
+ path = "../assets/#{fname}"
130
+ @body << "<img src=#{path}></img>"
131
+ _optional_blank_line
132
+ end
133
+
134
+ def tags
135
+ _debug "args = #{_args}"
136
+ @meta.tags = _args.dup || []
137
+ _optional_blank_line
138
+ end
139
+
140
+ def views
141
+ _debug "data = #{_args}"
142
+ @meta.views = _args.dup # + ["main"]
143
+ _optional_blank_line
144
+ end
145
+
146
+ def pin
147
+ _debug "data = #{_args}"
148
+ # verify only already-specified views?
149
+ @meta.pinned = _args.dup
150
+ _optional_blank_line
151
+ end
152
+
153
+ # def liveblog_version
154
+ # end
155
+
156
+ def list
157
+ @body << "<ul>"
158
+ _body {|line| @body << "<li>#{line}</li>" }
159
+ @body << "</ul>"
160
+ _optional_blank_line
161
+ end
162
+
163
+ def list!
164
+ @body << "<ul>"
165
+ lines = _body.each # {|line| @body << "<li>#{line}</li>" }
166
+ loop do
167
+ line = lines.next
168
+ line = _formatting(line)
169
+ if line[0] == " "
170
+ @body << line
171
+ else
172
+ @body << "<li>#{line}</li>"
173
+ end
174
+ end
175
+ @body << "</ul>"
176
+ _optional_blank_line
177
+ end
178
+
179
+ def asset
180
+ @meta.assets ||= {}
181
+ list = _args
182
+ # For now: copies, doesn't keep record
183
+ # Later: Add to file and uniq; use in publishing
184
+ list.each {|asset| copy_asset(asset) }
185
+ _optional_blank_line
186
+ end
187
+
188
+ def assets
189
+ @meta.assets ||= []
190
+ @meta.assets += _body
191
+ _optional_blank_line
192
+ end
193
+
194
+ def write_post(meta)
195
+ save = Dir.pwd
196
+ @postdir.gsub!(/\/\//, "/") # FIXME unneeded?
197
+ Dir.mkdir(@postdir) unless Dir.exist?(@postdir) # FIXME remember assets!
198
+ Dir.chdir(@postdir)
199
+ meta.views = meta.views.join(" ")
200
+ meta.tags = meta.tags.join(" ") rescue ""
201
+ File.write("body.txt", @body) # Actually HTML...
202
+ File.write("teaser.txt", meta.teaser)
203
+
204
+ fields = [:num, :title, :date, :pubdate, :views, :tags]
205
+
206
+ fname2 = "metadata.txt"
207
+ f2 = File.open(fname2, "w") do |f2|
208
+ fields.each {|fld| f2.puts "#{fld}: #{meta.send(fld)}" }
209
+ end
210
+ Dir.chdir(save)
211
+ rescue => err
212
+ puts "err = #{err}"
213
+ puts err.backtrace.join("\n")
214
+ end
215
+
216
+ def teaser
217
+ @meta.teaser = _body_text
218
+ @body << @meta.teaser + "\n"
219
+ # FIXME
220
+ end
221
+
222
+ def finalize
223
+ if @blog.nil?
224
+ puts @body
225
+ return
226
+ end
227
+ @slug = @blog.make_slug(@meta)
228
+ @postdir = @blog.view.dir + "/#@slug"
229
+ write_post(@meta) # FIXME
230
+ @meta
231
+ end
232
+
data/lib/post.rb CHANGED
@@ -98,8 +98,8 @@ class RuneBlog::Post
98
98
 
99
99
  def create_draft
100
100
  viewhome = @blog.view.publisher.url
101
- print "HOME = "
102
- p viewhome
101
+ # print "HOME = "
102
+ # p viewhome
103
103
  html = RuneBlog.post_template(title: @meta.title, date: @meta.pubdate,
104
104
  view: @meta.view, teaser: @meta.teaser, body: @meta.body,
105
105
  views: @meta.views, tags: @meta.tags, home: viewhome)
data/lib/repl.rb CHANGED
@@ -240,6 +240,7 @@ module RuneBlog::REPL
240
240
  file = files.first
241
241
  result = edit_file("#{@blog.root}/src/#{file}")
242
242
  @blog.rebuild_post(file)
243
+ sleep 5
243
244
  @out
244
245
  end
245
246
 
data/lib/runeblog.rb CHANGED
@@ -300,6 +300,8 @@ class RuneBlog
300
300
  debug "Called rebuild_post(#{file.inspect})"
301
301
  raise ArgumentError unless file.is_a?(String)
302
302
  meta = process_post(file)
303
+ p meta
304
+ sleep 4
303
305
  @views_dirty ||= []
304
306
  @views_dirty << meta.views
305
307
  @views_dirty.flatten!
@@ -1,6 +1,6 @@
1
1
 
2
2
  class RuneBlog
3
- VERSION = "0.1.54"
3
+ VERSION = "0.1.55"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
data/runeblog.gemspec CHANGED
@@ -5,9 +5,9 @@ $LOAD_PATH << "lib"
5
5
 
6
6
  require "runeblog_version"
7
7
 
8
- Gem.post_build do |spec|
9
- puts "Here we are"
10
- puts Dir.pwd
8
+ Gem.post_install do |spec|
9
+ Dir.chdir(RuneBlog::Path)
10
+ p Dir.pwd
11
11
  system("livetext -i liveblog.rb")
12
12
  end
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.54
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-28 00:00:00.000000000 Z
11
+ date: 2019-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -65,6 +65,7 @@ files:
65
65
  - lib/global.rb
66
66
  - lib/helpers-blog.rb
67
67
  - lib/helpers-repl.rb
68
+ - lib/liveblog.rb
68
69
  - lib/post.rb
69
70
  - lib/publish.rb
70
71
  - lib/repl.rb