runeblog 0.2.93 → 0.2.94

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: 51a1371a11eb69a62ff435090be403f586c0bddfd8c62ef7dc3e4f97020fee12
4
- data.tar.gz: 4d1e82de93ebb0d408964b5d06e6dc4a42f450e064b7174eecd4cb8328054f4a
3
+ metadata.gz: 7ed9580d074b2ce228aff385bbe22e907a9ae0c330f625aa2d42ee58464a1d3b
4
+ data.tar.gz: 0ce0642e8b2f0026cca4133916ff0dd3f992bb1ae8cb89e3304d90221d8195a8
5
5
  SHA512:
6
- metadata.gz: 8e27ae9cb582a3a84746db31ce664b1ed3a5ed8c47fff9178de4ff5a55e9c41687390b655a13b8df533e498edfe5ffb16af2f3f832c9d9c082353409e2dd17bb
7
- data.tar.gz: 73e512eb67281d74c141ecda0de9f75aec04e64402b5ef23a3552d0798e681b3b43aefa2a88fdb9b23bfda95f00b37938a6455599be11a665bcf182ff2b60659
6
+ metadata.gz: 84d30bada582bd3393e075a1cba653ec11e719941c675d1a9753d6dbf921643137e6096205b5120c91f385e6d9cb4a1e823440607b1db5ee23232c87885128bc
7
+ data.tar.gz: 0b0207066da6493400d66e9473c00659bef4b4169fb26cdbe554d220a59778579bd06207643516a409df39247fa8b263ae77229c16344912e81a8befb0237c6b
data/bin/blog CHANGED
@@ -25,8 +25,8 @@ end
25
25
  def get_universal
26
26
  univ = "#{@blog.root}/data/universal.lt3"
27
27
  if yesno("Faster initial setup? (no: edit universal.lt3)")
28
- author = ask("Author name: ")
29
- site = ask("Site/domain: ")
28
+ author = ask!("Author name: ")
29
+ site = ask!("Site/domain: ")
30
30
  # Now stash it...
31
31
  str = File.read(univ)
32
32
  str = str.gsub(/AUTHOR/, author)
@@ -41,8 +41,8 @@ def get_global
41
41
  if yesno("Faster view setup? (no: edit global.lt3)")
42
42
  view_name = ask("\nFilename: ")
43
43
  @blog.create_view(view_name) # call change_view??
44
- title = ask("View title: ")
45
- subtitle = ask("Subtitle : ")
44
+ title = ask!("View title: ")
45
+ subtitle = ask!("Subtitle : ")
46
46
  gname = "#{@blog.root}/views/#{view_name}/themes/standard/global.lt3"
47
47
  text = File.read(gname)
48
48
  text = text.gsub(/VIEW_NAME/, view_name)
@@ -50,7 +50,7 @@ def get_global
50
50
  text = text.gsub(/VIEW_SUBTITLE/, subtitle)
51
51
  File.write(gname, text)
52
52
  else
53
- view_name = ask("\nFilename: ")
53
+ view_name = ask!("\nFilename: ")
54
54
  @blog.create_view(view_name) # call change_view??
55
55
  vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(VIEW_.*\|SITE.*\)"'
56
56
  edit_file(@blog.view.dir/"themes/standard/global.lt3", vim: vim_params)
data/lib/helpers-blog.rb CHANGED
@@ -3,37 +3,15 @@ require 'fileutils'
3
3
 
4
4
  require 'processing'
5
5
 
6
- module RuneBlog::Helpers
7
-
8
- def _get_data?(file) # File need not exist
9
- if File.exist?(file)
10
- _get_data(file)
11
- else
12
- []
13
- end
14
- end
15
-
16
- def _get_data(file)
17
- lines = File.readlines(file)
18
- lines.reject! {|line| line[0] == "-" } # allow rejection of lines
19
- lines = lines.map do |line|
20
- line.sub(/ *# .*$/, "") # allow trailing comments
21
- end
22
- lines
23
- end
6
+ require 'lowlevel'
24
7
 
25
- def copy(src, dst)
26
- log!(enter: __method__, args: [src, dst], level: 2)
27
- cmd = "cp #{src} #{dst} 2>/dev/null"
28
- rc = system!(cmd)
29
- puts " Failed: #{cmd} - from #{caller[0]}" unless rc
30
- end
8
+ module RuneBlog::Helpers
31
9
 
32
- def copy!(src, dst)
33
- log!(enter: __method__, args: [src, dst], level: 2)
34
- cmd = "cp -r #{src} #{dst} 2>/dev/null"
35
- rc = system!(cmd)
36
- puts " Failed: #{cmd} - from #{caller[0]}" unless rc
10
+ def quit_RubyText
11
+ return unless defined? RubyText
12
+ sleep 6
13
+ RubyText.stop
14
+ exit
37
15
  end
38
16
 
39
17
  def get_repo_config
@@ -71,8 +49,7 @@ module RuneBlog::Helpers
71
49
  puts "Can't read vars file '#{file}': #{err}"
72
50
  puts err.backtrace.join("\n")
73
51
  puts "dir = #{Dir.pwd}"
74
- sleep 6; RubyText.stop
75
- exit
52
+ stop_RubyText
76
53
  end
77
54
 
78
55
  def read_config(file, *syms)
@@ -98,8 +75,7 @@ module RuneBlog::Helpers
98
75
  puts "Can't read config file '#{file}': #{err}"
99
76
  puts err.backtrace.join("\n")
100
77
  puts "dir = #{Dir.pwd}"
101
- sleep 6; RubyText.stop
102
- exit
78
+ stop_RubyText
103
79
  end
104
80
 
105
81
  def try_read_config(file, hash)
@@ -123,20 +99,21 @@ module RuneBlog::Helpers
123
99
  dirs.map {|name| RuneBlog::View.new(name) }
124
100
  end
125
101
 
126
- def write_repo_config(root: "#{Dir.pwd}/.blogs", view: File.read("#{root}/data/VIEW").chomp, editor: "/usr/local/bin/vim")
102
+ def write_repo_config(root: "#{Dir.pwd}/.blogs", view: nil, editor: "/usr/local/bin/vim")
103
+ view ||= File.read("#{root}/data/VIEW").chomp rescue "[no view]"
127
104
  File.write(root + "/data/ROOT", root + "\n")
128
105
  File.write(root + "/data/VIEW", view.to_s + "\n")
129
106
  File.write(root + "/data/EDITOR", editor + "\n")
130
107
  end
131
108
 
132
- def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
133
- log!(enter: __method__, args: [root, current_view, editor], level: 3)
134
- root = Dir.pwd + "/" + root
135
- x = OpenStruct.new
136
- x.root, x.current_view, x.editor = root, current_view, editor
137
- write_config(x, root + "/" + RuneBlog::ConfigFile)
138
- write_repo_config
139
- end
109
+ # def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
110
+ # log!(enter: __method__, args: [root, current_view, editor], level: 3)
111
+ # root = Dir.pwd + "/" + root
112
+ # x = OpenStruct.new
113
+ # x.root, x.current_view, x.editor = root, current_view, editor
114
+ # write_config(x, root + "/" + RuneBlog::ConfigFile)
115
+ # write_repo_config
116
+ # end
140
117
 
141
118
  def new_sequence
142
119
  log!(enter: __method__, level: 3)
@@ -164,38 +141,6 @@ module RuneBlog::Helpers
164
141
  files
165
142
  end
166
143
 
167
- def create_dirs(*dirs)
168
- log!(enter: __method__, args: [*dirs], level: 3)
169
- dirs.each do |dir|
170
- dir = dir.to_s # symbols allowed
171
- next if Dir.exist?(dir)
172
- cmd = "mkdir -p #{dir} >/dev/null"
173
- result = system!(cmd)
174
- raise CantCreateDir(dir) unless result
175
- end
176
- end
177
-
178
- def interpolate(str, bind)
179
- log!(enter: __method__, args: [str, bind], level: 3)
180
- wrap = "<<-EOS\n#{str}\nEOS"
181
- eval wrap, bind
182
- end
183
-
184
- def error(err) # Hmm, this is duplicated
185
- log!(str: "duplicated method", enter: __method__, args: [err], level: 2)
186
- str = "\n Error: #{err}"
187
- puts str
188
- puts err.backtrace.join("\n")
189
- end
190
-
191
- def dump(obj, name)
192
- log!(enter: __method__, args: [obj, name], level: 3)
193
- File.write(name, obj)
194
- end
195
144
  end
196
145
 
197
- def dump(obj, name) # FIXME scope
198
- log!(str: "scope problem", enter: __method__, args: [obj, name], level: 3)
199
- File.write(name, obj)
200
- end
201
146
 
data/lib/helpers-repl.rb CHANGED
@@ -109,26 +109,16 @@ module RuneBlog::REPL
109
109
  end
110
110
  meth = found || :cmd_INVALID
111
111
  params = cmd if meth == :cmd_INVALID
112
- # puts "choose: #{[meth, params].inspect}"
113
112
  [meth, params]
114
113
  end
115
114
 
116
- def error(err) # Hmm, this is duplicated
117
- str = "\n Error: #{err}"
118
- puts str
119
- puts err.backtrace.join("\n")
120
- end
121
-
122
115
  def ask(prompt, meth = :to_s)
123
116
  print prompt
124
- str = gets
125
- str.chomp!
126
- str.send(meth)
117
+ gets.chomp.send(meth)
127
118
  end
128
119
 
129
- def yesno(prompt, meth = :to_s)
130
- print prompt
131
- gets.chomp.upcase[0] == "Y"
120
+ def ask!(prompt, meth = :to_s)
121
+ ask(fx(prompt, :bold), meth)
132
122
  end
133
123
 
134
124
  def reset_output(initial = "")
data/lib/liveblog.rb CHANGED
@@ -501,22 +501,6 @@ rescue => err
501
501
  exit
502
502
  end
503
503
 
504
- # def pinned_rebuild
505
- # view = @blog.view
506
- # view = _args[0] unless _args.empty?
507
- # Dir.chdir(@blog.root/:views/view/"themes/standard/") do
508
- # wtag = "widgets/pinned"
509
- # code = _load_local("pinned")
510
- # if code
511
- # Dir.chdir(wtag) do
512
- # widget = code.new(@blog)
513
- # widget.build
514
- # end
515
- # # _include_file wtag/"pinned-card.html"
516
- # end
517
- # end
518
- # end
519
-
520
504
  def _handle_standard_widget(tag)
521
505
  wtag = :widgets/tag
522
506
  code = _load_local(tag)
@@ -769,11 +753,6 @@ def _post_lookup(postid) # side-effect
769
753
  vp
770
754
  end
771
755
 
772
- def _interpolate(str, context) # FIXME move this later
773
- wrapped = "%[" + str.dup + "]" # could fail...
774
- eval(wrapped, context)
775
- end
776
-
777
756
  def _card_generic(card_title:, middle:, extra: "")
778
757
  front = <<-HTML
779
758
  <div class="card #{extra} mb-3">
data/lib/lowlevel.rb ADDED
@@ -0,0 +1,73 @@
1
+
2
+ def dump(obj, name)
3
+ File.write(name, obj)
4
+ end
5
+
6
+ def system!(str, show: false)
7
+ log!(enter: __method__, args: [str], level: 2)
8
+ STDERR.puts str if show
9
+ rc = system(str)
10
+ return rc if rc
11
+ STDERR.puts "FAILED: #{str.inspect}"
12
+ STDERR.puts "\ncaller = \n#{caller.join("\n ")}\n"
13
+ if defined?(RubyText)
14
+ sleep 6
15
+ RubyText.stop
16
+ exit
17
+ end
18
+ return rc
19
+ end
20
+
21
+ def _get_data?(file) # File need not exist
22
+ if File.exist?(file)
23
+ _get_data(file)
24
+ else
25
+ []
26
+ end
27
+ end
28
+
29
+ def _get_data(file)
30
+ lines = File.readlines(file)
31
+ lines.reject! {|line| line[0] == "-" } # allow rejection of lines
32
+ lines = lines.map do |line|
33
+ line.sub(/ *# .*$/, "") # allow trailing comments
34
+ end
35
+ lines
36
+ end
37
+
38
+ def copy(src, dst)
39
+ log!(enter: __method__, args: [src, dst], level: 2)
40
+ cmd = "cp #{src} #{dst} 2>/dev/null"
41
+ system!(cmd)
42
+ end
43
+
44
+ def copy!(src, dst)
45
+ log!(enter: __method__, args: [src, dst], level: 2)
46
+ cmd = "cp -r #{src} #{dst} 2>/dev/null"
47
+ system!(cmd)
48
+ end
49
+
50
+ def create_dirs(*dirs)
51
+ log!(enter: __method__, args: [*dirs], level: 3)
52
+ dirs.each do |dir|
53
+ dir = dir.to_s # symbols allowed
54
+ next if Dir.exist?(dir)
55
+ cmd = "mkdir -p #{dir} >/dev/null"
56
+ result = system!(cmd)
57
+ raise CantCreateDir(dir) unless result
58
+ end
59
+ end
60
+
61
+ def interpolate(str, bind)
62
+ log!(enter: __method__, args: [str, bind], level: 3)
63
+ wrap = "<<-EOS\n#{str}\nEOS"
64
+ eval wrap, bind
65
+ end
66
+
67
+ def error(err)
68
+ log!(str: err, enter: __method__, args: [err], level: 2)
69
+ str = "\n Error: #{err}"
70
+ puts str
71
+ puts err.backtrace.join("\n")
72
+ end
73
+
data/lib/publish.rb CHANGED
@@ -37,21 +37,15 @@ class RuneBlog::Publishing
37
37
  url = "#@proto://#@server/#@path" # /#{vname}"
38
38
  end
39
39
 
40
- def system!(str)
41
- log!(enter: __method__, args: [str], level: 1)
42
- rc = system(str)
43
- rc
44
- end
45
-
46
40
  def publish
47
41
  log!(enter: __method__, level: 1)
48
42
  dir = @docroot/@path
49
43
  view_name = @blog.view.name
50
44
  viewpath = dir # /view_name
51
45
  # FIXME rsync doesn't work
52
- cmd = "rsync -a -r -z #{@blog.root}/views/#{@blog.view}/remote/ #@user@#@server:#{viewpath}/"
46
+ cmd = "rsync -r -z #{@blog.root}/views/#{@blog.view}/remote/ #@user@#@server:#{viewpath}/"
53
47
  system!(cmd)
54
- dump(files, "#{@blog.view.dir}/last_published")
48
+ dump("#{@blog.view} at #{Time.now}", "#{@blog.view.dir}/last_published")
55
49
  true
56
50
  end
57
51
 
data/lib/repl.rb CHANGED
@@ -194,7 +194,7 @@ module RuneBlog::REPL
194
194
  end
195
195
 
196
196
  ret = RubyText.spinner(label: " Publishing... ") do
197
- @blog.view.publisher.publish(files, assets) # FIXME weird?
197
+ @blog.view.publisher.publish
198
198
  end
199
199
  return @out unless ret
200
200
 
data/lib/runeblog.rb CHANGED
@@ -10,7 +10,6 @@ require 'logging'
10
10
 
11
11
  require 'runeblog_version'
12
12
  require 'helpers-blog'
13
- require 'default'
14
13
  require 'view'
15
14
  require 'publish'
16
15
  require 'post'
@@ -48,6 +47,34 @@ class RuneBlog
48
47
 
49
48
  include Helpers
50
49
 
50
+ class Default
51
+
52
+ # This will all become much more generic later.
53
+
54
+ def RuneBlog.post_template(num: 0, title: "No title", date: nil, view: "test_view",
55
+ teaser: "No teaser", body: "No body", tags: ["untagged"],
56
+ views: [], back: "javascript:history.go(-1)", home: "no url")
57
+ log!(enter: __method__, args: [num, title, date, view, teaser, body, tags, views, back, home], level: 3)
58
+ viewlist = (views + [view.to_s]).join(" ")
59
+ taglist = ".tags " + tags.join(" ")
60
+
61
+ <<~TEXT
62
+ .post #{num}
63
+
64
+ .title #{title}
65
+ .pubdate #{date}
66
+ .views #{viewlist}
67
+ #{taglist}
68
+
69
+ .teaser
70
+ #{teaser}
71
+ .end
72
+ #{body}
73
+ TEXT
74
+ end
75
+
76
+ end
77
+
51
78
  def _tmp_error(err) # FIXME move to helpers
52
79
  out = "/tmp/blog#{rand(100)}.txt"
53
80
  File.open(out, "w") do |f|
@@ -68,7 +95,7 @@ class RuneBlog
68
95
  create_dirs(:data, :drafts, :views, :posts)
69
96
  new_sequence
70
97
  end
71
- copy_data(:config, repo_root/:data)
98
+ copy_data(:config, repo_root/:data) unless File.exist?(repo_root/"data/VIEW")
72
99
  write_repo_config(root: repo_root)
73
100
  @blog = self.new
74
101
  @blog
@@ -90,7 +117,7 @@ class RuneBlog
90
117
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
91
118
 
92
119
  @root = Dir.pwd/root_rel
93
- copy_data(:config, @root/:data) unless File.exist?(@root/"data/VIEW")
120
+ # copy_data(:config, @root/:data) unless File.exist?(@root/"data/VIEW")
94
121
  write_repo_config(root: @root)
95
122
  get_repo_config
96
123
  @views = retrieve_views
@@ -210,6 +237,9 @@ class RuneBlog
210
237
  def view=(arg)
211
238
  log!(enter: __method__, args: [arg], level: 2)
212
239
  case arg
240
+ when "[no view]"
241
+ # puts "Warning: No current view set"
242
+ @view = nil
213
243
  when RuneBlog::View
214
244
  @view = arg
215
245
  _set_publisher
@@ -487,8 +517,8 @@ class RuneBlog
487
517
  log!(enter: __method__, args: [draft], level: 2)
488
518
  # FIXME dumb code
489
519
  view_line = File.readlines(draft).grep(/^.views /)
490
- raise "More than one .views call!" if view_line.size > 1
491
- raise "No .views call!" if view_line.size < 1
520
+ raise "More than one .views call in #{draft}" if view_line.size > 1
521
+ raise "No .views call in #{draft}" if view_line.size < 1
492
522
  view_line = view_line.first
493
523
  views = view_line[7..-1].split
494
524
  views.uniq
@@ -3,7 +3,7 @@ if !defined?(RuneBlog::Path)
3
3
  # if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
4
4
 
5
5
  class RuneBlog
6
- VERSION = "0.2.93"
6
+ VERSION = "0.2.94"
7
7
 
8
8
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
9
9
  Path = File.dirname(path)
@@ -41,22 +41,6 @@ def make_exception(sym, str)
41
41
  end
42
42
  end
43
43
 
44
- def system!(str, show: false)
45
- log!(enter: __method__, args: [str], level: 2)
46
- STDERR.puts str if show
47
- rc = system(str)
48
- if rc
49
- return rc
50
- else
51
- STDERR.puts "FAILED: #{str.inspect}"
52
- STDERR.puts "\ncaller = \n#{caller.join("\n ")}\n"
53
- sleep 6; RubyText.stop
54
- exit
55
- return rc
56
- end
57
- rc
58
- end
59
-
60
44
  def prefix(num)
61
45
  log!(enter: __method__, args: [num], level: 3)
62
46
  "#{'%04d' % num.to_i}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.93
4
+ version: 0.2.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
@@ -175,7 +175,6 @@ files:
175
175
  - empty_view/themes/standard/widgets/tag-cloud/tag-cloud.lt3
176
176
  - empty_view/themes/standard/widgets/tag-cloud/tag-cloud.rb
177
177
  - lib/Javascript.stuff
178
- - lib/default.rb
179
178
  - lib/exper/2svg.lt3
180
179
  - lib/exper/callout.js
181
180
  - lib/exper/fbtw-js
@@ -187,6 +186,7 @@ files:
187
186
  - lib/helpers-repl.rb
188
187
  - lib/liveblog.rb
189
188
  - lib/logging.rb
189
+ - lib/lowlevel.rb
190
190
  - lib/pathmagic.rb
191
191
  - lib/post.rb
192
192
  - lib/processing.rb
data/lib/default.rb DELETED
@@ -1,31 +0,0 @@
1
- class RuneBlog::Default
2
-
3
- # This will all become much more generic later.
4
-
5
- def RuneBlog.post_template(num: 0, title: "No title", date: nil, view: "test_view",
6
- teaser: "No teaser", body: "No body", tags: ["untagged"],
7
- views: [], back: "javascript:history.go(-1)", home: "no url")
8
- log!(enter: __method__, args: [num, title, date, view, teaser, body, tags, views, back, home], level: 3)
9
- viewlist = (views + [view.to_s]).join(" ")
10
- taglist = ".tags " + tags.join(" ")
11
-
12
- # .mixin liveblog
13
- # . ^ get rid of this later
14
-
15
- <<-TEXT
16
- .post #{num}
17
-
18
- .title #{title}
19
- .pubdate #{date}
20
- .views #{viewlist}
21
- #{taglist}
22
-
23
- .teaser
24
- #{teaser}
25
- .end
26
- #{body}
27
- TEXT
28
-
29
- end
30
-
31
- end