runeblog 0.0.64 → 0.0.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/VERSION +1 -1
- data/lib/repl.rb +4 -33
- data/lib/runeblog.rb +95 -63
- data/test/repl.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 337899305625d6e47d1651fc7f5c74cbe01d9dac
|
4
|
+
data.tar.gz: c115cf315621933d753bfdb663e7030506354df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f653637ca0fbbc59f34faf72b263546befc886a3bb10ec3569de9c4209bee45a30c7e267af30f297d5701b76e201955d48827cb87258e9695cd91012ddb348d2
|
7
|
+
data.tar.gz: f56f552eb2475dd785d00b3ec2cb16b3bfa166a5bdc46adfcbbd3d19e908d8412d6db09a5a8322b6062c3519409c79f52e3f8801fee1236072dc0cddafa9abde
|
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RuneBlog v 0.0.
|
1
|
+
RuneBlog v 0.0.65 2018-09-27
|
data/lib/repl.rb
CHANGED
@@ -4,8 +4,6 @@ require 'helpers-repl' # FIXME structure
|
|
4
4
|
|
5
5
|
module RuneBlog::REPL
|
6
6
|
|
7
|
-
# @blog = open_blog
|
8
|
-
|
9
7
|
def cmd_quit(arg)
|
10
8
|
check_empty(arg)
|
11
9
|
abort "\n "
|
@@ -33,8 +31,9 @@ module RuneBlog::REPL
|
|
33
31
|
error(err)
|
34
32
|
end
|
35
33
|
|
36
|
-
def
|
34
|
+
def cmd_preview(arg)
|
37
35
|
reset_output
|
36
|
+
check_empty(arg)
|
38
37
|
local = @blog.viewdir(@blog.view) + "/index.html"
|
39
38
|
result = system("open #{local}")
|
40
39
|
raise CantOpen, local unless result
|
@@ -77,7 +76,7 @@ module RuneBlog::REPL
|
|
77
76
|
check_empty(arg)
|
78
77
|
puts
|
79
78
|
files = @blog.find_src_slugs
|
80
|
-
files.each {|file| rebuild_post(file) }
|
79
|
+
files.each {|file| @blog.rebuild_post(file) }
|
81
80
|
nil
|
82
81
|
rescue => err
|
83
82
|
error(err)
|
@@ -210,7 +209,7 @@ module RuneBlog::REPL
|
|
210
209
|
result = system("vi #{@blog.root}/src/#{file}")
|
211
210
|
raise "Problem editing #{file}" unless result
|
212
211
|
|
213
|
-
rebuild_post(file)
|
212
|
+
@blog.rebuild_post(file)
|
214
213
|
nil
|
215
214
|
rescue => err
|
216
215
|
error(err)
|
@@ -292,32 +291,4 @@ module RuneBlog::REPL
|
|
292
291
|
@out
|
293
292
|
end
|
294
293
|
|
295
|
-
## Funky stuff -- needs to move?
|
296
|
-
|
297
|
-
# def new_blog!(arg) # FIXME weird?
|
298
|
-
# check_empty(arg)
|
299
|
-
# return if RuneBlog.exist?
|
300
|
-
# yes = yesno(red(" No .blog found. Create new blog? "))
|
301
|
-
# RuneBlog.create_new_blog if yes
|
302
|
-
# rescue => err
|
303
|
-
# error(err)
|
304
|
-
# end
|
305
|
-
|
306
|
-
# def open_blog # Crude - FIXME later
|
307
|
-
# @blog = RuneBlog.new
|
308
|
-
# @view = @blog.view # current view
|
309
|
-
# @sequence = @blog.sequence
|
310
|
-
# @root = @blog.root
|
311
|
-
# @deploy ||= {}
|
312
|
-
# @blog.views.each do |view|
|
313
|
-
# deployment = @blog.viewdir(@view) + "deploy"
|
314
|
-
# check_file_exists(deployment)
|
315
|
-
# lines = File.readlines(deployment).map {|x| x.chomp }
|
316
|
-
# @deploy[@view] = lines
|
317
|
-
# end
|
318
|
-
# @blog
|
319
|
-
# rescue => err
|
320
|
-
# error(err)
|
321
|
-
# end
|
322
|
-
|
323
294
|
end
|
data/lib/runeblog.rb
CHANGED
@@ -2,19 +2,36 @@ require 'find'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'livetext'
|
4
4
|
|
5
|
+
def create_dir(dir) # FIXME move later
|
6
|
+
cmd = "mkdir -p #{dir} >/dev/null 2>&1"
|
7
|
+
result = system(cmd)
|
8
|
+
raise "Can't create #{dir}" unless result
|
9
|
+
end
|
10
|
+
|
11
|
+
def interpolate(str)
|
12
|
+
wrap = "<<-EOS\n#{str}\nEOS"
|
13
|
+
eval wrap
|
14
|
+
end
|
15
|
+
|
16
|
+
def error(err) # FIXME - this is duplicated
|
17
|
+
str = "\n Error: #{err}"
|
18
|
+
puts str
|
19
|
+
puts err.backtrace # [0]
|
20
|
+
end
|
21
|
+
|
5
22
|
class RuneBlog
|
6
|
-
VERSION = "0.0.
|
23
|
+
VERSION = "0.0.65"
|
7
24
|
|
8
25
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
9
|
-
DefaultData = Path + "/../data"
|
26
|
+
DefaultData = Path + "/../data/views/_default"
|
10
27
|
|
11
|
-
BlogHeaderPath
|
12
|
-
BlogTrailerPath
|
13
|
-
|
28
|
+
BlogHeaderPath = DefaultData + "/custom/blog_header.html"
|
29
|
+
BlogTrailerPath = DefaultData + "/custom/blog_trailer.html"
|
30
|
+
PostTemplatePath = DefaultData + "/custom/post_template.html"
|
14
31
|
|
15
|
-
BlogHeader
|
16
|
-
BlogTrailer
|
17
|
-
|
32
|
+
BlogHeader = File.read(BlogHeaderPath) rescue "not found"
|
33
|
+
BlogTrailer = File.read(BlogTrailerPath) rescue "not found"
|
34
|
+
PostTemplate = File.read(PostTemplatePath) rescue "not found"
|
18
35
|
|
19
36
|
attr_reader :root, :views, :sequence
|
20
37
|
attr_accessor :view # FIXME
|
@@ -68,7 +85,7 @@ class RuneBlog
|
|
68
85
|
|
69
86
|
File.write(dir + "custom/blog_header.html", RuneBlog::BlogHeader)
|
70
87
|
File.write(dir + "custom/blog_trailer.html", RuneBlog::BlogTrailer)
|
71
|
-
File.write(dir + "custom/post_template.html", RuneBlog::
|
88
|
+
File.write(dir + "custom/post_template.html", RuneBlog::PostTemplate)
|
72
89
|
File.write(dir + "last_deployed", "Initial creation")
|
73
90
|
self.views << arg
|
74
91
|
end
|
@@ -103,28 +120,10 @@ class RuneBlog
|
|
103
120
|
end
|
104
121
|
|
105
122
|
def create_new_post(title, testing = false)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
.
|
110
|
-
|
111
|
-
.title #{title}
|
112
|
-
.pubdate #{date}
|
113
|
-
.views #{view}
|
114
|
-
|
115
|
-
.teaser
|
116
|
-
Teaser goes here.
|
117
|
-
.end
|
118
|
-
Remainder of post goes here.
|
119
|
-
EOS
|
120
|
-
|
121
|
-
num, @slug = make_slug(title)
|
122
|
-
@fname = @slug + ".lt3"
|
123
|
-
File.open("#@root/src/#@fname", "w") {|f| f.puts @template }
|
124
|
-
edit_initial_post(@fname) unless testing
|
125
|
-
process_post(@fname) #- FIXME handle each view
|
126
|
-
publish_post(@meta)
|
127
|
-
num
|
123
|
+
post = RuneBlog::Post.new(title, @view)
|
124
|
+
post.edit unless testing
|
125
|
+
post.publish
|
126
|
+
post.num
|
128
127
|
rescue => err
|
129
128
|
puts err # error(err)
|
130
129
|
end
|
@@ -152,10 +151,9 @@ EOS
|
|
152
151
|
end
|
153
152
|
|
154
153
|
def process_post(file)
|
155
|
-
@main ||= Livetext.new
|
156
|
-
@main.main.output = File.new("/tmp/WHOA","w") # FIXME srsly?
|
157
154
|
path = @root + "/src/#{file}"
|
158
|
-
|
155
|
+
livetext = Livetext.new(STDOUT) # (nil)
|
156
|
+
@meta = livetext.process_file(path, binding)
|
159
157
|
raise "process_file returned nil" if @meta.nil?
|
160
158
|
|
161
159
|
num, slug = self.make_slug(@meta.title, self.sequence)
|
@@ -215,16 +213,6 @@ EOS
|
|
215
213
|
self.views.each {|view| generate_index(view) }
|
216
214
|
end
|
217
215
|
|
218
|
-
def reload_post(file)
|
219
|
-
@main ||= Livetext.new
|
220
|
-
@main.main.output = File.new("/tmp/WHOA","w") # FIXME srsly?
|
221
|
-
@meta = process_post(file)
|
222
|
-
@meta.slug = file.sub(/.lt3$/, "")
|
223
|
-
@meta
|
224
|
-
rescue => err
|
225
|
-
error(err)
|
226
|
-
end
|
227
|
-
|
228
216
|
def posting(view, meta)
|
229
217
|
# FIXME clean up and generalize
|
230
218
|
ref = "#{view}/#{meta.slug}/index.html"
|
@@ -238,10 +226,12 @@ EOS
|
|
238
226
|
<br><br>
|
239
227
|
<hr>
|
240
228
|
HTML
|
229
|
+
text = File.read(self.viewdir(view) + "custom/post_template.html")
|
230
|
+
interpolate(text)
|
241
231
|
end
|
242
232
|
|
243
233
|
def rebuild_post(file)
|
244
|
-
|
234
|
+
@meta = process_post(file)
|
245
235
|
publish_post(@meta) # FIXME ??
|
246
236
|
rescue => err
|
247
237
|
error(err)
|
@@ -272,23 +262,6 @@ EOS
|
|
272
262
|
dirs
|
273
263
|
end
|
274
264
|
|
275
|
-
def create_dir(dir)
|
276
|
-
cmd = "mkdir -p #{dir} >/dev/null 2>&1"
|
277
|
-
result = system(cmd)
|
278
|
-
raise "Can't create #{dir}" unless result
|
279
|
-
end
|
280
|
-
|
281
|
-
def error(err) # FIXME - this is duplicated
|
282
|
-
str = "\n Error: #{err}"
|
283
|
-
puts str
|
284
|
-
puts err.backtrace # [0]
|
285
|
-
end
|
286
|
-
|
287
|
-
def interpolate(str)
|
288
|
-
wrap = "<<-EOS\n#{str}\nEOS"
|
289
|
-
eval wrap
|
290
|
-
end
|
291
|
-
|
292
265
|
def find_src_slugs
|
293
266
|
files = Dir.entries("#@root/src/").grep /\d\d\d\d.*.lt3$/
|
294
267
|
files.map! {|f| File.basename(f) }
|
@@ -302,6 +275,10 @@ end
|
|
302
275
|
|
303
276
|
class RuneBlog::Post
|
304
277
|
|
278
|
+
class << self
|
279
|
+
attr_accessor :blog
|
280
|
+
end
|
281
|
+
|
305
282
|
attr_reader :id, :title, :date, :views, :num, :slug
|
306
283
|
|
307
284
|
def self.files(num, root)
|
@@ -311,15 +288,70 @@ class RuneBlog::Post
|
|
311
288
|
end
|
312
289
|
|
313
290
|
def initialize(title, view)
|
291
|
+
raise "Post.blog is not set!" if RuneBlog::Post.blog.nil?
|
292
|
+
@blog = RuneBlog::Post.blog
|
314
293
|
@title = title
|
315
294
|
@view = view
|
316
295
|
@num, @slug = make_slug
|
296
|
+
##
|
297
|
+
date = Time.now.strftime("%Y-%m-%d")
|
298
|
+
template = <<-EOS.gsub(/^ */, "")
|
299
|
+
.mixin liveblog
|
300
|
+
|
301
|
+
.title #{title}
|
302
|
+
.pubdate #{date}
|
303
|
+
.views #{view}
|
304
|
+
|
305
|
+
.teaser
|
306
|
+
Teaser goes here.
|
307
|
+
.end
|
308
|
+
Remainder of post goes here.
|
309
|
+
EOS
|
310
|
+
|
311
|
+
@draft = "#{@blog.root}/src/#@slug.lt3"
|
312
|
+
File.write(@draft, template)
|
313
|
+
end
|
314
|
+
|
315
|
+
def edit
|
316
|
+
result = system("vi #@draft +8")
|
317
|
+
raise "Problem editing #@draft" unless result
|
318
|
+
nil
|
319
|
+
rescue => err
|
320
|
+
error(err)
|
321
|
+
end
|
322
|
+
|
323
|
+
def publish
|
324
|
+
livetext = Livetext.new(STDOUT)
|
325
|
+
@meta = livetext.process_file(@draft, binding)
|
326
|
+
raise "process_file returned nil" if @meta.nil?
|
327
|
+
|
328
|
+
@meta.views.each do |view| # Create dir using slug (index.html, metadata?)
|
329
|
+
vdir = @blog.viewdir(view)
|
330
|
+
dir = vdir + @slug + "/"
|
331
|
+
Dir.mkdir(dir)
|
332
|
+
Dir.chdir(dir) do
|
333
|
+
create_post_subtree(vdir)
|
334
|
+
@blog.generate_index(view)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
rescue => err
|
338
|
+
p err
|
339
|
+
err.backtrace.each {|x| puts x }
|
340
|
+
# error(err)
|
317
341
|
end
|
318
342
|
|
319
343
|
private
|
320
344
|
|
345
|
+
def create_post_subtree(vdir)
|
346
|
+
create_dir("assets")
|
347
|
+
File.write("metadata.yaml", @meta.to_yaml)
|
348
|
+
template = File.read(vdir + "/custom/post_template.html")
|
349
|
+
text = interpolate(template)
|
350
|
+
File.write("index.html", text)
|
351
|
+
end
|
352
|
+
|
321
353
|
def make_slug(postnum = nil)
|
322
|
-
postnum ||=
|
354
|
+
postnum ||= @blog.next_sequence
|
323
355
|
num = tag(postnum) # FIXME can do better
|
324
356
|
slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
325
357
|
[postnum, "#{num}-#{slug}"]
|
data/test/repl.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.65
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|