runeblog 0.2.43 → 0.2.44

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: 16662b0b5b8ec9310e57c63c336fe13bdde1612a4b1dc0a8ffdaab0a2982db1f
4
- data.tar.gz: 93aeb315ce95b26a4aee96350fb20abf081b95af69873e57ed1e1310f8a4416b
3
+ metadata.gz: b0b81363110b0cb0392e016c289ee76b841d05a2d4ed2167ce26b9f08bb2e1ae
4
+ data.tar.gz: c57eedabc749e9bee009dd3dc68c9f5ad8f430ae858ff6e307b027cd90fbf147
5
5
  SHA512:
6
- metadata.gz: 0fb2ef08e58378caa049c6b5a274f3cb6928f9e09dc9a54d5cf5fdd613fed0c473d249dbb2d43b99baf76ae209a343ab70cb89db75e26f082284db1737c967a8
7
- data.tar.gz: a35443b76f177cc48457acebdea57fcc9909edd49af992c7eb3ce8d15a7308855c08992385b9dbae0ae9b429646e052210576733e76d835e3717e4214f61e123
6
+ metadata.gz: 20a947a5d88018aa3a9942b559cba915f15c733120ffbdd46433e50ea018bd9997184a194220a530882c9bcfab818a364c141b3ba62a4d36411b4241617521b4
7
+ data.tar.gz: '019e9d9fbff78f670ea225014e3ec9208aa9fb0fd31fbc4241262d9f4ed39c365f5be14c6d3439e9bb996a9cea568ef81ddd1b1a41ad369b14279339160f91a8'
@@ -40,3 +40,9 @@
40
40
  text-align: top;
41
41
  }
42
42
 
43
+ . not used?
44
+ \.thumbnail img {
45
+ max-height: 100%;
46
+ max-width: 100%;
47
+ }
48
+
@@ -0,0 +1 @@
1
+ .include ../widgets/pages/faq.lt3
@@ -12,5 +12,6 @@
12
12
  index Home
13
13
  about About
14
14
  contact Contact
15
+ faq FAQ
15
16
  .end
16
17
 
@@ -1,15 +1,22 @@
1
1
  . In real life, ads won't work this way...
2
2
 
3
+ .include vars.lt3
4
+
3
5
  .set classname="btn btn-light float-right"
4
6
  .set card.title="Advertisement"
5
7
  .set card.text="Build your amazing website with blabla.com."
6
- .set extra="bg-dark text-white"
8
+ . set extra="bg-dark text-white"
9
+
10
+ <!-- "$ad.image" -->
7
11
 
8
12
  <div class="card $extra mb-3">
9
13
  <div class="card-body">
14
+ <!--
10
15
  <h5 class="card-title">$card.title</h5>
11
16
  <p class="card-text">$card.text</p>
12
17
  <a href="javascript: void(0)" onclick="javascript:open_main('widgets/ad/ad.html')" class="$classname">Visit page</a>
18
+ -->
19
+ <img style="max-height: 100%; max-width: 100%" src="$ad.image"></img>
13
20
  </div>
14
21
  </div>
15
22
 
@@ -5,11 +5,14 @@
5
5
  class ::RuneBlog::Widget
6
6
  class Pages
7
7
  def self.build
8
+ # build child pages
8
9
  children = Dir["*.lt3"] - ["pages.lt3"]
9
10
  children.each do |child|
10
11
  dest = child.sub(/.lt3$/, ".html")
11
12
  xlate src: child, dst: dest # , debug: true
12
13
  end
14
+ # build mainfile
15
+ # build cardfile
13
16
  end
14
17
 
15
18
  def self.edit_menu
@@ -5,7 +5,7 @@ class RuneBlog::Default
5
5
  def RuneBlog.post_template(num: 0, title: "No title", date: nil, view: "test_view",
6
6
  teaser: "No teaser", body: "No body", tags: ["untagged"],
7
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])
8
+ log!(enter: __method__, args: [num, title, date, view, teaser, body, tags, views, back, home], level: 3)
9
9
  viewlist = (views + [view.to_s]).join(" ")
10
10
  taglist = ".tags " + tags.join(" ")
11
11
  <<-TEXT
@@ -20,7 +20,7 @@ end
20
20
  # Refactor, move stuff elsewhere?
21
21
 
22
22
  def make_exception(sym, str)
23
- log!(enter: __method__, args: [sym, str])
23
+ log!(enter: __method__, args: [sym, str], level: 3)
24
24
  return if Object.constants.include?(sym)
25
25
  Object.const_set(sym, StandardError.dup)
26
26
  define_method(sym) do |*args|
@@ -30,8 +30,9 @@ def make_exception(sym, str)
30
30
  end
31
31
  end
32
32
 
33
- def system!(str)
34
- log!(enter: __method__, args: [str])
33
+ def system!(str, show: false)
34
+ log!(enter: __method__, args: [str], level: 2)
35
+ STDERR.puts str if show
35
36
  rc = system(str)
36
37
  if rc
37
38
  return rc
@@ -44,12 +45,12 @@ end
44
45
  end
45
46
 
46
47
  def prefix(num)
47
- log!(enter: __method__, args: [num])
48
+ log!(enter: __method__, args: [num], level: 3)
48
49
  "#{'%04d' % num.to_i}"
49
50
  end
50
51
 
51
52
  def check_meta(meta, where = "")
52
- log!(enter: __method__, args: [meta, where])
53
+ log!(enter: __method__, args: [meta, where], level: 3)
53
54
  str = "--- #{where}\n"
54
55
  str << "\ncheck_meta: \n" + caller.join("\n") + "\n meta = #{meta.inspect}\n"
55
56
  str << " title missing!\n" unless meta.title
@@ -62,14 +63,14 @@ def check_meta(meta, where = "")
62
63
  end
63
64
 
64
65
  def verify(hash)
65
- log!(enter: __method__, args: [hash])
66
+ log!(enter: __method__, args: [hash], level: 3)
66
67
  hash.each_pair do |expr, msg|
67
68
  puts "<< #{msg}" unless expr
68
69
  end
69
70
  end
70
71
 
71
72
  def assure(hash) # really the same as verify for now...
72
- log!(enter: __method__, args: [hash])
73
+ log!(enter: __method__, args: [hash], level: 3)
73
74
  hash.each_pair do |expr, msg|
74
75
  puts "<< #{msg}" unless expr
75
76
  end
@@ -6,14 +6,14 @@ require 'xlate'
6
6
  module RuneBlog::Helpers
7
7
 
8
8
  def copy(src, dst)
9
- log!(enter: __method__, args: [src, dst])
9
+ log!(enter: __method__, args: [src, dst], level: 2)
10
10
  cmd = "cp #{src} #{dst} 2>/dev/null"
11
11
  rc = system!(cmd)
12
12
  puts " Failed: #{cmd} - from #{caller[0]}" unless rc
13
13
  end
14
14
 
15
15
  def copy!(src, dst)
16
- log!(enter: __method__, args: [src, dst])
16
+ log!(enter: __method__, args: [src, dst], level: 2)
17
17
  cmd = "cp -r #{src} #{dst} 2>/dev/null"
18
18
  rc = system!(cmd)
19
19
  puts " Failed: #{cmd} - from #{caller[0]}" unless rc
@@ -36,7 +36,7 @@ module RuneBlog::Helpers
36
36
  # end
37
37
 
38
38
  def read_config(file, *syms)
39
- log!(enter: __method__, args: [file, *syms])
39
+ log!(enter: __method__, args: [file, *syms], level: 3)
40
40
  lines = File.readlines(file).map(&:chomp)
41
41
  obj = ::OpenStruct.new
42
42
  lines.each do |line|
@@ -61,7 +61,7 @@ module RuneBlog::Helpers
61
61
  end
62
62
 
63
63
  def try_read_config(file, hash)
64
- log!(enter: __method__, args: [file, hash])
64
+ log!(enter: __method__, args: [file, hash], level: 3)
65
65
  return hash.values unless File.exist?(file)
66
66
  vals = read_config(file, *hash.keys)
67
67
  vals
@@ -80,7 +80,7 @@ module RuneBlog::Helpers
80
80
  # end
81
81
 
82
82
  def write_config(obj, file)
83
- log!(enter: __method__, args: [obj, file])
83
+ log!(enter: __method__, args: [obj, file], level: 2)
84
84
  hash = obj.to_h
85
85
  File.open(file, "w") do |out|
86
86
  hash.each_pair {|key, val| out.puts "#{key}: #{val}" }
@@ -88,13 +88,13 @@ module RuneBlog::Helpers
88
88
  end
89
89
 
90
90
  def get_views # read from filesystem
91
- log!(enter: __method__)
91
+ log!(enter: __method__, level: 3)
92
92
  dirs = subdirs("#@root/views/").sort
93
93
  dirs.map {|name| RuneBlog::View.new(name) }
94
94
  end
95
95
 
96
96
  def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
97
- log!(enter: __method__, args: [root, current_view, editor])
97
+ log!(enter: __method__, args: [root, current_view, editor], level: 3)
98
98
  root = Dir.pwd/root
99
99
  x = OpenStruct.new
100
100
  x.root, x.current_view, x.editor = root, current_view, editor
@@ -102,21 +102,21 @@ module RuneBlog::Helpers
102
102
  end
103
103
 
104
104
  def new_sequence
105
- log!(enter: __method__)
105
+ log!(enter: __method__, level: 3)
106
106
  dump(0, "sequence")
107
107
  version_info = "#{RuneBlog::VERSION}\nBlog created: #{Time.now.to_s}"
108
108
  dump(version_info, "VERSION")
109
109
  end
110
110
 
111
111
  def subdirs(dir)
112
- log!(enter: __method__, args: [dir])
112
+ log!(enter: __method__, args: [dir], level: 3)
113
113
  dirs = Dir.entries(dir) - %w[. ..]
114
114
  dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
115
115
  dirs
116
116
  end
117
117
 
118
118
  def find_draft_slugs
119
- log!(enter: __method__)
119
+ log!(enter: __method__, level: 3)
120
120
  files = Dir["#@root/drafts/**"].grep /\d{4}.*.lt3$/
121
121
  flagfile = "#@root/drafts/last_rebuild"
122
122
  last = File.exist?(flagfile) ? File.mtime(flagfile) : (Time.now - 86_400)
@@ -128,7 +128,7 @@ module RuneBlog::Helpers
128
128
  end
129
129
 
130
130
  def create_dirs(*dirs)
131
- log!(enter: __method__, args: [*dirs])
131
+ log!(enter: __method__, args: [*dirs], level: 3)
132
132
  dirs.each do |dir|
133
133
  dir = dir.to_s # symbols allowed
134
134
  next if Dir.exist?(dir)
@@ -139,27 +139,27 @@ module RuneBlog::Helpers
139
139
  end
140
140
 
141
141
  def interpolate(str, bind)
142
- log!(enter: __method__, args: [str, bind])
142
+ log!(enter: __method__, args: [str, bind], level: 3)
143
143
  wrap = "<<-EOS\n#{str}\nEOS"
144
144
  eval wrap, bind
145
145
  end
146
146
 
147
147
  def error(err) # Hmm, this is duplicated
148
- log!(str: "duplicated method", enter: __method__, args: [err])
148
+ log!(str: "duplicated method", enter: __method__, args: [err], level: 2)
149
149
  str = "\n Error: #{err}"
150
150
  puts str
151
151
  puts err.backtrace.join("\n")
152
152
  end
153
153
 
154
154
  def dump(obj, name)
155
- log!(enter: __method__, args: [obj, name])
155
+ log!(enter: __method__, args: [obj, name], level: 3)
156
156
  File.write(name, obj)
157
157
  end
158
158
 
159
159
  end
160
160
 
161
161
  def dump(obj, name) # FIXME scope
162
- log!(str: "scope problem", enter: __method__, args: [obj, name])
162
+ log!(str: "scope problem", enter: __method__, args: [obj, name], level: 3)
163
163
  File.write(name, obj)
164
164
  end
165
165
 
@@ -128,17 +128,17 @@ end
128
128
 
129
129
 
130
130
  def make_main_links
131
- log!(enter: __method__)
131
+ log!(enter: __method__, level: 1)
132
132
  # FIXME remember strings may not be safe
133
133
  line = _data.chomp
134
134
  tag, card_title = *line.split(" ", 2)
135
135
  cardfile, mainfile = "#{tag}-card", "#{tag}-main"
136
136
  input = "list.data"
137
- log!(str: "Reading #{input}", pwd: true)
137
+ log!(str: "Reading #{input}", pwd: true, level: 3)
138
138
  pairs = File.readlines(input).map {|line| line.chomp.split(/, */, 2) }
139
139
  _write_main(mainfile, pairs, card_title, tag)
140
140
  _write_card(cardfile, mainfile, pairs, card_title, tag)
141
- log!(str: "...returning from method", pwd: true)
141
+ log!(str: "...returning from method", pwd: true, level: 3)
142
142
  end
143
143
 
144
144
  ### inset
@@ -375,16 +375,22 @@ def sidebar
375
375
  tcard = "#{tag}-card.html"
376
376
 
377
377
  code = _load_local(tag)
378
- code && Dir.chdir(wtag) { code.build }
379
-
380
- # if File.exist?(wtag/"SUBFILES")
381
- # children = Dir[wtag/"*.lt3"] - [wtag/tag+".lt3"]
382
- # children.each do |child|
383
- # dest = child.sub(/.lt3$/, ".html")
384
- # xlate src: child, dst: dest # , debug: true
385
- # end
386
- # end
387
- xlate cwd: wtag, src: tag, dst: tcard # , debug: true
378
+ if code && tag == "pages"
379
+ Dir.chdir(wtag) { code.build }
380
+ else
381
+ end
382
+
383
+ if tag == "ad"
384
+ num = rand(1..4)
385
+ img = "widgets/ad/ad#{num}.png"
386
+ src, dst = img, @root/:views/@view_name/"remote/widgets/ad/"
387
+ system!("cp #{src} #{dst}") # , show: true)
388
+ File.open(wtag/"vars.lt3", "w") do |f|
389
+ f.puts ".set ad.image = #{img}"
390
+ end
391
+ end
392
+
393
+ xlate cwd: wtag, src: tag, dst: tcard # , debug: (tag == "ad")
388
394
  _include_file wtag/tcard
389
395
  end
390
396
  _out %[</div>]
@@ -593,7 +599,7 @@ def _html_body(file, css = nil)
593
599
  end
594
600
 
595
601
  def _write_card(cardfile, mainfile, pairs, card_title, tag)
596
- log!(str: "Creating #{cardfile}.html", pwd: true)
602
+ log!(str: "Creating #{cardfile}.html", pwd: true, level: 2)
597
603
  url = mainfile
598
604
  url = :widgets/tag/mainfile + ".html"
599
605
  File.open("#{cardfile}.html", "w") do |f|
@@ -608,7 +614,7 @@ def _write_card(cardfile, mainfile, pairs, card_title, tag)
608
614
  </h5>
609
615
  <div class="collapse" id="#{tag}">
610
616
  EOS
611
- log!(str: "Writing data pairs to #{cardfile}.html", pwd: true)
617
+ log!(str: "Writing data pairs to #{cardfile}.html", pwd: true, level: 2)
612
618
  local = _local_tag?(tag)
613
619
  pairs.each do |file, title|
614
620
  url = file
@@ -681,7 +687,7 @@ def _write_main_pages(mainfile, pairs, card_title, tag)
681
687
  end
682
688
 
683
689
  def _write_main(mainfile, pairs, card_title, tag)
684
- log!(str: "Creating #{mainfile}.html", pwd: true)
690
+ log!(str: "Creating #{mainfile}.html", pwd: true, level: 2)
685
691
 
686
692
  if tag == "pages" # temporary experiment
687
693
  _write_main_pages(mainfile, pairs, card_title, tag)
@@ -2,8 +2,17 @@ unless self.respond_to?("log!")
2
2
  $logging = true
3
3
  $log = File.new("/tmp/runeblog.log","w")
4
4
 
5
- def log!(str: "", enter: nil, args: [], pwd: false, dir: false)
5
+ def outlog(str = "", stderr: false)
6
+ $log.puts str
7
+ STDERR.puts str if stderr
8
+ end
9
+
10
+ def log!(str: "", enter: nil, args: [], pwd: false, dir: false, level: 0, stderr: false)
6
11
  return unless $logging
12
+ @err_level ||= ENV['RUNEBLOG_ERROR_LEVEL']
13
+ @err_level ||= 0
14
+ return if level < @err_level
15
+
7
16
  time = Time.now.strftime("%H:%M:%S")
8
17
 
9
18
  meth = ""
@@ -17,16 +26,16 @@ unless self.respond_to?("log!")
17
26
  str = " ... #{str}" unless str.empty?
18
27
  indent = " "*12
19
28
 
20
- $log.puts "#{time} #{meth}#{para}"
21
- $log.puts "#{indent} #{str} " unless str.empty?
22
- $log.puts "#{indent} #{source}"
23
- $log.puts "#{indent} pwd = #{Dir.pwd} " if pwd
29
+ outlog "#{time} #{meth}#{para}"
30
+ outlog "#{indent} #{str} " unless str.empty?
31
+ outlog "#{indent} #{source}"
32
+ outlog "#{indent} pwd = #{Dir.pwd} " if pwd
24
33
  if dir
25
34
  files = (Dir.entries('.') - %w[. ..]).join(" ")
26
- $log.puts "#{indent} dir/* = #{files}"
35
+ outlog "#{indent} dir/* = #{files}"
27
36
  end
28
- # $log.puts "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil?
29
- $log.puts
37
+ # outlog "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil?
38
+ outlog
30
39
  $log.close
31
40
  $log = File.new("/tmp/runeblog.log","a")
32
41
  end
@@ -10,14 +10,14 @@ class RuneBlog::Post
10
10
  include RuneBlog::Helpers
11
11
 
12
12
  def self.files(num, root)
13
- log!(enter: __method__, args: [num, root])
13
+ log!(enter: __method__, args: [num, root], level: 3)
14
14
  files = Find.find(root).to_a
15
15
  result = files.grep(/#{prefix(num)}-/)
16
16
  result
17
17
  end
18
18
 
19
19
  def self.load(post)
20
- log!(enter: __method__, args: [post])
20
+ log!(enter: __method__, args: [post], level: 3)
21
21
  raise "Doesn't work right now"
22
22
  raise NoBlogAccessor if RuneBlog.blog.nil?
23
23
  # "post" is a slug
@@ -36,7 +36,7 @@ class RuneBlog::Post
36
36
  end
37
37
 
38
38
  def write_metadata(meta) # FIXME ???
39
- log!(enter: __method__, args: [meta])
39
+ log!(enter: __method__, args: [meta], level: 3)
40
40
  debug "=== write_metadata:"
41
41
  debug "-----\n#{meta.inspect}\n-----"
42
42
  fname2 = "metadata.txt"
@@ -57,7 +57,7 @@ class RuneBlog::Post
57
57
  end
58
58
 
59
59
  def initialize
60
- log!(enter: __method__)
60
+ log!(enter: __method__, level: 3)
61
61
  @blog = RuneBlog.blog || raise(NoBlogAccessor)
62
62
  @meta = OpenStruct.new
63
63
  end
@@ -115,7 +115,7 @@ class RuneBlog::ViewPost
115
115
  :teaser_text
116
116
 
117
117
  def initialize(view, postdir)
118
- log!(enter: __method__, args: [view, postdir])
118
+ log!(enter: __method__, args: [view, postdir], level: 3)
119
119
  # Assumes already parsed/processed
120
120
  @blog = RuneBlog.blog || raise(NoBlogAccessor)
121
121
  @path = postdir.dup
@@ -131,7 +131,7 @@ class RuneBlog::ViewPost
131
131
  end
132
132
 
133
133
  def get_dirs
134
- log!(enter: __method__, args: [view, postdir])
134
+ log!(enter: __method__, args: [view, postdir], level: 3)
135
135
  fname = File.basename(draft)
136
136
  noext = fname.sub(/.lt3$/, "")
137
137
  vdir = @root/:views/view
@@ -21,25 +21,25 @@ class RuneBlog::Publishing
21
21
  end
22
22
 
23
23
  def to_h
24
- log!(enter: __method__)
24
+ log!(enter: __method__, level: 3)
25
25
  {user: @user, server: @server, docroot: @docroot,
26
26
  path: @path, proto: @proto}
27
27
  end
28
28
 
29
29
  def url
30
- log!(enter: __method__)
30
+ log!(enter: __method__, level: 3)
31
31
  vname = @blog.view.name # .gsub(/_/, "\\_")
32
32
  url = "#@proto://#@server/#@path" # /#{vname}"
33
33
  end
34
34
 
35
35
  def system!(str)
36
- log!(enter: __method__, args: [str])
36
+ log!(enter: __method__, args: [str], level: 1)
37
37
  rc = system(str)
38
38
  rc
39
39
  end
40
40
 
41
41
  def publish(files, assets=[])
42
- log!(enter: __method__, args: [files, assets])
42
+ log!(enter: __method__, args: [files, assets], level: 1)
43
43
  dir = @docroot/@path
44
44
  view_name = @blog.view.name
45
45
  viewpath = dir # /view_name
@@ -53,7 +53,7 @@ class RuneBlog
53
53
  end
54
54
 
55
55
  def self.create(root = ".blogs")
56
- log!(enter: __method__, args: [root])
56
+ log!(enter: __method__, args: [root], level: 1)
57
57
  # Crude - FIXME later - # What views are there? Publishing, etc.
58
58
  self.blog = self # Weird. Like a singleton - dumbass circular dependency?
59
59
  root = Dir.pwd/root
@@ -101,7 +101,7 @@ class RuneBlog
101
101
  end
102
102
 
103
103
  def _deploy_local(dir)
104
- log!(enter: __method__, args: [dir])
104
+ log!(enter: __method__, args: [dir], level: 1)
105
105
  Dir.chdir(dir) do
106
106
  views = _retrieve_metadata(:views)
107
107
  views.each {|v| system!("cp *html #@root/views/#{v}/remote") }
@@ -132,7 +132,7 @@ class RuneBlog
132
132
  end
133
133
 
134
134
  def process_post(sourcefile)
135
- log!(enter: __method__, args: [dir])
135
+ log!(enter: __method__, args: [dir], level: 2)
136
136
  nslug = sourcefile.sub(/.lt3/, "")
137
137
  dir = @root/:posts/nslug
138
138
  create_dir(dir)
@@ -141,7 +141,7 @@ class RuneBlog
141
141
  end
142
142
 
143
143
  def inspect
144
- log!(enter: __method__)
144
+ log!(enter: __method__, level: 3)
145
145
  str = "blog: "
146
146
  ivars = ["@root", "@sequence"] # self.instance_variables
147
147
  ivars.each do |iv|
@@ -152,30 +152,30 @@ class RuneBlog
152
152
  end
153
153
 
154
154
  def view?(name)
155
- log!(enter: __method__, args: [name])
155
+ log!(enter: __method__, args: [name], level: 3)
156
156
  raise ArgumentError unless name.is_a?(String) && ! name.empty?
157
157
  views.any? {|x| x.name == name }
158
158
  end
159
159
 
160
160
  def view(name = nil)
161
- log!(enter: __method__, args: [name])
161
+ log!(enter: __method__, args: [name], level: 3)
162
162
  raise ArgumentError unless name.nil? || (name.is_a?(String) && ! name.empty?)
163
163
  name.nil? ? @view : str2view(name)
164
164
  end
165
165
 
166
166
  def str2view(str)
167
- log!(enter: __method__, args: [str])
167
+ log!(enter: __method__, args: [str], level: 3)
168
168
  raise ArgumentError unless str.is_a?(String) && ! str.empty?
169
169
  @views.find {|x| x.name == str }
170
170
  end
171
171
 
172
172
  def _set_publisher
173
- log!(enter: __method__)
173
+ log!(enter: __method__, level: 3)
174
174
  @view.publisher = RuneBlog::Publishing.new(@view.to_s) # FIXME refactor
175
175
  end
176
176
 
177
177
  def view=(arg)
178
- log!(enter: __method__, args: [arg])
178
+ log!(enter: __method__, args: [arg], level: 2)
179
179
  case arg
180
180
  when RuneBlog::View
181
181
  @view = arg
@@ -191,19 +191,19 @@ class RuneBlog
191
191
  end
192
192
 
193
193
  def get_sequence
194
- log!(enter: __method__)
194
+ log!(enter: __method__, level: 3)
195
195
  File.read(@root/:sequence).to_i
196
196
  end
197
197
 
198
198
  def next_sequence
199
- log!(enter: __method__)
199
+ log!(enter: __method__, level: 3)
200
200
  @sequence += 1
201
201
  dump(@sequence, @root/:sequence)
202
202
  @sequence
203
203
  end
204
204
 
205
205
  def viewdir(v = nil) # delete?
206
- log!(enter: __method__, args: [v])
206
+ log!(enter: __method__, args: [v], level: 3)
207
207
  v = str2view(v) if v.is_a?(String)
208
208
  raise ArgumentError unless v.nil? || v.is_a?(RuneBlog::View)
209
209
  v ||= @view
@@ -211,17 +211,17 @@ class RuneBlog
211
211
  end
212
212
 
213
213
  def self.exist?
214
- log!(enter: __method__)
214
+ log!(enter: __method__, level: 3)
215
215
  Dir.exist?(DotDir) && File.exist?(DotDir/ConfigFile)
216
216
  end
217
217
 
218
218
  def mark_last_published(str)
219
- log!(enter: __method__, args: [str])
219
+ log!(enter: __method__, args: [str], level: 2)
220
220
  dump(str, "#{self.view.dir}/last_published")
221
221
  end
222
222
 
223
223
  def add_view(view_name)
224
- log!(enter: __method__, args: [view_name])
224
+ log!(enter: __method__, args: [view_name], level: 2)
225
225
  view = RuneBlog::View.new(view_name)
226
226
  @view = view # current view
227
227
  @views << view # all views
@@ -229,7 +229,7 @@ class RuneBlog
229
229
  end
230
230
 
231
231
  def make_empty_view_tree(view_name)
232
- log!(enter: __method__, args: [view_name])
232
+ log!(enter: __method__, args: [view_name], level: 2)
233
233
  Dir.chdir(@root) do
234
234
  cmd = "cp -r #{RuneBlog::Path}/../empty_view views/#{view_name}"
235
235
  system!(cmd)
@@ -237,7 +237,7 @@ class RuneBlog
237
237
  end
238
238
 
239
239
  def check_valid_new_view(view_name)
240
- log!(enter: __method__, args: [view_name])
240
+ log!(enter: __method__, args: [view_name], level: 3)
241
241
  raise ArgumentError unless view_name.is_a?(String)
242
242
  raise ArgumentError if view_name.empty?
243
243
  names = self.views.map(&:to_s)
@@ -249,9 +249,11 @@ class RuneBlog
249
249
  end
250
250
 
251
251
  def create_view(view_name)
252
- log!(enter: __method__, args: [view_name])
252
+ log!(enter: __method__, args: [view_name], level: 2)
253
253
  check_valid_new_view(view_name)
254
254
  make_empty_view_tree(view_name)
255
+ # STDERR.puts "Made empty tree!"
256
+ # system("bash")
255
257
  add_view(view_name)
256
258
  mark_last_published("Initial creation")
257
259
  end
@@ -267,7 +269,7 @@ class RuneBlog
267
269
  end
268
270
 
269
271
  def view_files
270
- log!(enter: __method__)
272
+ log!(enter: __method__, level: 2)
271
273
  vdir = self.view.dir
272
274
  files = [vdir/"index.html"]
273
275
  files += posts.map {|x| vdir/x }
@@ -275,7 +277,7 @@ class RuneBlog
275
277
  end
276
278
 
277
279
  def post_lookup(postid) # side-effect?
278
- log!(enter: __method__, args: [postid])
280
+ log!(enter: __method__, args: [postid], level: 2)
279
281
  slug = title = date = teaser_text = nil
280
282
 
281
283
  dir_posts = @vdir/:posts
@@ -290,7 +292,7 @@ class RuneBlog
290
292
  end
291
293
 
292
294
  def index_entry(slug)
293
- log!(enter: __method__, args: [slug])
295
+ log!(enter: __method__, args: [slug], level: 2)
294
296
  id = slug.to_i
295
297
  text = nil
296
298
  @theme = @view.dir/"themes/standard"
@@ -309,7 +311,7 @@ class RuneBlog
309
311
  end
310
312
 
311
313
  def collect_recent_posts(file)
312
- log!(enter: __method__, args: [file])
314
+ log!(enter: __method__, args: [file], level: 3)
313
315
  posts = nil
314
316
  dir_posts = @vdir/:posts
315
317
  entries = Dir.entries(dir_posts)
@@ -335,7 +337,7 @@ class RuneBlog
335
337
  end
336
338
 
337
339
  def create_new_post(title, testing = false, teaser: nil, body: nil, views: [])
338
- log!(enter: __method__, args: [title, testing, teaser, body, views])
340
+ log!(enter: __method__, args: [title, testing, teaser, body, views], level: 1)
339
341
  meta = nil
340
342
  views = views + [self.view.to_s]
341
343
  Dir.chdir(@root/:posts) do
@@ -351,7 +353,7 @@ class RuneBlog
351
353
  end
352
354
 
353
355
  def edit_initial_post(file, testing = false)
354
- log!(enter: __method__, args: [file, testing])
356
+ log!(enter: __method__, args: [file, testing], level: 3)
355
357
  debug "=== edit_initial_post #{file.inspect} => #{sourcefile}"
356
358
  sourcefile = @root/:drafts/file
357
359
  result = system!("#@editor #{sourcefile} +8") unless testing
@@ -363,20 +365,20 @@ class RuneBlog
363
365
  end
364
366
 
365
367
  def posts
366
- log!(enter: __method__)
368
+ log!(enter: __method__, level: 3)
367
369
  dir = self.view.dir/:posts
368
370
  posts = Dir.entries(dir).grep(/^\d{4}/)
369
371
  posts
370
372
  end
371
373
 
372
374
  def drafts
373
- log!(enter: __method__)
375
+ log!(enter: __method__, level: 3)
374
376
  dir = @root/:drafts
375
377
  drafts = Dir.entries(dir).grep(/^\d{4}.*/)
376
378
  end
377
379
 
378
380
  def change_view(view)
379
- log!(enter: __method__, args: [view])
381
+ log!(enter: __method__, args: [view], level: 3)
380
382
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
381
383
  x = OpenStruct.new
382
384
  x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
@@ -400,7 +402,7 @@ class RuneBlog
400
402
  src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
401
403
  xlate cwd: vdir/"themes/standard",
402
404
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
403
- generate_index(view) # recent posts (recent.html)
405
+ # generate_index(view) # recent posts (recent.html)
404
406
  # ^ HERE
405
407
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
406
408
  rescue => err
@@ -411,7 +413,7 @@ class RuneBlog
411
413
  end
412
414
 
413
415
  def _get_views(draft)
414
- log!(enter: __method__, args: [draft])
416
+ log!(enter: __method__, args: [draft], level: 2)
415
417
  # FIXME dumb code
416
418
  view_line = File.readlines(draft).grep(/^.views /)
417
419
  raise "More than one .views call!" if view_line.size > 1
@@ -422,7 +424,7 @@ class RuneBlog
422
424
  end
423
425
 
424
426
  def _copy_get_dirs(draft, view)
425
- log!(enter: __method__, args: [draft, view])
427
+ log!(enter: __method__, args: [draft, view], level: 2)
426
428
  fname = File.basename(draft)
427
429
  noext = fname.sub(/.lt3$/, "")
428
430
  vdir = @root/:views/view
@@ -435,12 +437,12 @@ class RuneBlog
435
437
  end
436
438
 
437
439
  def _post_metadata(draft, pdraft)
438
- log!(enter: __method__, args: [draft, pdraft])
440
+ log!(enter: __method__, args: [draft, pdraft], level: 2)
439
441
  # FIXME store this somewhere
440
442
  fname = File.basename(draft) # 0001-this-is-a-post.lt3
441
443
  nslug = fname.sub(/.lt3$/, "") # 0001-this-is-a-post
442
444
  aslug = nslug.sub(/\d\d\d\d-/, "") # this-is-a-post
443
- pnum = nslug[0..3] # 0001
445
+ pnum = nslug[0..3] # 0001
444
446
  Dir.chdir(pdraft) do
445
447
  excerpt = File.read("teaser.txt")
446
448
  date = _retrieve_metadata(:date)
@@ -470,7 +472,7 @@ class RuneBlog
470
472
  end
471
473
 
472
474
  def copy_widget_html(view)
473
- log!(enter: __method__)
475
+ log!(enter: __method__, level: 2)
474
476
  vdir = @root/:views/view
475
477
  remote = vdir/:remote
476
478
  wdir = vdir/:themes/:standard/:widgets
@@ -481,12 +483,15 @@ class RuneBlog
481
483
  create_dirs(rem)
482
484
  files = Dir[w/"*"]
483
485
  files = files.select {|x| x =~ /(html|css)$/ }
484
- files.each {|file| system!("cp #{file} #{rem}") }
486
+ # files.each {|f| STDERR.puts " #{f.inspect}" }
487
+ tag = File.basename(w)
488
+ # STDERR.puts "--- tag: #{tag.inspect}"
489
+ files.each {|file| system!("cp #{file} #{rem}", show: (tag == "zzz")) }
485
490
  end
486
491
  end
487
492
 
488
493
  def _handle_post(draft, view)
489
- log!(enter: __method__, args: [draft, view])
494
+ log!(enter: __method__, args: [draft, view], level: 2)
490
495
  # break into separate methods?
491
496
 
492
497
  fname = File.basename(draft) # 0001-this-is-a-post.lt3
@@ -515,7 +520,7 @@ class RuneBlog
515
520
  end
516
521
 
517
522
  def generate_post(draft)
518
- log!(enter: __method__, args: [draft])
523
+ log!(enter: __method__, args: [draft], level: 1)
519
524
  views = _get_views(draft)
520
525
  views.each do |view|
521
526
  _handle_post(draft, view)
@@ -561,7 +566,7 @@ class RuneBlog
561
566
  end
562
567
 
563
568
  def remove_post(num)
564
- log!(enter: __method__, args: [num])
569
+ log!(enter: __method__, args: [num], level: 1)
565
570
  raise ArgumentError unless num.is_a?(Integer)
566
571
  # FIXME update original draft .views
567
572
  tag = prefix(num)
@@ -578,7 +583,7 @@ class RuneBlog
578
583
  end
579
584
 
580
585
  def undelete_post(num)
581
- log!(enter: __method__, args: [num])
586
+ log!(enter: __method__, args: [num], level: 1)
582
587
  raise ArgumentError unless num.is_a?(Integer)
583
588
  files = Find.find(@root/:views).to_a
584
589
  tag = prefix(num)
@@ -594,14 +599,14 @@ class RuneBlog
594
599
  end
595
600
 
596
601
  def delete_draft(num)
597
- log!(enter: __method__, args: [num])
602
+ log!(enter: __method__, args: [num], level: 1)
598
603
  raise ArgumentError unless num.is_a?(Integer)
599
604
  tag = prefix(num)
600
605
  system!("rm -rf #@root/drafts/#{tag}-*")
601
606
  end
602
607
 
603
608
  def make_slug(meta)
604
- log!(enter: __method__, args: [meta])
609
+ log!(enter: __method__, args: [meta], level: 3)
605
610
  raise ArgumentError unless meta.title.is_a?(String)
606
611
  label = '%04d' % meta.num # FIXME can do better
607
612
  slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
@@ -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.43"
5
+ VERSION = "0.2.44"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -8,7 +8,7 @@ class RuneBlog::View
8
8
  include RuneBlog::Helpers
9
9
 
10
10
  def initialize(name)
11
- log!(enter: __method__, args: [name])
11
+ log!(enter: __method__, args: [name], level: 3)
12
12
  raise NoBlogAccessor if RuneBlog.blog.nil?
13
13
  @blog = RuneBlog.blog
14
14
  @name = name
@@ -17,27 +17,23 @@ class RuneBlog::View
17
17
  end
18
18
 
19
19
  def dir
20
- log!(enter: __method__)
21
20
  @blog.root + "/views/#@name/"
22
21
  end
23
22
 
24
23
  def local_index
25
- log!(enter: __method__)
26
24
  dir + "/remote/index.html"
27
25
  end
28
26
 
29
27
  def index
30
- log!(enter: __method__)
31
28
  dir + "index.html"
32
29
  end
33
30
 
34
31
  def to_s
35
- log!(enter: __method__)
36
32
  @name
37
33
  end
38
34
 
39
35
  def publishable_files
40
- log!(enter: __method__)
36
+ log!(enter: __method__, level: 2)
41
37
  vdir = dir()
42
38
  remote = local_index()
43
39
  files = [remote]
@@ -55,12 +51,10 @@ class RuneBlog::View
55
51
  end
56
52
 
57
53
  def can_publish?
58
- log!(enter: __method__)
59
54
  @can_publish
60
55
  end
61
56
 
62
57
  def recent?(file)
63
- log!(enter: __method__, args: [file])
64
58
  File.mtime(file) > File.mtime("#{self.dir()}/last_published")
65
59
  rescue
66
60
  true
@@ -2,7 +2,7 @@
2
2
  LEXT = ".lt3"
3
3
 
4
4
  def stale?(src, dst, force = false)
5
- log!(enter: __method__, args: [src, dst])
5
+ log!(enter: __method__, args: [src, dst], level: 3)
6
6
  raise "Source #{src} not found in #{Dir.pwd}" unless File.exist?(src)
7
7
  return true if force
8
8
  return true unless File.exist?(dst)
@@ -29,7 +29,7 @@ LEXT = ".lt3"
29
29
  STDERR.puts "#{indent} -- ^ Already up to date!" if debug
30
30
  return
31
31
  end
32
- rc = system!("livetext #{src} >#{dst}")
32
+ rc = system("livetext #{src} >#{dst}")
33
33
  STDERR.puts "...completed (shell returned #{rc})" if debug
34
34
  system!("cp #{dst} #{copy}") if copy
35
35
  end
@@ -30,11 +30,6 @@ end
30
30
  def make_post(x, title, teaser, body, views=[])
31
31
  debug " make_post #{bold(title)}"
32
32
  x.create_new_post(title, true, teaser: teaser, body: body, views: views)
33
- views.each do |view|
34
- debug
35
- debug "** generate_index #{bold(view)}"
36
- x.generate_index(view)
37
- end # recent.html
38
33
  end
39
34
 
40
35
  def show_lines(text)
@@ -70,6 +65,9 @@ File.open(".blogs/views/around_austin/themes/standard/global.lt3", "a") do |f|
70
65
  end
71
66
  ####
72
67
 
68
+ debug("** generate_view: #{bold('around_austin')}")
69
+ x.generate_view("around_austin")
70
+
73
71
  debug("-- change_view: #{bold('around_austin')}")
74
72
  x.change_view("around_austin") # 1 2 7 8 9
75
73
 
@@ -136,8 +134,10 @@ in 2005.
136
134
  BODY
137
135
 
138
136
  debug
139
- debug("** generate_view: #{bold('around_austin')}")
140
- x.generate_view("around_austin")
137
+ debug "** generate_index #{bold("around_austin")}"
138
+ x.generate_index("around_austin")
139
+
140
+ debug
141
141
  x.change_view("around_austin")
142
142
  debug
143
143
 
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.43
4
+ version: 0.2.44
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-10-15 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -67,9 +67,6 @@ files:
67
67
  - empty_view/remote/etc/GIT_IS_DUMB
68
68
  - empty_view/remote/navbar/GIT_IS_DUMB
69
69
  - empty_view/remote/permalink/GIT_IS_DUMB
70
- - empty_view/remote/widgets/links/list.data
71
- - empty_view/remote/widgets/news/list.data
72
- - empty_view/remote/widgets/pages/list.data
73
70
  - empty_view/themes/standard/README
74
71
  - empty_view/themes/standard/blog/generate.lt3
75
72
  - empty_view/themes/standard/blog/head.lt3
@@ -82,6 +79,7 @@ files:
82
79
  - empty_view/themes/standard/global.lt3
83
80
  - empty_view/themes/standard/navbar/about.lt3
84
81
  - empty_view/themes/standard/navbar/contact.lt3
82
+ - empty_view/themes/standard/navbar/faq.lt3
85
83
  - empty_view/themes/standard/navbar/navbar.lt3
86
84
  - empty_view/themes/standard/post/generate.lt3
87
85
  - empty_view/themes/standard/post/head.lt3
@@ -89,6 +87,10 @@ files:
89
87
  - empty_view/themes/standard/post/permalink.lt3
90
88
  - empty_view/themes/standard/widgets/README
91
89
  - empty_view/themes/standard/widgets/ad/ad.lt3
90
+ - empty_view/themes/standard/widgets/ad/ad1.png
91
+ - empty_view/themes/standard/widgets/ad/ad2.png
92
+ - empty_view/themes/standard/widgets/ad/ad3.png
93
+ - empty_view/themes/standard/widgets/ad/ad4.png
92
94
  - empty_view/themes/standard/widgets/bydates/README
93
95
  - empty_view/themes/standard/widgets/bydates/bydates.lt3
94
96
  - empty_view/themes/standard/widgets/bydates/bydates.rb
@@ -1,3 +0,0 @@
1
- https://www.mensa.org, no, Mensa International
2
- http://space.com, yes, Space.com: NASA, Space Exploration and Astronomy News
3
- https://arstechnica.com, no, Ars Technica
@@ -1,4 +0,0 @@
1
- https://techcrunch.com/2019/09/16/fossa-scores-8-5-million-series-a-to-help-enterprise-manage-open-source-licenses/, yes, FOSSA scores \$8.5 million Series A to help enterprise manage open-source licenses
2
- https://techcrunch.com/2019/09/17/spacexs-orbital-starship-prototype-construction-progress-detailed-in-new-photos/, yes, SpaceX’s orbital Starship prototype construction progress detailed in new photos
3
- https://developers.googleblog.com/2019/05/Flutter-io19.html, yes, Flutter: a Portable UI Framework for Mobile, Web, Embedded, and Desktop
4
- https://jaycarlson.net/microcontrollers/, no, The Amazing \$1 Microcontroller (2017)
@@ -1,4 +0,0 @@
1
- faq.html,Frequently Asked Questions
2
- like-dislike.html,Likes and Dislikes
3
- disclaim.html,Disclaimer
4
- lifestory.html,My Life Story