livetext 0.8.43 → 0.8.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/livetext.rb +18 -13
  3. data/plugin/liveblog.rb +40 -32
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f616a0419bfa694f6b124dd9a9951571f5e9ca86f62c29d6c9f594a680b5abc
4
- data.tar.gz: cf4ea38b26db10bd5756f3a6a37010b9d5a16af570114222b5ae35d6160a46ee
3
+ metadata.gz: fe26e3a5a5777c7242d5646bc6096ed115a5e58d63f9e88f0b2ca98cf2c2871a
4
+ data.tar.gz: 5c5448ea8b232973e0ee3998f94495db6b74aad14e7a14e22e63eabd028e486f
5
5
  SHA512:
6
- metadata.gz: b195ba333856b2d1ac0e4a98b1a9cf1bec33f804eef68f11d8600a7e3e5e2ff4c529d2d06d6b82a4ab9871a6f86adbc44d8810b1b6711dfa163e949d10a17a1a
7
- data.tar.gz: 7868ec91b536e5beca57b7bd955907935941b12e677ece9a6af886d377d32a17af810b94ccaddfe64e700be8d5589399b71af331777ede6ce841cdff59dc3be2
6
+ metadata.gz: c461c3f6a2a04dcce45120202d9c24d781085e5e906eec6fec97e02cc9a7e3a73e8334643941f458cc32e99d8a5bce5cbc840fc10c466b9ab9d4fe90fc626544
7
+ data.tar.gz: 572562a687cd022b5d7be7ab3a86e2bd6885232d8c4a673f13a691a93df7d794a822c9d0ea54998ec6d301e32d2a3bc932325918f2af4e18ca3b185b84df5f71
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.43"
2
+ VERSION = "0.8.44"
3
3
  end
4
4
 
5
5
  $Livetext = Livetext
@@ -28,18 +28,22 @@ class Livetext
28
28
  include Livetext::Standard
29
29
  include Livetext::UserAPI
30
30
 
31
- Disallowed = [:nil?, :===, :=~, :!~, :eql?, :hash, :<=>,
32
- :class, :singleton_class, :clone, :dup, :taint, :tainted?,
33
- :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?,
34
- :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
35
- :private_methods, :public_methods, :instance_variables,
36
- :instance_variable_get, :instance_variable_set,
37
- :instance_variable_defined?, :remove_instance_variable,
38
- :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send,
39
- :respond_to?, :extend, :display, :method, :public_method,
40
- :singleton_method, :define_singleton_method, :object_id, :to_enum,
41
- :enum_for, :pretty_inspect, :==, :equal?, :!, :!=, :instance_eval,
42
- :instance_exec, :__send__, :__id__, :__binding__]
31
+ Disallowed = [:nil?, :===, :=~, :!~, :eql?, :hash, :<=>,
32
+ :class, :singleton_class, :clone, :dup, :taint, :tainted?,
33
+ :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?,
34
+ :to_s, :inspect, :methods, :singleton_methods, :protected_methods,
35
+ :private_methods, :public_methods, :instance_variables,
36
+ :instance_variable_get, :instance_variable_set,
37
+ :instance_variable_defined?, :remove_instance_variable,
38
+ :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send,
39
+ :respond_to?, :extend, :display, :method, :public_method,
40
+ :singleton_method, :define_singleton_method, :object_id, :to_enum,
41
+ :enum_for, :pretty_inspect, :==, :equal?, :!, :!=, :instance_eval,
42
+ :instance_exec, :__send__, :__id__, :__binding__]
43
+
44
+ class << self
45
+ attr_accessor :parameters # from outside world (process_text)
46
+ end
43
47
 
44
48
  def initialize(parent, output = nil)
45
49
  @parent = parent
@@ -124,6 +128,7 @@ class Livetext
124
128
  enum = text.each
125
129
  @backtrace = false
126
130
  @main.source(enum, fname, 0)
131
+ Livetext.parameters = args # e.g., for liveblog
127
132
  loop do
128
133
  line = @main.nextline
129
134
  break if line.nil?
data/plugin/liveblog.rb CHANGED
@@ -30,14 +30,6 @@ class ::Livetext::Functions # do this differently??
30
30
 
31
31
  end
32
32
 
33
-
34
- begin
35
- ThisBlog
36
- rescue
37
- ThisBlog = RuneBlog.new
38
- # ThisConfig = ThisBlog.open_blog
39
- end
40
-
41
33
  ### find_asset
42
34
 
43
35
  def find_asset(asset)
@@ -66,22 +58,23 @@ end
66
58
  #############
67
59
 
68
60
  def init_liveblog # FIXME - a lot of this logic sucks
69
- @blog = ThisBlog
70
- @config = ThisBlog
61
+ @blog, @meta = Livetext.parameters
62
+ @config = @blog.config
71
63
  @root = @config.root
72
- @title = ""
73
- @teaser = ""
74
- @body = ""
64
+ @view = @blog.view.name
65
+ @vdir = @blog.view.dir
66
+ @title, @teaser = meta.title, meta.teaser
75
67
  @body = ""
76
- @meta = ::OpenStruct.new
77
-
78
- @publish ||= {}
79
- @config.views.each do |view|
80
- publish = @config.viewdir(view) + "publish"
81
- raise "File '#{publish}' not found" unless File.exist?(publish)
82
- lines = File.readlines(publish).map {|x| x.chomp }
83
- @publish[view] = lines
84
- end
68
+ @slug = @blog.make_slug(meta)
69
+ @postdir = @blog.view.dir + "/#@slug"
70
+
71
+ # @publish ||= {}
72
+ # @config.views.each do |view|
73
+ # publish = @config.viewdir(view) + "publish"
74
+ # raise "File '#{publish}' not found" unless File.exist?(publish)
75
+ # lines = File.readlines(publish).map {|x| x.chomp }
76
+ # @publish[view] = lines
77
+ # end
85
78
  end
86
79
 
87
80
  def _errout(*args)
@@ -96,12 +89,14 @@ def _passthru(line, context = nil)
96
89
  end
97
90
 
98
91
  def title
99
- @meta.title = @_data
100
- @body << "<h1>#{@meta.title}</h1>"
92
+ title = @_data
93
+ raise "Title discrepancy? Found #{title.inspect} != #{@title.inspect}"
94
+ @body << "<h1>#@title</h1>"
101
95
  end
102
96
 
103
97
  def pubdate
104
98
  _debug "data = #@_data"
99
+ # Check for discrepancy?
105
100
  match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
106
101
  junk, y, m, d = match.to_a
107
102
  y, m, d = y.to_i, m.to_i, d.to_i
@@ -169,17 +164,30 @@ def assets
169
164
  # STDERR.puts red("\n [DEBUG] ") + "Assets: #{_body.inspect}"
170
165
  end
171
166
 
172
- def finalize
173
- @meta.body = @body
174
- File.open("/tmp/lblog.txt", "w") do |f|
175
- f.puts
176
- f.puts @meta.inspect
177
- end
178
- @meta
179
- end
167
+ def write_post(meta)
168
+ save = Dir.pwd
169
+ Dir.chdir(@postdir)
170
+ meta.views = meta.views.join(" ")
171
+ meta.tags = meta.tags.join(" ")
172
+ File.write("index.html", @body)
173
+ File.write("teaser.txt", meta.teaser)
174
+
175
+ fields = [:num, :title, :date, :pubdate, :views, :tags]
176
+
177
+ fname2 = "metadata.txt"
178
+ f2 = File.open(fname2, "w") do |f2|
179
+ fields.each {|fld| f2.puts "#{fld}: #{meta.send(fld)}" }
180
+ end
181
+ Dir.chdir(save)
182
+ end
180
183
 
181
184
  def teaser
182
185
  @meta.teaser = _body_text
183
186
  @body << @meta.teaser + "\n"
184
187
  # FIXME
185
188
  end
189
+
190
+ def finalize
191
+ write_post(@meta) # FIXME
192
+ end
193
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livetext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.43
4
+ version: 0.8.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: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2018-12-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com