livetext 0.8.64 → 0.8.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/livetext +7 -0
- data/lib/livetext.rb +1 -1
- metadata +2 -3
- data/plugin/liveblog.rb +0 -229
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 408bbc63240aa88a4e55b1f64b64893e2a246887a018269e0dd5c778601f26be
|
4
|
+
data.tar.gz: bd7880ff23cc0bbb71f4e3b752a821ee9eff7eda03748705350a1efad106fb28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6643114bde626f1abe795ddd1c9bfeefffdfbdc66293b9c852aacdc244d9a50e96eeb09f6c281105a4a58448e1bd15ef7445913e08d299852a281495856b9b87
|
7
|
+
data.tar.gz: d5e20e7d3d22bdad2e74d0bc98acc05bf05fb457dd45f06f156ed1dd903e9c5cf5ef5d229f90472e488b0e4e9a8d534b5748c2eb97ce179418742dc4eb8d8dfb
|
data/bin/livetext
CHANGED
@@ -43,6 +43,10 @@ def usage
|
|
43
43
|
Turn on backtrace:
|
44
44
|
livetext -b
|
45
45
|
livetext --backtrace
|
46
|
+
|
47
|
+
Install plugin:
|
48
|
+
livetext -i filename.rb
|
49
|
+
livetext -install filename.rb
|
46
50
|
EOF
|
47
51
|
puts
|
48
52
|
exit
|
@@ -71,6 +75,9 @@ loop do
|
|
71
75
|
x.process(src)
|
72
76
|
when "-h", "--help"
|
73
77
|
usage
|
78
|
+
when "-i", "--install"
|
79
|
+
lib = ARGV.shift
|
80
|
+
system("cp #{lib} #{Livetext::Path}/../plugin/")
|
74
81
|
when Object
|
75
82
|
x.process_file(arg, @backtrace)
|
76
83
|
end
|
data/lib/livetext.rb
CHANGED
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.
|
4
|
+
version: 0.8.65
|
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-03-
|
11
|
+
date: 2019-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -28,7 +28,6 @@ files:
|
|
28
28
|
- livetext.gemspec
|
29
29
|
- plugin/bookish.rb
|
30
30
|
- plugin/calibre.rb
|
31
|
-
- plugin/liveblog.rb
|
32
31
|
- plugin/livemagick.rb
|
33
32
|
- plugin/markdown.rb
|
34
33
|
- plugin/pyggish.rb
|
data/plugin/liveblog.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'pp'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
require 'runeblog' # Now depends explicitly
|
6
|
-
|
7
|
-
def quote
|
8
|
-
_passthru "<blockquote>"
|
9
|
-
_passthru _body
|
10
|
-
_passthru "</blockquote>"
|
11
|
-
_optional_blank_line
|
12
|
-
end
|
13
|
-
|
14
|
-
class ::Livetext::Functions # do this differently??
|
15
|
-
|
16
|
-
def asset # FIXME this is baloney...
|
17
|
-
raise "meh"
|
18
|
-
param = ::Livetext::Functions.param
|
19
|
-
context = ::Livetext::Functions.context
|
20
|
-
main = context.eval("@main") rescue "NO MAIN?"
|
21
|
-
@meta = main.instance_eval("@main.instance_eval { @meta }")
|
22
|
-
@config = main.instance_eval("@main.instance_eval { @config }")
|
23
|
-
@root = @config.root
|
24
|
-
|
25
|
-
text, name = param.split("|")
|
26
|
-
|
27
|
-
# FIXME how should this work?
|
28
|
-
view = @blog.view
|
29
|
-
url = find_asset(name)
|
30
|
-
"<a href='#{url}'>#{text}</a>"
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
### inset
|
36
|
-
|
37
|
-
def inset
|
38
|
-
lines = _body
|
39
|
-
box = []
|
40
|
-
lines.each do |line|
|
41
|
-
line = line.dup
|
42
|
-
if line[0] == "/" # Only into inset
|
43
|
-
line[0] = ' '
|
44
|
-
box << line
|
45
|
-
line.replace(" ")
|
46
|
-
end
|
47
|
-
if line[0] == "|" # Into inset and body
|
48
|
-
line[0] = ' '
|
49
|
-
box << line
|
50
|
-
end
|
51
|
-
_passthru(line)
|
52
|
-
end
|
53
|
-
lr = _args.first
|
54
|
-
wide = _args[1] || "25"
|
55
|
-
_passthru "<div style='float:#{lr}; width: #{wide}%; padding:8px; padding-right:12px; font-family:verdana'>"
|
56
|
-
_passthru '<b><i>'
|
57
|
-
_passthru box.join("<br>")
|
58
|
-
_passthru_noline '</i></b></div>'
|
59
|
-
_optional_blank_line
|
60
|
-
end
|
61
|
-
|
62
|
-
### copy_asset
|
63
|
-
|
64
|
-
def copy_asset(asset)
|
65
|
-
vdir = @blog.view.dir
|
66
|
-
return if File.exist?(vdir + "/assets/" + asset)
|
67
|
-
top = vdir + "/../../assets/"
|
68
|
-
if File.exist?(top + asset)
|
69
|
-
system("cp #{top}/#{asset} #{vdir}/assets/#{asset}")
|
70
|
-
return
|
71
|
-
end
|
72
|
-
raise "Can't find #{asset.inspect}"
|
73
|
-
end
|
74
|
-
|
75
|
-
#############
|
76
|
-
|
77
|
-
def init_liveblog # FIXME - a lot of this logic sucks
|
78
|
-
@blog, num = Livetext.parameters
|
79
|
-
@meta = OpenStruct.new
|
80
|
-
@meta.num = num
|
81
|
-
@root = @blog.root rescue nil
|
82
|
-
@view = @blog.view.name rescue nil
|
83
|
-
@vdir = @blog.view.dir rescue nil
|
84
|
-
@body = ""
|
85
|
-
end
|
86
|
-
|
87
|
-
def _errout(*args)
|
88
|
-
::STDERR.puts *args
|
89
|
-
end
|
90
|
-
|
91
|
-
def _passthru(line, context = nil)
|
92
|
-
return if line.nil?
|
93
|
-
line = _formatting(line, context)
|
94
|
-
@body << line + "\n"
|
95
|
-
@body << "<p>" if line.empty? && ! @_nopara
|
96
|
-
end
|
97
|
-
|
98
|
-
def _passthru_noline(line, context = nil)
|
99
|
-
return if line.nil?
|
100
|
-
line = _formatting(line, context)
|
101
|
-
@body << line
|
102
|
-
@body << "<p>" if line.empty? && ! @_nopara
|
103
|
-
end
|
104
|
-
|
105
|
-
def title
|
106
|
-
title = @_data.chomp
|
107
|
-
@meta.title = title
|
108
|
-
@body << "<h1>#{title}</h1>"
|
109
|
-
_optional_blank_line
|
110
|
-
end
|
111
|
-
|
112
|
-
def pubdate
|
113
|
-
_debug "data = #@_data"
|
114
|
-
# Check for discrepancy?
|
115
|
-
match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
|
116
|
-
junk, y, m, d = match.to_a
|
117
|
-
y, m, d = y.to_i, m.to_i, d.to_i
|
118
|
-
@meta.date = ::Date.new(y, m, d)
|
119
|
-
@meta.pubdate = "%04d-%02d-%02d" % [y, m, d]
|
120
|
-
_optional_blank_line
|
121
|
-
end
|
122
|
-
|
123
|
-
def image # primitive so far
|
124
|
-
_debug "img: huh? <img src=#{_args.first}></img>"
|
125
|
-
fname = _args.first
|
126
|
-
path = "../assets/#{fname}"
|
127
|
-
@body << "<img src=#{path}></img>"
|
128
|
-
_optional_blank_line
|
129
|
-
end
|
130
|
-
|
131
|
-
def tags
|
132
|
-
_debug "args = #{_args}"
|
133
|
-
@meta.tags = _args.dup || []
|
134
|
-
_optional_blank_line
|
135
|
-
end
|
136
|
-
|
137
|
-
def views
|
138
|
-
_debug "data = #{_args}"
|
139
|
-
@meta.views = _args.dup # + ["main"]
|
140
|
-
_optional_blank_line
|
141
|
-
end
|
142
|
-
|
143
|
-
def pin
|
144
|
-
_debug "data = #{_args}"
|
145
|
-
# verify only already-specified views?
|
146
|
-
@meta.pinned = _args.dup
|
147
|
-
_optional_blank_line
|
148
|
-
end
|
149
|
-
|
150
|
-
# def liveblog_version
|
151
|
-
# end
|
152
|
-
|
153
|
-
def list
|
154
|
-
@body << "<ul>"
|
155
|
-
_body {|line| @body << "<li>#{line}</li>" }
|
156
|
-
@body << "</ul>"
|
157
|
-
_optional_blank_line
|
158
|
-
end
|
159
|
-
|
160
|
-
def list!
|
161
|
-
@body << "<ul>"
|
162
|
-
lines = _body.each # {|line| @body << "<li>#{line}</li>" }
|
163
|
-
loop do
|
164
|
-
line = lines.next
|
165
|
-
line = _formatting(line)
|
166
|
-
if line[0] == " "
|
167
|
-
@body << line
|
168
|
-
else
|
169
|
-
@body << "<li>#{line}</li>"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
@body << "</ul>"
|
173
|
-
_optional_blank_line
|
174
|
-
end
|
175
|
-
|
176
|
-
def asset
|
177
|
-
@meta.assets ||= {}
|
178
|
-
list = _args
|
179
|
-
# For now: copies, doesn't keep record
|
180
|
-
# Later: Add to file and uniq; use in publishing
|
181
|
-
list.each {|asset| copy_asset(asset) }
|
182
|
-
_optional_blank_line
|
183
|
-
end
|
184
|
-
|
185
|
-
def assets
|
186
|
-
@meta.assets ||= []
|
187
|
-
@meta.assets += _body
|
188
|
-
_optional_blank_line
|
189
|
-
end
|
190
|
-
|
191
|
-
def write_post(meta)
|
192
|
-
save = Dir.pwd
|
193
|
-
@postdir.gsub!(/\/\//, "/") # FIXME unneeded?
|
194
|
-
Dir.mkdir(@postdir) unless Dir.exist?(@postdir) # FIXME remember assets!
|
195
|
-
Dir.chdir(@postdir)
|
196
|
-
meta.views = meta.views.join(" ")
|
197
|
-
meta.tags = meta.tags.join(" ") rescue ""
|
198
|
-
File.write("body.txt", @body) # Actually HTML...
|
199
|
-
File.write("teaser.txt", meta.teaser)
|
200
|
-
|
201
|
-
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
202
|
-
|
203
|
-
fname2 = "metadata.txt"
|
204
|
-
f2 = File.open(fname2, "w") do |f2|
|
205
|
-
fields.each {|fld| f2.puts "#{fld}: #{meta.send(fld)}" }
|
206
|
-
end
|
207
|
-
Dir.chdir(save)
|
208
|
-
rescue => err
|
209
|
-
puts "err = #{err}"
|
210
|
-
puts err.backtrace.join("\n")
|
211
|
-
end
|
212
|
-
|
213
|
-
def teaser
|
214
|
-
@meta.teaser = _body_text
|
215
|
-
@body << @meta.teaser + "\n"
|
216
|
-
# FIXME
|
217
|
-
end
|
218
|
-
|
219
|
-
def finalize
|
220
|
-
if @blog.nil?
|
221
|
-
puts @body
|
222
|
-
return
|
223
|
-
end
|
224
|
-
@slug = @blog.make_slug(@meta)
|
225
|
-
@postdir = @blog.view.dir + "/#@slug"
|
226
|
-
write_post(@meta) # FIXME
|
227
|
-
@meta
|
228
|
-
end
|
229
|
-
|