runeblog 0.3.20 → 0.3.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -97,7 +97,6 @@ class RuneBlog
97
97
  def self.create_new_blog_repo(root_rel = ".blogs")
98
98
  log!(enter: __method__, args: [root_rel])
99
99
  check_nonempty_string(root_rel)
100
- self.blog = self # Weird. Like a singleton - dumbass circular dependency?
101
100
  repo_root = Dir.pwd/root_rel
102
101
  check_error(BlogRepoAlreadyExists) { Dir.exist?(repo_root) }
103
102
 
@@ -113,16 +112,17 @@ class RuneBlog
113
112
  end
114
113
  # copy_data(:extra, repo_root/:config)
115
114
  write_repo_config(root: repo_root)
116
- @blog = self.new
117
- @blog
115
+ # Weird. Like a singleton - dumbass circular dependency?
116
+ self.blog = blog = self.new
117
+ blog
118
118
  rescue => err
119
119
  puts "Can't create blog repo: '#{repo_root}' - #{err}"
120
120
  puts err.backtrace.join("\n")
121
121
  end
122
122
 
123
123
  def self.open(root_rel = ".blogs")
124
+ raise "Not impl"
124
125
  log!(enter: __method__, args: [root_rel])
125
- self.blog = self # Weird. Like a singleton - dumbass circular dependency?
126
126
  blog = self.new(root_rel)
127
127
  rescue => err
128
128
  _tmp_error(err)
@@ -130,10 +130,11 @@ class RuneBlog
130
130
 
131
131
  def initialize(root_rel = ".blogs") # always assumes existing blog
132
132
  log!(enter: "initialize", args: [root_rel])
133
- self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
133
+ # Weird. Like a singleton - dumbass circular dependency?
134
+ self.class.blog = self
134
135
 
135
136
  @root = Dir.pwd/root_rel
136
- write_repo_config(root: @root) # ?? FIXME
137
+ # write_repo_config(root: @root) # ?? FIXME
137
138
  get_repo_config
138
139
  read_features # top level
139
140
  @views = retrieve_views
@@ -146,6 +147,11 @@ class RuneBlog
146
147
  @sequence = get_sequence
147
148
  @post_views = []
148
149
  @post_tags = []
150
+ rescue => err
151
+ puts "Error - see stdout.txt"
152
+ STDERR.puts err.inspect
153
+ STDERR.puts err&.backtrace
154
+ sleep 3
149
155
  end
150
156
 
151
157
  def complete_file(name, vars, hash)
@@ -241,7 +247,7 @@ class RuneBlog
241
247
  create_dirs(dir)
242
248
  # FIXME dependencies?
243
249
  preprocess cwd: dir, src: @root/:drafts/sourcefile, dst: @root/:posts/sourcefile.sub(/.lt3/, ".html"), # ZZZ
244
- mix: "liveblog" # , debug: true
250
+ mix: "liveblog", vars: @view.globals # , debug: true
245
251
  _deploy_local(dir)
246
252
  rescue => err
247
253
  _tmp_error(err)
@@ -264,13 +270,13 @@ class RuneBlog
264
270
  views.any? {|x| x.name == name }
265
271
  end
266
272
 
267
- def view(name = nil)
268
- log!(enter: __method__, args: [name], level: 3)
269
- return @view if name.nil?
270
-
271
- check_nonempty_string(name)
272
- return str2view(name)
273
- end
273
+ # def view(name = nil)
274
+ # log!(enter: __method__, args: [name], level: 3)
275
+ # return @view if name.nil?
276
+ #
277
+ # check_nonempty_string(name)
278
+ # return str2view(name)
279
+ # end
274
280
 
275
281
  def str2view(str)
276
282
  log!(enter: __method__, args: [str], level: 3)
@@ -287,26 +293,28 @@ class RuneBlog
287
293
 
288
294
  def view=(arg)
289
295
  log!(enter: __method__, args: [arg], level: 2)
296
+ if arg == "[no view]"
297
+ @view = nil
298
+ return
299
+ end
300
+ # STDERR.puts "view= #{arg.inspect}"
301
+
290
302
  case arg
291
- when "[no view]"
292
- # puts "Warning: No current view set"
293
- @view = nil
294
303
  when RuneBlog::View
295
304
  @view = arg
296
- read_features(@view)
297
- @view.get_globals
298
- _set_publisher
305
+ @view.get_globals(true)
299
306
  when String
300
307
  new_view = str2view(arg)
301
- # puts "new_view = #{new_view} (#{new_view.class})"
308
+ # STDERR.puts "view= new view #{new_view.inspect}"
302
309
  check_error(NoSuchView, arg) { new_view.nil? }
303
310
  @view = new_view
304
- read_features(@view)
305
- @view.get_globals
306
- _set_publisher
307
311
  else
308
312
  raise CantAssignView(arg.class.to_s)
309
313
  end
314
+ read_features(@view)
315
+ @view.get_globals(true)
316
+ _set_publisher
317
+ File.write(@root/"data/VIEW", @view.to_s)
310
318
  rescue => err
311
319
  _tmp_error(err)
312
320
  end
@@ -327,7 +335,9 @@ class RuneBlog
327
335
  log!(enter: __method__, args: [v], level: 3)
328
336
  return @view if v.nil?
329
337
  check_nonempty_string(v)
330
- return @root/:views/v
338
+ dir = @root/:views/v
339
+ puts "Dir = #{dir}" # ; sleep 5
340
+ return dir
331
341
  end
332
342
 
333
343
  def self.exist?
@@ -375,8 +385,9 @@ class RuneBlog
375
385
  make_empty_view_tree(view_name)
376
386
  add_view(view_name)
377
387
  mark_last_published("Initial creation")
378
- system("cp #@root/data/global.lt3 #@root/views/#{view_name}/themes/standard/global.lt3")
379
- @view.get_globals
388
+ # system("cp #@root/data/global.lt3 #@root/views/#{view_name}/themes/standard/global.lt3")
389
+ system("cp #@root/data/global.lt3 #@root/views/#{view_name}/data/global.lt3")
390
+ @view.get_globals(true)
380
391
  rescue => err
381
392
  _tmp_error(err)
382
393
  end
@@ -408,7 +419,7 @@ class RuneBlog
408
419
  posts.select! {|x| File.directory?(x) }
409
420
 
410
421
  posts = posts.select {|x| File.basename(x).to_i == postid }
411
- postdir = exactly_one(posts)
422
+ postdir = exactly_one(posts, posts.join("/"))
412
423
  vp = RuneBlog::ViewPost.new(self.view, postdir)
413
424
  vp
414
425
  rescue => err
@@ -424,7 +435,7 @@ class RuneBlog
424
435
  depend = [post_entry_name]
425
436
  html = "/tmp/post_entry.html"
426
437
  preprocess src: post_entry_name, dst: html,
427
- call: ".nopara" # , deps: depend # , debug: true
438
+ call: ".nopara", vars: @view.globals # , deps: depend # , debug: true
428
439
  @_post_entry = File.read(html)
429
440
  vp = post_lookup(id)
430
441
  nslug, aslug, title, date, teaser_text =
@@ -566,15 +577,16 @@ class RuneBlog
566
577
  log!(enter: __method__, args: [view])
567
578
  vdir = @root/:views/view
568
579
  @theme = @root/:views/view/:themes/:standard
569
- depend = [vdir/"remote/etc/blog.css.lt3", @theme/"global.lt3",
580
+ @data = @root/:views/view/:data
581
+ depend = [vdir/"remote/etc/blog.css.lt3", @data/"global.lt3",
570
582
  @theme/"blog/head.lt3",
571
583
  # @theme/"navbar/navbar.lt3",
572
584
  @theme/"blog/index.lt3"] # FIXME what about assets?
573
585
  preprocess cwd: vdir/"themes/standard/etc", src: "blog.css.lt3",
574
- copy: vdir/"remote/etc/", call: [".nopara"], strip: true
586
+ copy: vdir/"remote/etc/", call: [".nopara"], strip: true , vars: @view.globals
575
587
  preprocess cwd: vdir/"themes/standard", deps: depend, force: true,
576
588
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html",
577
- call: ".nopara"
589
+ call: ".nopara" , vars: @view.globals
578
590
  copy!("#{vdir}/themes/standard/banner/*", "#{vdir}/remote/banner/") # includes navbar/
579
591
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
580
592
  # rebuild widgets?
@@ -588,7 +600,7 @@ class RuneBlog
588
600
  def _get_views(draft)
589
601
  log!(enter: __method__, args: [draft], level: 2)
590
602
  # FIXME dumb code
591
- view_line = exactly_one(File.readlines(draft).grep(/^.views /))
603
+ view_line = exactly_one(File.readlines(draft).grep(/^.views /), ".view line")
592
604
  views = view_line[7..-1].split
593
605
  views.uniq
594
606
  rescue => err
@@ -626,11 +638,14 @@ class RuneBlog
626
638
  title = meta.title
627
639
  tags = meta.tags
628
640
  # FIXME simplify
629
- addvar(hash, "post.num" => pnum, "post.aslug" => aslug,
630
- "post.date" => date, title: title.chomp,
631
- teaser: excerpt.chomp, longdate: longdate,
632
- "post.nslug" => pnum + "-" + aslug,
633
- "post.tags" => tags.join(" "))
641
+ addvar(hash, "post.num" => pnum,
642
+ "post.aslug" => aslug,
643
+ "post.date" => date,
644
+ title: title.chomp,
645
+ teaser: excerpt.chomp,
646
+ longdate: longdate,
647
+ "post.nslug" => pnum + "-" + aslug,
648
+ "post.tags" => tags.join(" "))
634
649
  end
635
650
  hash
636
651
  rescue => err
@@ -639,19 +654,25 @@ class RuneBlog
639
654
 
640
655
  def copy_widget_html(view)
641
656
  log!(enter: __method__, level: 2)
657
+ log! str: "=== cwh cp 1"
642
658
  vdir = @root/:views/view
643
659
  remote = vdir/:remote
644
660
  wdir = vdir/:widgets
645
661
  widgets = Dir[wdir/"*"].select {|w| File.directory?(w) }
662
+ log! str: "=== cwh cp 2"
646
663
  widgets.each do |w|
647
664
  dir = File.basename(w)
648
665
  rem = w.sub(/widgets/, "remote/widgets")
666
+ log! str: "=== cwh cp 3 w = #{w.inspect}"
649
667
  create_dirs(rem)
650
668
  files = Dir[w/"*"]
651
669
  # files = files.select {|x| x =~ /(html|css)$/ }
652
670
  tag = File.basename(w)
653
- files.each {|file| system!("cp #{file} #{rem}", show: (tag == "zzz")) }
671
+ log! str: "=== cwh cp 4 tag = #{tag.inspect}"
672
+ files.each {|file| system!("cp #{file} #{rem}", show: true) }
673
+ log! str: "=== cwh cp 5 tag was #{tag.inspect}"
654
674
  end
675
+ log! str: "=== cwh cp 6"
655
676
  rescue => err
656
677
  _tmp_error(err)
657
678
  end
@@ -667,25 +688,34 @@ class RuneBlog
667
688
  pdraft = @root/:posts/nslug
668
689
  remote = @root/:views/view_name/:remote
669
690
  @theme = @root/:views/view_name/:themes/:standard
691
+ pmeta = @root/:views/view_name/:posts/nslug
692
+
670
693
 
671
694
  create_dirs(pdraft) # Step 1...
695
+ @view.globals ||= {}
696
+ args = {cwd: pdraft, src: draft, debug: true, dst: "guts.html",
697
+ mix: "liveblog", vars: @view.globals}
672
698
  preprocess cwd: pdraft, src: draft, # FIXME dependencies?
673
- dst: "guts.html", mix: "liveblog"
699
+ debug: true,
700
+ dst: "guts.html", mix: "liveblog", vars: @view.globals
674
701
  hash = _post_metadata(draft, pdraft)
702
+ hash[:CurrentPost] = pmeta
675
703
  vposts = @root/:views/view_name/:posts # Step 2...
676
- puts "-- hpost:"
677
- hash.each_pair {|k,v| puts " #{k}: #{v}" if k.is_a? Symbol }
678
- puts
679
704
  copy!(pdraft, vposts) # ??
680
- copy(pdraft/"guts.html", @theme/:post) # Step 3...
681
- preprocess cwd: @theme/:post, src: "generate.lt3", # Step 4...
682
- force: true, vars: hash,
683
- dst: remote/ahtml, call: ".nopara"
705
+ copy(pdraft/"guts.html", vposts/nslug) # Step 3...
706
+ # Step 4...
707
+ preprocess cwd: pmeta, src: "../../themes/standard/post/generate.lt3",
708
+ force: true, vars: hash, debug: true,
709
+ dst: remote/ahtml, call: ".nopara"
684
710
  FileUtils.rm_f(remote/"published")
685
711
  timelog("Generated", remote/"history")
686
712
  copy_widget_html(view_name)
687
713
  rescue => err
688
- _tmp_error(err)
714
+ puts "Error - see stdout.txt"
715
+ STDERR.puts err.inspect
716
+ STDERR.puts err&.backtrace
717
+ # _tmp_error(err)
718
+ # puts err.backtrace.join("\n")
689
719
  end
690
720
 
691
721
  def _check_view?(view)
@@ -697,7 +727,9 @@ puts
697
727
  def generate_post(draft, force = false)
698
728
  log!(enter: __method__, args: [draft], level: 1)
699
729
  views = _get_views(draft)
700
- views.each {|view| _handle_post(draft, view) }
730
+ views.each do |view|
731
+ _handle_post(draft, view)
732
+ end
701
733
  # For current view:
702
734
  slug = File.basename(draft).sub(/.lt3$/, "")
703
735
  postdir = self.view.dir/"remote/post/"/slug
@@ -1,7 +1,7 @@
1
1
  if !defined?(RuneBlog::Path)
2
2
 
3
3
  class RuneBlog
4
- VERSION = "0.3.20"
4
+ VERSION = "0.3.25"
5
5
 
6
6
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
7
7
  Path = File.dirname(path)
@@ -13,17 +13,36 @@ class RuneBlog::View
13
13
  @name = name
14
14
  @publisher = RuneBlog::Publishing.new(name)
15
15
  @can_publish = true # FIXME
16
- @blog.view = self
16
+ # @blog.view = self # NOOOO??
17
17
  get_globals
18
18
  end
19
19
 
20
- def get_globals
21
- gfile = @blog.root/"views/#{name}/themes/standard/global.lt3"
20
+ def dump_globals_stderr
21
+ log!(enter: __method__, args: [list], level: 2)
22
+ list2 = list.select(&block)
23
+ STDERR.puts "-- globals = "
24
+ log!(str: "-- globals = ")
25
+ @globals.each_pair do |k, v|
26
+ msg = sprintf " %-10s %s\n", k, v if k.is_a? Symbol
27
+ STDERR.puts msg
28
+ log!(str: msg)
29
+ end
30
+ STDERR.puts
31
+ log!(str: "")
32
+ end
33
+
34
+ def get_globals(force = false)
35
+ return if @globals && !force
36
+ # gfile = @blog.root/"views/#@name/themes/standard/global.lt3"
37
+ gfile = @blog.root/"views/#@name/data/global.lt3"
22
38
  return unless File.exist?(gfile) # Hackish!! how is View.new called from create_view??
23
39
 
24
40
  live = Livetext.customize(call: ".nopara")
25
41
  live.xform_file(gfile)
42
+ live._setvar("ViewDir", @blog.root/:views/@name)
43
+ live._setvar("View", @name)
26
44
  @globals = live.vars
45
+ # dump_globals_stderr
27
46
  end
28
47
 
29
48
  def dir
@@ -8,6 +8,7 @@ require "runeblog_version"
8
8
  Gem.post_install do |spec|
9
9
  Dir.chdir(RuneBlog::Path)
10
10
  system("livetext -i liveblog.rb")
11
+ system("livetext -i code_rouge.rb")
11
12
  end
12
13
 
13
14
  spec = Gem::Specification.new do |s|
@@ -20,8 +21,9 @@ spec = Gem::Specification.new do |s|
20
21
  s.authors = ["Hal Fulton"]
21
22
  s.email = 'rubyhacker@gmail.com'
22
23
  s.executables << "blog"
23
- s.add_runtime_dependency 'livetext', '~> 0.9', '>= 0.9.04'
24
- s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.22'
24
+ s.add_runtime_dependency 'livetext', '~> 0.9', '>= 0.9.10'
25
+ s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.23'
26
+ s.add_runtime_dependency 'rouge', '~> 3.25', '>= 3.25.0'
25
27
 
26
28
  s.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.0'
27
29
 
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.3.20
4
+ version: 0.3.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-11 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.9'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.9.04
22
+ version: 0.9.10
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.9'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.9.04
32
+ version: 0.9.10
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rubytext
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.1.22
42
+ version: 0.1.23
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,27 @@ dependencies:
49
49
  version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.1.22
52
+ version: 0.1.23
53
+ - !ruby/object:Gem::Dependency
54
+ name: rouge
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 3.25.0
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.25'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.25.0
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '3.25'
53
73
  - !ruby/object:Gem::Dependency
54
74
  name: minitest
55
75
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +129,7 @@ files:
109
129
  - empty_view/config/twitter/tw.html
110
130
  - empty_view/config/twitter/tw.js
111
131
  - empty_view/config/twitter/twitter.rb
132
+ - empty_view/data/GIT_IS_DUMB
112
133
  - empty_view/posts/GIT_IS_DUMB
113
134
  - empty_view/remote/assets/GIT_IS_DUMB
114
135
  - empty_view/remote/banner/navbar/GIT_IS_DUMB
@@ -235,8 +256,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
256
  - !ruby/object:Gem::Version
236
257
  version: '0'
237
258
  requirements: []
238
- rubygems_version: 3.0.4
239
- signing_key:
259
+ rubygems_version: 3.0.8
260
+ signing_key:
240
261
  specification_version: 4
241
262
  summary: A command-line blogging system
242
263
  test_files: []