runeblog 0.1.81 → 0.1.82

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: a40ca6858d4ca38b504ef54bb5a8f87433abb297b8ec63c88ae1b5d2aa3762eb
4
- data.tar.gz: 960b06aadc8ab29c28bf46c8907722b9dc91ce095157ca9cfc554fc3fbd05675
3
+ metadata.gz: d1767dd929fb222d5107da06ce3cafb3b0916fe6ff13fda0bf23e649c59fa678
4
+ data.tar.gz: 572f0934dcf02a10cc922b5910d5c4602a64078eb46b9304613000e7bd426868
5
5
  SHA512:
6
- metadata.gz: 5a81c6cb6fe18bc970997818775e8ce8e348acb9fd75e83f2f8fd75a83bee3875f83cf5bead1e6f9bbddf7da9060ff20a228b1f7d0ad632a8f52c139e90f621d
7
- data.tar.gz: 59a0c7e1da3d22d22ebf207d1543850355048fca50cae82483739c9a0ce65d49fbd3bb0ea8d6c43556a04c7fc64c33d7f44b692edb210cdde680ecf1735be4a8
6
+ metadata.gz: 1d0f9babd073538726699c6c41ee4022be7d998ede5af13d10ac36034908f83f6090ffec1de555e754bf64103bb220761d7cd7f25e06533385e384b1348f0e16
7
+ data.tar.gz: 414278f412434ab9acbaf4be6675c3228844f62d7c4ab62d41953aed5901ee19cac81756ef0271442826a705afdca32e9ba2b515fa564b9830c619a2f9707085
data/data/standard.tgz CHANGED
Binary file
data/lib/default.rb CHANGED
@@ -23,6 +23,9 @@ def RuneBlog.post_template(num: 0, title: "No title", date: nil, view: "test_vie
23
23
  #{teaser}
24
24
  .end
25
25
  #{body}
26
+
27
+ <br>
28
+ <a href="javascript:history.go(-1)">[Back]</a>
26
29
  TEXT
27
30
 
28
31
  end
data/lib/helpers-blog.rb CHANGED
@@ -4,6 +4,20 @@ require 'runeblog_version'
4
4
 
5
5
  module RuneBlog::Helpers
6
6
 
7
+ def copy(src, dst)
8
+ system("cp #{src} #{dst}")
9
+ end
10
+
11
+ def copy!(src, dst)
12
+ system("cp -r #{src} #{dst}")
13
+ end
14
+
15
+ def livetext(src, dst)
16
+ src << ".lt3" unless src.end_with?(".lt3")
17
+ dst << ".html" unless src.end_with?(".html")
18
+ system("livetext #{src} >#{dst}")
19
+ end
20
+
7
21
  def get_root
8
22
  if $_blog
9
23
  if $_blog.root
@@ -114,9 +128,9 @@ module RuneBlog::Helpers
114
128
  raise CantCreateDir(dir) unless result
115
129
  end
116
130
 
117
- def interpolate(str)
131
+ def interpolate(str, binding)
118
132
  wrap = "<<-EOS\n#{str}\nEOS"
119
- eval wrap
133
+ eval wrap, binding
120
134
  end
121
135
 
122
136
  def error(err) # Hmm, this is duplicated
data/lib/liveblog.rb CHANGED
@@ -32,6 +32,7 @@ end
32
32
  def post
33
33
  @meta = OpenStruct.new
34
34
  @meta.num = _args[0]
35
+ _out " <!-- Post number #{@meta.num} -->\n "
35
36
  end
36
37
 
37
38
  def _view_from_cwd
@@ -300,7 +301,7 @@ def head
300
301
  "linkc" => %[<link rel="canonical" href="#{_var(:host)}">],
301
302
  "og:url" => %[<meta property="og:url" content="#{_var(:host)}">],
302
303
  "og:site_name" => %[<meta property="og:site_name" content="#{_var(:title)}">],
303
- "style" => %[<link rel="stylesheet" href="blog-application.css">],
304
+ "style" => %[<link rel="stylesheet" href="assets/blog.css">],
304
305
  "feed" => %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}/feed.xml" title="#{_var(:title)}">],
305
306
  "favicon" => %[<link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">\n <link rel="apple-touch-icon" href="../assets/favicon.ico">]
306
307
  }
@@ -325,7 +326,7 @@ def head
325
326
  end
326
327
  end
327
328
  hash = defaults.dup.update(result) # FIXME collisions?
328
- _out "<html lang=en_US>"
329
+ # _out "<html lang=en_US>"
329
330
  _out "<head>"
330
331
  hash.each_value {|x| _out " " + x }
331
332
  _out "</head>"
@@ -402,6 +403,7 @@ def script
402
403
  _out %[<script src="#{url}" integrity="#{integ}" crossorigin="#{cross}"></script>]
403
404
  end
404
405
 
406
+
405
407
  ### How this next bit works:
406
408
  ###
407
409
  ### all_teasers will call _find_recent_posts
@@ -439,7 +441,7 @@ def all_teasers
439
441
 
440
442
  text = <<-HTML
441
443
  <html>
442
- <head><link rel="stylesheet" href="blog-application.css"></head>
444
+ <head><link rel="stylesheet" href="assets/blog.css"></head>
443
445
  <body>
444
446
  HTML
445
447
  posts = _find_recent_posts
@@ -491,6 +493,7 @@ def _teaser(slug)
491
493
  text
492
494
  end
493
495
 
496
+
494
497
  def card_iframe
495
498
  title = _data
496
499
  lines = _body
data/lib/post.rb CHANGED
@@ -153,5 +153,18 @@ class RuneBlog::ViewPost
153
153
  @title = lines.grep(/title:/).first[7..-1].chomp
154
154
  @date = lines.grep(/pubdate:/).first[9..-1].chomp
155
155
  end
156
+
157
+ def get_dirs
158
+ fname = File.basename(draft)
159
+ noext = fname.sub(/.lt3$/, "")
160
+ vdir = "#@root/views/#{view}"
161
+ dir = "#{vdir}/posts/#{noext}/"
162
+ Dir.mkdir(dir) unless Dir.exist?(dir)
163
+ system("cp #{draft} #{dir}")
164
+ viewdir, slugdir, aslug = vdir, dir, noext[5..-1]
165
+ theme = viewdir + "/themes/standard"
166
+ [noext, viewdir, slugdir, aslug, theme]
167
+ end
168
+
156
169
  end
157
170
 
data/lib/runeblog.rb CHANGED
@@ -1,4 +1,5 @@
1
- require 'livetext'
1
+ require 'date'
2
+ # require 'livetext'
2
3
 
3
4
  require 'runeblog_version'
4
5
  require 'global'
@@ -24,7 +25,7 @@ class RuneBlog
24
25
  make_exception(:CantCreateDir, "Can't create directory $1")
25
26
  make_exception(:EditorProblem, "Could not edit $1")
26
27
  make_exception(:NoSuchView, "No such view: $1")
27
- make_exception(:LivetextError, "Livetext#process_file returned nil for $1")
28
+ # make_exception(:LivetextError, "Livetext#process_file returned nil for $1")
28
29
  make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
29
30
 
30
31
 
@@ -169,8 +170,14 @@ class RuneBlog
169
170
  create_dir('assets')
170
171
  create_dir('posts')
171
172
 
173
+ create_dir('staging')
174
+ create_dir('staging/assets')
175
+ create_dir('remote')
176
+ create_dir('remote/assets')
177
+
172
178
  Dir.chdir("themes") { system("tar zxvf #{GemData}/standard.tgz >/dev/null 2>&1") }
173
- # system("cp themes/standard/blog/assets/* assets/")
179
+ copy!("themes/standard/*", "staging/")
180
+ copy("themes/standard/assets/*", "remote/assets/")
174
181
 
175
182
  pub = "user: xxx\nserver: xxx\ndocroot: xxx\npath: xxx\nproto: xxx\n"
176
183
  dump(pub, "publish")
@@ -210,6 +217,71 @@ class RuneBlog
210
217
  result
211
218
  end
212
219
 
220
+ def post_lookup(postid) # side-effect?
221
+ # .. = templates, ../.. = views/thisview
222
+ slug = title = date = teaser_text = nil
223
+
224
+ dir_posts = @vdir + "/posts"
225
+ posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts + "/" + x }
226
+ posts.select! {|x| File.directory?(x) }
227
+
228
+ post = posts.select {|x| File.basename(x).to_i == postid }
229
+ raise "Error: More than one post #{postid}" if post.size > 1
230
+ postdir = post.first
231
+ vp = RuneBlog::ViewPost.new(self.view, postdir)
232
+ vp
233
+ end
234
+
235
+ def teaser(slug)
236
+ id = slug.to_i
237
+ text = nil
238
+ post_entry_name = @theme + "/blog-_postentry.lt3"
239
+ @_post_entry ||= File.read(post_entry_name)
240
+ vp = post_lookup(id)
241
+ nslug, aslug, title, date, teaser_text =
242
+ vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text
243
+ path = vp.path
244
+ # url = "#{path}/#{aslug}.html" # Should be relative to .blogs!! FIXME
245
+ url = "#{aslug}.html" # Should be relative to .blogs!! FIXME
246
+ date = ::Date.parse(date)
247
+ date = date.strftime("%B %e<br>%Y")
248
+ text = interpolate(@_post_entry, binding)
249
+ text
250
+ end
251
+
252
+ def collect_recent_posts(file)
253
+ @vdir = ".."
254
+ posts = nil
255
+ dir_posts = @vdir + "/posts"
256
+ entries = Dir.entries(dir_posts)
257
+ posts = entries.grep(/^\d\d\d\d/).map {|x| dir_posts + "/" + x }
258
+ posts.select! {|x| File.directory?(x) }
259
+ # directories that start with four digits
260
+ posts = posts.sort {|a, b| b.to_i <=> a.to_i } # sort descending
261
+ posts = posts[0..19] # return 20 at most
262
+ text = <<-HTML
263
+ <html>
264
+ <head><link rel="stylesheet" href="assets/blog.css"></head>
265
+ <body>
266
+ HTML
267
+ # posts = _find_recent_posts
268
+ wanted = [5, posts.size].min # estimate how many we want?
269
+ enum = posts.each
270
+ wanted.times do
271
+ postid = File.basename(enum.next)
272
+ postid = postid.to_i
273
+ text << teaser(postid) # side effect! calls _out
274
+ end
275
+ text << "</body></html>"
276
+ File.write(file, text) # FIXME ???
277
+ iframe_text = <<-HTML
278
+ <iframe style="width: 100vw;height: 100vh;position: relative;"
279
+ src='recent.html' width=100% frameborder="0" allowfullscreen>
280
+ </iframe>
281
+ HTML
282
+ # _out iframe_text # FIXME ??
283
+ end
284
+
213
285
  def create_new_post(title, testing = false, teaser: nil, body: nil, other_views: [])
214
286
  save = Dir.pwd
215
287
  Dir.chdir(self.view.dir)
@@ -309,25 +381,26 @@ class RuneBlog
309
381
  def generate_post(draft)
310
382
  views = _get_views(draft)
311
383
  views.each do |view|
312
- noext, viewdir, slugdir, aslug, theme = _copy_get_dirs(draft, view)
384
+ noext, viewdir, slugdir, aslug, @theme = _copy_get_dirs(draft, view)
385
+ staging = viewdir + "/staging"
313
386
  Dir.chdir(slugdir) do
314
- html = noext[5..-1] + ".html"
315
- system("livetext #{draft} >#{html}")
316
-
317
- Dir.mkdir("sidebar") unless Dir.exist?("sidebar")
318
- system("cp #{theme}/sidebar/*.lt3 ./sidebar/")
319
- files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3",
320
- "meta.lt3", "navbar.lt3", "blog-application.css"]
321
- files2 = files.map {|x| theme + "/" + x }
322
- files2.each do |f|
323
- system("cp #{f} .")
387
+ copy(draft, ".")
388
+ lt3 = draft.split("/")[-1]
389
+ # Remember: Some posts may be in more than one view -- careful with links back
390
+ # system("livetext #{draft} >staging/#{name}/index.html") # permalink?
391
+ # Structure is borked?
392
+ copy!("#{@theme}/*", "#{staging}")
393
+ copy(lt3, staging)
394
+ html = noext[5..-1]
395
+ Dir.chdir(staging) do
396
+ livetext draft, html
397
+ # link to POST??
398
+ copy html, "../remote"
399
+ collect_recent_posts("recent.html")
400
+ copy("recent.html", "../remote")
401
+ livetext "blog-generate", "../remote/index"
324
402
  end
325
-
326
- # system("livetext blog-generate.lt3 >bgen.html")
327
- # files.each {|fname| system("rm ./#{fname}") }
328
- # system("rm -rf ./sidebar/")
329
403
  end
330
- # create framed pure slug (where?)
331
404
  end
332
405
  end
333
406
 
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.1.81"
5
+ VERSION = "0.1.82"
6
6
 
7
7
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
8
8
  end
data/lib/view.rb CHANGED
@@ -25,7 +25,7 @@ class RuneBlog::View
25
25
  end
26
26
 
27
27
  def local_index
28
- dir + "/generated/index.html"
28
+ dir + "/remote/index.html"
29
29
  end
30
30
 
31
31
  def index
@@ -39,7 +39,7 @@ class RuneBlog::View
39
39
  def publishable_files
40
40
  vdir = dir()
41
41
  files = [local_index()]
42
- others = Dir.entries(vdir + "/generated").grep(/^\d\d\d\d/).map {|x| "#{vdir}/generated/#{x}" }
42
+ others = Dir.entries(vdir + "/remote").grep(/^\d\d\d\d/).map {|x| "#{vdir}/remote/#{x}" }
43
43
  abort "FIXME... publishable_files"
44
44
  deep_assets = Dir["#{vdir}/themes/standard/assets/*"]
45
45
  deep_assets.each do |file| # Do this at view creation
data/test/make_blog.rb CHANGED
@@ -19,7 +19,8 @@ def debug(str)
19
19
  end
20
20
 
21
21
  def make_post(x, title, teaser, body, views=[])
22
- STDERR.puts "\n========= make_post '#{title}'"
22
+ # STDERR.puts "\n========= make_post '#{title}'"
23
+ print "."
23
24
  meta = OpenStruct.new
24
25
  num = x.create_new_post(title, true, teaser: teaser, body: body, other_views: views)
25
26
  num
@@ -32,6 +33,10 @@ def show_lines(text)
32
33
  str
33
34
  end
34
35
 
36
+
37
+
38
+ puts
39
+
35
40
  system("rm -rf .blogs")
36
41
  RuneBlog.create_new_blog_repo('test_view', ".blogs/data")
37
42
  x = RuneBlog.new
@@ -61,36 +66,36 @@ EXCERPT
61
66
  Now, depending on what you consider "major," blah blah blah...
62
67
  BODY
63
68
 
64
- # x.change_view("computing") # 3 5 6
65
- #
66
- # make_post(x, "Elixir Conf coming up...", <<-EXCERPT, <<-BODY)
67
- # The next Elixir Conf is always coming up.
68
- # EXCERPT
69
- # I mean, unless the previous one was the last one ever, which I don't expect to
70
- # happen for a couple of decades.
71
- # BODY
72
- #
73
- # x.change_view("music") # 4 10
74
- #
75
- # make_post(x, "Does indie still matter?", <<-EXCERPT, <<-BODY)
76
- # Indie msic blah blah blah blah....
77
- # EXCERPT
78
- # And more about indie music.
79
- # BODY
80
- #
81
- # x.change_view("computing")
82
- #
83
- # make_post(x, "The genius of Scenic", <<-EXCERPT, <<-BODY)
84
- # Boyd Multerer is a genius.
85
- # EXCERPT
86
- # And so is Scenic.
87
- # BODY
88
- #
89
- # make_post(x, "The future of coding", <<-EXCERPT, <<-BODY)
90
- # Someday you can forget your text editor entirely.
91
- # EXCERPT
92
- # But that day hasn't come yet.
93
- # BODY
69
+ x.change_view("computing") # 3 5 6
70
+
71
+ make_post(x, "Elixir Conf coming up...", <<-EXCERPT, <<-BODY)
72
+ The next Elixir Conf is always coming up.
73
+ EXCERPT
74
+ I mean, unless the previous one was the last one ever, which I don't expect to
75
+ happen for a couple of decades.
76
+ BODY
77
+
78
+ x.change_view("music") # 4 10
79
+
80
+ make_post(x, "Does indie still matter?", <<-EXCERPT, <<-BODY)
81
+ Indie msic blah blah blah blah....
82
+ EXCERPT
83
+ And more about indie music.
84
+ BODY
85
+
86
+ x.change_view("computing")
87
+
88
+ make_post(x, "The genius of Scenic", <<-EXCERPT, <<-BODY)
89
+ Boyd Multerer is a genius.
90
+ EXCERPT
91
+ And so is Scenic.
92
+ BODY
93
+
94
+ make_post(x, "The future of coding", <<-EXCERPT, <<-BODY)
95
+ Someday you can forget your text editor entirely.
96
+ EXCERPT
97
+ But that day hasn't come yet.
98
+ BODY
94
99
 
95
100
  x.change_view("around_austin")
96
101
 
@@ -124,3 +129,4 @@ BODY
124
129
 
125
130
  x.change_view("around_austin")
126
131
 
132
+ puts
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.81
4
+ version: 0.1.82
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-08-21 00:00:00.000000000 Z
11
+ date: 2019-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext