runeblog 0.2.69 → 0.2.74

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: cac83d9c4f6850081ed2e007400c08c0a45e0515384e1eab36deb24ff8f269f1
4
- data.tar.gz: 77164031eeee9f02d96d8b966831c4e04544def4973affad48b3f1f43acd702f
3
+ metadata.gz: a66a7e9938f682fe72d0a6f693cad408fffbeb93f34da1f91732548d879211cf
4
+ data.tar.gz: c2beeb6b86e7d08926bca781d6adca2560f7413501319295abf23a194ee6e039
5
5
  SHA512:
6
- metadata.gz: 292cdd9ee19c4b7c290c0a41a7c2966758f3f89fdd0453ec8e58a827501d95b2761491f9799a0f009ae1a0ef99ac78e489ded615bc496121919ecfd613184737
7
- data.tar.gz: 4128e54f173bc9edb46dea6ca62abb815bb1c4e50320879517f7e01d8ec1e1579d439431bcbc183d0bfdd6e627a025f7b2b2bd27f7819ca06e7ff725eae1dba1
6
+ metadata.gz: dd1d9d4a194f2f28683e20fbf027b87f3f27e4ced5c16e21c1e7e292dceacc75f87f718b6abe018e46e37c3645c32c107e3e24a4e1c5fb14aa5c38925198dbb1
7
+ data.tar.gz: 2d4ce56d3dd5d97b168692d984706ac941fa6f5a3daf3f227dfd42023ae1c7a5c734692eed321e8752eb4eca601809c5e5d350ff58851be6cb12feca84ec933a
data/bin/blog CHANGED
@@ -94,7 +94,7 @@ STDERR.reopen(errfile)
94
94
 
95
95
  # read a .rubytext file here?? Call it something else?
96
96
  home = ENV['HOME']
97
- @fg, @bg = try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
97
+ @fg, @bg = Blue, White ## FIXME!! try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
98
98
  @fg = @fg.downcase.to_sym
99
99
  @bg = @bg.downcase.to_sym
100
100
 
@@ -0,0 +1 @@
1
+ /usr/local/bin/vim
@@ -0,0 +1 @@
1
+ /FULL/PATH/.blogs
@@ -0,0 +1 @@
1
+ [no view]
@@ -39,6 +39,7 @@ def system!(str, show: false)
39
39
  else
40
40
  STDERR.puts "FAILED: #{str.inspect}"
41
41
  STDERR.puts "\ncaller = \n#{caller.join("\n ")}\n"
42
+ exit
42
43
  return rc
43
44
  end
44
45
  rc
@@ -19,6 +19,25 @@ module RuneBlog::Helpers
19
19
  puts " Failed: #{cmd} - from #{caller[0]}" unless rc
20
20
  end
21
21
 
22
+ def get_repo_config
23
+ log!(enter: __method__, level: 3)
24
+ @editor = File.read("#@root/data/EDITOR").chomp
25
+ @current_view = File.read("#@root/data/VIEW").chomp
26
+ @root = File.read("#@root/data/ROOT").chomp
27
+ rescue => err
28
+ STDERR.puts "Can't read config: #{err}"
29
+ STDERR.puts err.backtrace.join("\n")
30
+ STDERR.puts "dir = #{Dir.pwd}"
31
+ end
32
+
33
+ def copy_data(tag, dest)
34
+ data = RuneBlog::Path + "/../data" # files kept inside gem
35
+ case tag
36
+ when :config; files = %w[ROOT VIEW EDITOR]
37
+ end
38
+ files.each {|file| copy(data + "/" + file, dest) }
39
+ end
40
+
22
41
  def read_config(file, *syms)
23
42
  log!(enter: __method__, args: [file, *syms], level: 3)
24
43
  lines = File.readlines(file).map(&:chomp)
@@ -65,12 +84,19 @@ module RuneBlog::Helpers
65
84
  dirs.map {|name| RuneBlog::View.new(name) }
66
85
  end
67
86
 
87
+ def write_repo_config(root: "#{Dir.pwd}/.blogs", view: "[no view]", editor: "/usr/local/bin/vim")
88
+ File.write(root + "/data/ROOT", root + "\n")
89
+ File.write(root + "/data/VIEW", view.to_s + "\n")
90
+ File.write(root + "/data/EDITOR", editor + "\n")
91
+ end
92
+
68
93
  def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
69
94
  log!(enter: __method__, args: [root, current_view, editor], level: 3)
70
- root = Dir.pwd/root
95
+ root = Dir.pwd + "/" + root
71
96
  x = OpenStruct.new
72
97
  x.root, x.current_view, x.editor = root, current_view, editor
73
- write_config(x, root/RuneBlog::ConfigFile)
98
+ write_config(x, root + "/" + RuneBlog::ConfigFile)
99
+ write_repo_config
74
100
  end
75
101
 
76
102
  def new_sequence
@@ -9,11 +9,9 @@ require 'xlate'
9
9
 
10
10
 
11
11
  def init_liveblog # FIXME - a lot of this logic sucks
12
- here = Dir.pwd
13
- dir = here
14
- loop { dir = Dir.pwd; break if File.exist?("config"); Dir.chdir("..") }
15
- Dir.chdir(here) # here??? or dir??
16
- @blog = RuneBlog.new(dir)
12
+ dir = Dir.pwd.sub(/\.blogs.*/, "")
13
+ @blog = nil
14
+ Dir.chdir(dir) { @blog = RuneBlog.new }
17
15
  @root = @blog.root
18
16
  @view = @blog.view
19
17
  @view_name = @blog.view.name unless @view.nil?
@@ -118,7 +116,6 @@ def banner
118
116
  str2 << " <td colspan=#{span}><img src=#{image} #{width} height=#{high}></img></td>" + "\n"
119
117
  when "svg_title"
120
118
  stuff, hash = _svg_title(*data)
121
- STDERR.puts hash.inspect
122
119
  wide = hash["width"]
123
120
  str2 << " <td colspan=#{span} width=#{wide}>#{stuff}</td>" + "\n"
124
121
  when "text"
@@ -748,7 +745,7 @@ def navbar
748
745
  end
749
746
 
750
747
  def _make_navbar(orient = :horiz)
751
- vdir = @blog.view.dir
748
+ vdir = @root/:views/@blog.view
752
749
  title = _var(:blog)
753
750
 
754
751
  extra = ""
@@ -255,7 +255,7 @@ module RuneBlog::REPL
255
255
  return @out
256
256
  else
257
257
  if @blog.view?(arg)
258
- @blog.view = arg # reads config
258
+ @blog.view = arg
259
259
  output "View: " + @blog.view.name.to_s
260
260
  puts "\n ", fx(arg, :bold), "\n" unless testing
261
261
  end
@@ -53,61 +53,48 @@ class RuneBlog
53
53
  puts "Error: See #{out}"
54
54
  end
55
55
 
56
- def self.create_new_blog_repo(dir = ".blogs")
57
- log!(enter: __method__, args: [dir])
58
- raise ArgumentError unless dir.is_a?(String) && ! dir.empty?
59
- root_dir = Dir.pwd/dir
60
- self.create(dir)
61
- rescue => err
62
- puts "Can't create blog repo: '#{dir}' - #{err}"
63
- puts err.backtrace.join("\n")
64
- end
65
-
66
- def self.create(root = ".blogs")
67
- log!(enter: __method__, args: [root], level: 1)
68
- # Crude - FIXME later - # What views are there? Publishing, etc.
56
+ def self.create_new_blog_repo(root_rel = ".blogs")
57
+ log!(enter: __method__, args: [root_rel])
58
+ raise ArgumentError unless root_rel.is_a?(String) && ! root_rel.empty?
69
59
  self.blog = self # Weird. Like a singleton - dumbass circular dependency?
70
- root = Dir.pwd/root
71
- raise BlogRepoAlreadyExists if Dir.exist?(root)
72
- create_dirs(root)
73
- Dir.chdir(root) do
74
- create_dirs(:drafts, :views, :posts)
60
+ repo_root = Dir.pwd/root_rel
61
+ raise BlogRepoAlreadyExists if Dir.exist?(repo_root)
62
+ create_dirs(repo_root)
63
+ Dir.chdir(repo_root) do
64
+ create_dirs(:data, :drafts, :views, :posts)
75
65
  new_sequence
76
66
  end
77
- x = OpenStruct.new
78
- x.root, x.current_view, x.editor = root, "test_view", "/usr/bin/vim " # dumb - FIXME later
79
- write_config(x, root/ConfigFile)
80
- @blog = self.new(root)
67
+ copy_data(:config, repo_root/:data)
68
+ write_repo_config(root: repo_root)
69
+ @blog = self.new
81
70
  @blog
82
71
  rescue => err
83
- _tmp_error(err)
72
+ puts "Can't create blog repo: '#{repo_root}' - #{err}"
73
+ puts err.backtrace.join("\n")
84
74
  end
85
75
 
86
- def self.open(root = ".blogs")
87
- log!(enter: __method__, args: [root])
88
- # Crude - FIXME later - # What views are there? Publishing, etc.
76
+ def self.open(root_rel = ".blogs")
77
+ log!(enter: __method__, args: [root_rel])
89
78
  self.blog = self # Weird. Like a singleton - dumbass circular dependency?
90
- root = Dir.pwd/root
91
- blog = self.new(root)
79
+ blog = self.new(root_rel)
92
80
  rescue => err
93
81
  _tmp_error(err)
94
82
  end
95
83
 
96
- def initialize(root_dir = ".blogs") # always assumes existing blog
97
- log!(enter: "initialize", args: [root_dir])
98
- # Crude - FIXME later - # What views are there? Publishing, etc.
84
+ def initialize(root_rel = ".blogs") # always assumes existing blog
85
+ log!(enter: "initialize", args: [root_rel])
99
86
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
100
87
 
101
- @root = root_dir
102
- file = @root/ConfigFile
103
- errmsg = "No config file! file = #{file.inspect} dir = #{Dir.pwd}"
104
- raise errmsg unless File.exist?(file)
105
-
106
- @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
107
- md = Dir.pwd.match(%r[.*/views/(.*?)/])
108
- @view_name = md[1] if md
88
+ @root = Dir.pwd/root_rel
89
+ copy_data(:config, @root/:data)
90
+ write_repo_config(root: @root)
91
+ get_repo_config
109
92
  @views = get_views
110
- @view = str2view(@view_name)
93
+ md = Dir.pwd.match(%r[.*/views/(.*?)/])
94
+ if md
95
+ @view_name = md[1]
96
+ @view = str2view(@view_name)
97
+ end
111
98
  @sequence = get_sequence
112
99
  @post_views = []
113
100
  @post_tags = []
@@ -234,15 +221,15 @@ class RuneBlog
234
221
 
235
222
  def viewdir(v = nil) # delete?
236
223
  log!(enter: __method__, args: [v], level: 3)
224
+ v ||= @view
237
225
  v = str2view(v) if v.is_a?(String)
238
226
  raise ArgumentError unless v.nil? || v.is_a?(RuneBlog::View)
239
- v ||= @view
240
227
  return @root/:views/v
241
228
  end
242
229
 
243
230
  def self.exist?
244
231
  log!(enter: __method__, level: 3)
245
- Dir.exist?(DotDir) && File.exist?(DotDir/ConfigFile)
232
+ Dir.exist?(DotDir)
246
233
  end
247
234
 
248
235
  def mark_last_published(str)
@@ -253,7 +240,8 @@ class RuneBlog
253
240
  def add_view(view_name)
254
241
  log!(enter: __method__, args: [view_name], level: 2)
255
242
  view = RuneBlog::View.new(view_name)
256
- @view = view # current view
243
+ self.view = view # current view
244
+ File.write(@root/"data/VIEW", view_name)
257
245
  @views << view # all views
258
246
  view
259
247
  end
@@ -282,7 +270,6 @@ class RuneBlog
282
270
 
283
271
  def create_view(view_name)
284
272
  log!(enter: __method__, args: [view_name], level: 2)
285
- check_valid_new_view(view_name)
286
273
  make_empty_view_tree(view_name)
287
274
  add_view(view_name)
288
275
  mark_last_published("Initial creation")
@@ -331,11 +318,8 @@ class RuneBlog
331
318
  text = nil
332
319
  @theme = @view.dir/"themes/standard"
333
320
  post_entry_name = @theme/"blog/post_entry.lt3"
334
- # STDERR.puts "-- @pename = #{post_entry_name}"
335
- # STDERR.puts "-- @pe = #{@_post_entry.inspect}"
336
321
  depend = [post_entry_name]
337
322
  xlate src: post_entry_name, dst: "/tmp/post_entry.html" # , deps: depend # , debug: true
338
- # STDERR.puts "-- xlate result: #{`ls -l /tmp/post_entry.html`}"
339
323
  @_post_entry ||= File.read("/tmp/post_entry.html")
340
324
  vp = post_lookup(id)
341
325
  nslug, aslug, title, date, teaser_text =
@@ -428,9 +412,8 @@ class RuneBlog
428
412
  def change_view(view)
429
413
  log!(enter: __method__, args: [view], level: 3)
430
414
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
431
- x = OpenStruct.new
432
- x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
433
- write_config(x, @root/ConfigFile)
415
+ File.write(@root/"data/VIEW", view)
416
+ # write_repo_config
434
417
  self.view = view # error checking?
435
418
  end
436
419
 
@@ -453,13 +436,15 @@ class RuneBlog
453
436
  # @theme/"navbar/navbar.lt3",
454
437
  @theme/"blog/index.lt3"] # FIXME what about assets?
455
438
  xlate cwd: vdir/"themes/standard/etc", deps: depend,
456
- src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
439
+ src: "blog.css.lt3", copy: vdir/"remote/etc/" # , debug: true
457
440
  xlate cwd: vdir/"themes/standard", deps: depend, force: true,
458
441
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
459
442
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
460
443
  copy_widget_html(view)
461
444
  rescue => err
462
- _tmp_error(err)
445
+ STDERR.puts err
446
+ STDERR.puts err.backtrace.join("\n")
447
+ # _tmp_error(err)
463
448
  end
464
449
 
465
450
  def _get_views(draft)
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.2.69"
5
+ VERSION = "0.2.74"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -14,6 +14,7 @@ class RuneBlog::View
14
14
  @name = name
15
15
  @publisher = RuneBlog::Publishing.new(name)
16
16
  @can_publish = true # FIXME
17
+ @blog.view = self
17
18
  end
18
19
 
19
20
  def dir
@@ -45,7 +45,7 @@ def xlate(cwd: Dir.pwd, src:,
45
45
  dst: (strip = true; File.basename(src).sub(/.lt3$/,"")),
46
46
  deps: [], copy: nil, debug: false, force: false)
47
47
  src += LEXT unless src.end_with?(LEXT)
48
- dst += ".html" unless (dst.end_with?(".html")) # || strip)
48
+ dst += ".html" unless (dst.end_with?(".html") || strip)
49
49
  indent = " "*12
50
50
  Dir.chdir(cwd) do
51
51
  if debug
@@ -28,11 +28,12 @@ spec = Gem::Specification.new do |s|
28
28
  # Files...
29
29
  main = Find.find("bin").to_a +
30
30
  Find.find("lib").to_a
31
+ data = Find.find("data").to_a
31
32
  test = Find.find("test").to_a
32
33
  misc = %w[./README.lt3 ./README.md ./runeblog.gemspec]
33
34
  empty_view = Find.find("empty_view").to_a
34
35
 
35
- s.files = main + misc + test + empty_view
36
+ s.files = main + misc + data + test + empty_view
36
37
  s.homepage = 'https://github.com/Hal9000/runeblog'
37
38
  s.license = "Ruby"
38
39
  s.post_install_message = "\n Success! Run 'blog' command and type h for help.\n "
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.2.69
4
+ version: 0.2.74
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-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -76,6 +76,9 @@ files:
76
76
  - "./runeblog.gemspec"
77
77
  - bin/blog
78
78
  - bin/mkwidget
79
+ - data/EDITOR
80
+ - data/ROOT
81
+ - data/VIEW
79
82
  - empty_view/assets/austin-pano.jpg
80
83
  - empty_view/assets/sky2.jpg
81
84
  - empty_view/remote/assets/GIT_IS_DUMB