runeblog 0.1.78 → 0.1.79

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: 7e483b3ec658dfbb130d8b2b090107155af6c5371066949ae9d78bf8b4851525
4
- data.tar.gz: 91ae3aebfefc68e69ddea4aa9cb700a28a572a422f41b9c010b570271069c22e
3
+ metadata.gz: 6add0a9ef9437be9e4f41ee88ac0a067cc13a9120c73a4403a2a23d471f1034d
4
+ data.tar.gz: ec7b79a7c68f46b57e367043aff7db3524d88e8fd593ccd9a699ca1071ff83c0
5
5
  SHA512:
6
- metadata.gz: bd0a51b5eef53f86f738e51dca6428bf2eefa6373912e023c61819aadef977b30f4e7735d0a3a183944f4071c136d797ba6f32f06e327e663bd75ba84db4efe2
7
- data.tar.gz: a531739bb62e383d4e660a7f9e630a786934d739badfd179359d63392f23f5486c62b6f53922169b0ee12c319da71edad2fb7ec7839497fa2c3121be4d2bcf6c
6
+ metadata.gz: 2301c17418d3d5f1cb076e36d9b6583b8388f82f6c142ac67b4d2f88110dcd46c3d79f344bf59a0e3dd0858fbbf35d3469f6a7ab0ad11d587b5cd142c61eb124
7
+ data.tar.gz: e96e4521ecb8f542a58164ac20f2cac17b51113cd3096258a45124b05ad1a79e29f6059eabe154c1ae4576ece2bda8f51f50c5c3368740f5728fd137a0a50e03
data/bin/blog CHANGED
@@ -9,6 +9,9 @@ require 'repl'
9
9
 
10
10
  include RuneBlog::REPL
11
11
 
12
+ errfile = File.new("stderr.out", "w")
13
+ STDERR.reopen(errfile)
14
+
12
15
  def get_started
13
16
  puts
14
17
  puts fx(<<-TEXT, :bold)
Binary file
@@ -5,6 +5,9 @@ require 'date'
5
5
  require 'livetext'
6
6
  require 'runeblog'
7
7
 
8
+ errfile = File.new("liveblog.out", "w")
9
+ STDERR.reopen(errfile)
10
+
8
11
  # ::Home = Dir.pwd unless defined?(::Home)
9
12
 
10
13
  =begin
@@ -288,6 +291,7 @@ def finalize
288
291
  @slug = @blog.make_slug(@meta)
289
292
  slug_dir = @slug
290
293
  @postdir = @blog.view.dir + "/posts/#{slug_dir}"
294
+ STDERR.puts "Got here!"
291
295
  write_post
292
296
  @meta
293
297
  end
@@ -359,7 +363,7 @@ def head
359
363
  "linkc" => %[<link rel="canonical" href="#{_var(:host)}">],
360
364
  "og:url" => %[<meta property="og:url" content="#{_var(:host)}">],
361
365
  "og:site_name" => %[<meta property="og:site_name" content="#{_var(:title)}">],
362
- "style" => %[<link rel="stylesheet" href="../assets/application.css">],
366
+ "style" => %[<link rel="stylesheet" href="blog-application.css">],
363
367
  "feed" => %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}/feed.xml" title="#{_var(:title)}">],
364
368
  "favicon" => %[<link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">\n <link rel="apple-touch-icon" href="../assets/favicon.ico">]
365
369
  }
@@ -418,10 +422,12 @@ def main # side-effect
418
422
  STDERR.puts "--- inside #main: which = #{which.inspect}"
419
423
  case which
420
424
  when "recent_posts"
421
- all_teasers # FIXME does nothing yet
422
- when "post"
423
- self.data = "post-index.lt3"
424
- _include
425
+ all_teasers
426
+ when "post" # FIXME!!!
427
+ # _out "<iframe src='./0001-whats-at-stubbs/whats-at-stubbs.html'><iframe>"
428
+ _out %[<iframe style="width: 100vw;height: 100vh;position: relative;" src='whats-at-stubbs.html' width=100% frameborder="0" allowfullscreen></iframe>]
429
+ # self.data = "post-index.lt3"
430
+ # _include
425
431
  end
426
432
  _out %[</div>]
427
433
  end
@@ -499,26 +505,26 @@ STDERR.puts "-- inside #all_teasers..."
499
505
  close = <<-HTML
500
506
  </section>
501
507
  HTML
502
- STDERR.puts "=== at01"
503
- _out open
504
- # FIXME: Now do the magic...
505
- STDERR.puts "=== at02"
508
+
509
+ text = <<-HTML
510
+ <html>
511
+ <head><link rel="stylesheet" href="blog-application.css"></head>
512
+ <body>
513
+ HTML
514
+ # _out open
506
515
  posts = _find_recent_posts
507
- STDERR.puts "=== at03"
508
516
  wanted = [5, posts.size].min # estimate how many we want?
509
- STDERR.puts "=== at04"
510
517
  enum = posts.each
511
- STDERR.puts "=== at05"
512
518
  wanted.times do
513
- STDERR.puts "=== at06 (loop)"
514
519
  postid = File.basename(enum.next)
515
- STDERR.puts "=== at07"
516
520
  postid = postid.to_i
517
- STDERR.puts "=== at08"
518
- _teaser(postid)
519
- STDERR.puts "=== at09"
521
+ text << _teaser(postid) # side effect! calls _out
520
522
  end
521
- _out close
523
+ text << "</body></html>"
524
+ File.write("recent.html", text)
525
+ # _out close
526
+ # _out "<iframe src='./recent.html'><iframe>"
527
+ _out %[<iframe style="width: 100vw;height: 100vh;position: relative;" src='recent.html' width=100% frameborder="0" allowfullscreen></iframe>]
522
528
  end
523
529
 
524
530
  def _post_lookup(postid) # side-effect
@@ -532,15 +538,8 @@ def _post_lookup(postid) # side-effect
532
538
  post = posts.select {|x| File.basename(x).to_i == postid }
533
539
  raise "Error: More than one post #{postid}" if post.size > 1
534
540
  postdir = post.first
535
- fname = "#{postdir}/teaser.txt"
536
- teaser_text = File.read(fname).chomp
537
- # FIXME dumb hacks...
538
- mdfile = "#{postdir}/metadata.txt"
539
- lines = File.readlines(mdfile)
540
- title = lines.grep(/title:/).first[7..-1].chomp
541
- date = lines.grep(/pubdate:/).first[9..-1].chomp
542
- slug = postdir
543
- [slug, title, date, teaser_text]
541
+ vp = RuneBlog::ViewPost.new(@blog.view, postdir)
542
+ vp
544
543
  end
545
544
 
546
545
  def _interpolate(str, context) # FIXME move this later
@@ -553,15 +552,19 @@ def _teaser(slug)
553
552
  text = nil
554
553
  post_entry_name = @theme + "blog-_postentry.lt3"
555
554
  @_post_entry ||= File.read(post_entry_name)
556
- slug = title = date = teaser_text = nil
557
- slug, title, date, teaser_text = _post_lookup(id)
558
- # vdir = File.expand_path("../../..")
559
- url = "#@vdir/#{slug}.html"
555
+ vp = _post_lookup(id)
556
+ nslug, aslug, title, date, teaser_text =
557
+ vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text
558
+ path = vp.path
559
+ STDERR.puts [">>>>> vp = ", vp].inspect
560
+ url = "#{path}/#{aslug}.html" # Should be relative to .blogs!! FIXME
561
+ STDERR.puts [slug, url].inspect
560
562
  date = Date.parse(date)
561
563
  date = date.strftime("%B %e<br>%Y")
562
564
  text = _interpolate(@_post_entry, binding)
563
565
  # File.write("../../../generated/#{slug}.html", text)
564
- _out text
566
+ # _out text
567
+ text
565
568
  end
566
569
 
567
570
  def card_iframe
@@ -134,5 +134,24 @@ STDERR.puts "--- cmd = #{cmd}\n "
134
134
  p err
135
135
  puts err.backtrace.join("\n")
136
136
  end
137
+ end
137
138
 
139
+ class RuneBlog::ViewPost
140
+ attr_reader :path, :nslug, :aslug, :title, :date,
141
+ :teaser_text
142
+ def initialize(view, postdir)
143
+ # Assumes already parsed/processed
144
+ @blog = RuneBlog.blog || raise(NoBlogAccessor)
145
+ @path = postdir.dup
146
+ @nslug = @path.split("/").last
147
+ @aslug = @nslug[5..-1]
148
+ fname = "#{postdir}/teaser.txt"
149
+ @teaser_text = File.read(fname).chomp
150
+ # FIXME dumb hacks...
151
+ mdfile = "#{postdir}/metadata.txt"
152
+ lines = File.readlines(mdfile)
153
+ @title = lines.grep(/title:/).first[7..-1].chomp
154
+ @date = lines.grep(/pubdate:/).first[9..-1].chomp
155
+ end
138
156
  end
157
+
@@ -233,7 +233,8 @@ module RuneBlog::REPL
233
233
  # Simplify this
234
234
  tag = "#{'%04d' % id}"
235
235
  files = Find.find(@blog.root+"/drafts").to_a
236
- files = files.grep(/#{tag}-/)
236
+ p files
237
+ files = files.grep(/#{tag}-.*lt3/)
237
238
  files = files.map {|f| File.basename(f) }
238
239
  if files.size > 1
239
240
  msg = "Multiple files: #{files}"
@@ -1,4 +1,4 @@
1
- require 'find'
1
+ #equire 'find'
2
2
  require 'livetext'
3
3
 
4
4
  require 'runeblog_version'
@@ -223,9 +223,13 @@ class RuneBlog
223
223
  Dir.chdir(self.view.dir)
224
224
  # change to create_draft ?
225
225
  post = Post.create(title: title, teaser: teaser, body: body, other_views: other_views)
226
+ puts "cnp: num = #{post.meta.num}"
226
227
  post.edit unless testing
227
- meta = post.build
228
+ post.build
229
+ meta = post.meta
228
230
  Dir.chdir(save)
231
+ puts "cnp: title = #{title.inspect}\n meta = #{meta.inspect}"
232
+ meta.num ||= 999
229
233
  return meta.num
230
234
  Dir.chdir(save)
231
235
  meta.num = 999
@@ -297,6 +301,16 @@ return meta.num
297
301
  def generate_view(view)
298
302
  end
299
303
 
304
+ def _get_views(draft)
305
+ # FIXME dumb code
306
+ view_line = File.readlines(draft).grep(/^.views /)
307
+ raise "More than one .views call!" if view_line.size > 1
308
+ raise "No .views call!" if view_line.size < 1
309
+ # STDERR.puts view_line.inspect
310
+ view_line = view_line.first
311
+ views = view_line[7..-1].split
312
+ end
313
+
300
314
  # Remember: A post in multiple views will trigger multiple
301
315
  # views needing to be rebuilt (and published)
302
316
 
@@ -313,7 +327,45 @@ return meta.num
313
327
  # livetext ??/recent.lt3 >VIEW/working/recent.html
314
328
  # livetext VIEW/blog/generate.lt3 ??
315
329
 
330
+ def _copy_get_dirs(draft, view)
331
+ fname = File.basename(draft)
332
+ noext = fname.sub(/.lt3$/, "")
333
+ vdir = "#@root/views/#{view}"
334
+ dir = "#{vdir}/posts/#{noext}/"
335
+ Dir.mkdir(dir) unless Dir.exist?(dir)
336
+ system("cp #{draft} #{dir}")
337
+ viewdir, slugdir, aslug = vdir, dir, noext[5..-1]
338
+ theme = viewdir + "/themes/standard"
339
+ [noext, viewdir, slugdir, aslug, theme]
340
+ end
341
+
316
342
  def generate_post(draft)
343
+ views = _get_views(draft)
344
+ views.each do |view|
345
+ noext, viewdir, slugdir, aslug, theme = _copy_get_dirs(draft, view)
346
+ Dir.chdir(slugdir) do
347
+ html = noext[5..-1] + ".html"
348
+ STDERR.puts "--- NEW gp into #{slugdir}: livetext #{draft} >#{html}"
349
+ system("livetext #{draft} >#{html}")
350
+
351
+ Dir.mkdir("sidebar") unless Dir.exist?("sidebar")
352
+ system("cp #{theme}/sidebar/*.lt3 ./sidebar/")
353
+ files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3",
354
+ "meta.lt3", "navbar.lt3"]
355
+ files2 = files.map {|x| theme + "/" + x }
356
+ files2.each do |f|
357
+ system("cp #{f} .")
358
+ end
359
+
360
+ # system("livetext blog-generate.lt3 >bgen.html")
361
+ # files.each {|fname| system("rm ./#{fname}") }
362
+ # system("rm -rf ./sidebar/")
363
+ end
364
+ # create framed pure slug (where?)
365
+ end
366
+ end
367
+
368
+ def old_generate_post(draft)
317
369
  dir = File.dirname(draft)
318
370
  fname = File.basename(draft)
319
371
  # STDERR.puts "--- gp01 dir/fname = #{dir} #{fname}"
@@ -323,37 +375,36 @@ return meta.num
323
375
  raise "No .views call!" if view_line.size < 1
324
376
  view_line = view_line.first
325
377
 
326
- # STDERR.puts "--- gp01b view_line = #{view_line}"
327
378
  views = view_line[7..-1].split
328
379
  slug_dir = fname.sub(/.lt3$/, "")
329
- # STDERR.puts "--- gp02 preloop"
330
380
  views.each do |view|
331
- # STDERR.puts "--- gp03 view = #{view}"
332
381
  vdir = "#@root/views/#{view}"
333
382
  dir = "#{vdir}/posts/#{slug_dir}/"
334
- STDERR.puts "--- gp03b vdir = #{vdir} dir = #{dir}"
335
383
  Dir.mkdir(dir) unless Dir.exist?(dir)
336
- puts
337
- # --- gp04 system: cp /Users/Hal/Dropbox/files/runeblog/.blogs/data/drafts/0007-the-graffiti-wall.lt3
338
- # /Users/Hal/Dropbox/files/runeblog/.blogs/data/around_austin/posts/0007-the-graffiti-wall.lt3/
339
- STDERR.puts "--- gp04 system: cp #{draft} #{dir}"
340
- STDERR.puts
341
384
  system("cp #{draft} #{dir}")
342
385
  Dir.chdir(dir) do
343
- STDERR.puts "--- gp05 into #{dir}: livetext #{draft} >#{draft}.html"
344
- system("livetext #{draft} >#{draft}.html")
386
+ html = draft.sub(/.lt3$/, ".html")
387
+ STDERR.puts "--- gp05 into #{dir}: livetext #{draft} >#{html}"
388
+ system("livetext #{draft} >#{html}")
389
+
345
390
  # copy from theme?
346
391
  theme = vdir + "/themes/standard"
347
- files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3", "meta.lt3", "navbar.lt3"]
348
- files = files.map {|x| theme + "/" + x }
349
- STDERR.puts "---- Files = #{files.inspect}"
350
- files.each do |f|
351
- STDERR.puts "---- cp #{f} ."
392
+ Dir.mkdir("sidebar") unless Dir.exist?("sidebar")
393
+ system("cp #{theme}/sidebar/*.lt3 ./sidebar/")
394
+ files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3",
395
+ "meta.lt3", "navbar.lt3"]
396
+ files2 = files.map {|x| theme + "/" + x }
397
+ # STDERR.puts "---- gp06: In #{Dir.pwd}: files = #{files.inspect}"
398
+ files2.each do |f|
399
+ # STDERR.puts "---- gp07: cp #{f} ."
352
400
  system("cp #{f} .")
353
401
  end
354
- STDERR.puts "---- Files copied from theme"
402
+ # STDERR.puts "---- gp08: Files copied from theme"
403
+
355
404
  system("livetext blog-generate.lt3 >bgen.html")
356
- STDERR.puts "---- Files went thru livetext"
405
+ # STDERR.puts "---- gp09: Files went thru livetext"
406
+ # files.each {|fname| system("rm ./#{fname}") }
407
+ # system("rm -rf ./sidebar/")
357
408
  end
358
409
  # create framed pure slug (where?)
359
410
  end
@@ -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.78"
5
+ VERSION = "0.1.79"
6
6
 
7
7
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
8
8
  end
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.78
4
+ version: 0.1.79
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-06 00:00:00.000000000 Z
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext