livetext 0.8.42 → 0.8.43

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: c1902fcbf9b44c268b05bcd185223203bab7e985d10f36242d41d3e7b7683e56
4
- data.tar.gz: 9dcf1fe627a781be69837ac89f0d69929ed1a9cac2f1a86b576112af9361fb13
3
+ metadata.gz: 6f616a0419bfa694f6b124dd9a9951571f5e9ca86f62c29d6c9f594a680b5abc
4
+ data.tar.gz: cf4ea38b26db10bd5756f3a6a37010b9d5a16af570114222b5ae35d6160a46ee
5
5
  SHA512:
6
- metadata.gz: 89c23d7cbf0acd8fbc6841f79285d39a866c4ac6ebb25a2cf20516adf2b7ce306f8ccaf265db3223b149d864895b64e205e1d982d9aaa2554e4bf08d7e8a1f3b
7
- data.tar.gz: c4eb4e89272f1d97113a3f7c825f94ef962afdb1e515b95a0490ffee4cf4418dac92a73e723848adde8b5d077d440a778bde1e16115a69f83f856ee473163fb2
6
+ metadata.gz: b195ba333856b2d1ac0e4a98b1a9cf1bec33f804eef68f11d8600a7e3e5e2ff4c529d2d06d6b82a4ab9871a6f86adbc44d8810b1b6711dfa163e949d10a17a1a
7
+ data.tar.gz: 7868ec91b536e5beca57b7bd955907935941b12e677ece9a6af886d377d32a17af810b94ccaddfe64e700be8d5589399b71af331777ede6ce841cdff59dc3be2
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.42"
2
+ VERSION = "0.8.43"
3
3
  end
4
4
 
5
5
  $Livetext = Livetext
@@ -119,6 +119,20 @@ class Livetext
119
119
  end
120
120
  end
121
121
 
122
+ def process_text(text, *args)
123
+ text = text.split("\n") if text.is_a? String
124
+ enum = text.each
125
+ @backtrace = false
126
+ @main.source(enum, fname, 0)
127
+ loop do
128
+ line = @main.nextline
129
+ break if line.nil?
130
+ process_line(line, context)
131
+ end
132
+ val = @main.finalize if @main.respond_to? :finalize
133
+ val
134
+ end
135
+
122
136
  def process_file(fname, context=nil)
123
137
  context ||= binding
124
138
  @context = context
data/livetext.gemspec CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.files = main + misc + test
24
24
  s.homepage = 'https://github.com/Hal9000/livetext'
25
- s.license = "Ruby's license"
25
+ s.license = "Ruby"
26
26
  end
data/plugin/liveblog.rb CHANGED
@@ -23,7 +23,7 @@ class ::Livetext::Functions # do this differently??
23
23
  text, name = param.split("|")
24
24
 
25
25
  # FIXME how should this work?
26
- view = ThisBlog.view
26
+ view = @blog.view
27
27
  url = find_asset(name)
28
28
  "<a href='#{url}'>#{text}</a>"
29
29
  end
@@ -69,6 +69,7 @@ def init_liveblog # FIXME - a lot of this logic sucks
69
69
  @blog = ThisBlog
70
70
  @config = ThisBlog
71
71
  @root = @config.root
72
+ @title = ""
72
73
  @teaser = ""
73
74
  @body = ""
74
75
  @body = ""
@@ -108,15 +109,11 @@ def pubdate
108
109
  @meta.pubdate = "%04d-%02d-%02d" % [y, m, d]
109
110
  end
110
111
 
111
- # def categories # now: tags
112
- # _debug "args = #{_args}"
113
- # @meta.categories = _args # phase out
114
- # @meta.tags = _args
115
- # end
116
-
117
112
  def image # primitive so far
118
113
  _debug "img: huh? <img src=#{_args.first}></img>"
119
- @body << "<img src=#{_args.first}></img>"
114
+ fname = _args.first
115
+ path = "assets/#{fname}"
116
+ @body << "<img src=#{path}></img>"
120
117
  end
121
118
 
122
119
  def tags
@@ -174,6 +171,10 @@ end
174
171
 
175
172
  def finalize
176
173
  @meta.body = @body
174
+ File.open("/tmp/lblog.txt", "w") do |f|
175
+ f.puts
176
+ f.puts @meta.inspect
177
+ end
177
178
  @meta
178
179
  end
179
180
 
@@ -0,0 +1,185 @@
1
+ require 'ostruct'
2
+ require 'pp'
3
+ require 'date'
4
+
5
+ require 'runeblog' # Now depends explicitly
6
+
7
+ def quote
8
+ _puts "<blockquote>"
9
+ _puts _body
10
+ _puts "</blockquote>"
11
+ end
12
+
13
+ class ::Livetext::Functions # do this differently??
14
+
15
+ def asset # FIXME this is baloney...
16
+ param = ::Livetext::Functions.param
17
+ context = ::Livetext::Functions.context
18
+ main = context.eval("@main") rescue "NO MAIN?"
19
+ @meta = main.instance_eval("@main.instance_eval { @meta }")
20
+ @config = main.instance_eval("@main.instance_eval { @config }")
21
+ @root = @config.root
22
+
23
+ text, name = param.split("|")
24
+
25
+ # FIXME how should this work?
26
+ view = @blog.view
27
+ url = find_asset(name)
28
+ "<a href='#{url}'>#{text}</a>"
29
+ end
30
+
31
+ end
32
+
33
+
34
+ begin
35
+ ThisBlog
36
+ rescue
37
+ ThisBlog = RuneBlog.new
38
+ # ThisConfig = ThisBlog.open_blog
39
+ end
40
+
41
+ ### find_asset
42
+
43
+ def find_asset(asset)
44
+ views = @config.views
45
+ views.each do |view|
46
+ vdir = @config.viewdir(view)
47
+ post_dir = "#{vdir}#{@meta.slug}/assets/"
48
+ path = post_dir + asset
49
+ STDERR.puts " Seeking #{path}"
50
+ return path if File.exist?(path)
51
+ end
52
+ views.each do |view|
53
+ dir = @config.viewdir(view) + "/assets/"
54
+ path = dir + asset
55
+ STDERR.puts " Seeking #{path}"
56
+ return path if File.exist?(path)
57
+ end
58
+ top = @root + "/assets/"
59
+ path = top + asset
60
+ STDERR.puts " Seeking #{path}"
61
+ return path if File.exist?(path)
62
+
63
+ return nil
64
+ end
65
+
66
+ #############
67
+
68
+ def init_liveblog # FIXME - a lot of this logic sucks
69
+ @blog = ThisBlog
70
+ @config = ThisBlog
71
+ @root = @config.root
72
+ @title = ""
73
+ @teaser = ""
74
+ @body = ""
75
+ @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
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
+ @body << "<p>" if line == "\n" and ! @_nopara
94
+ line = _formatting(line, context)
95
+ @body << line + "\n"
96
+ end
97
+
98
+ def title
99
+ @meta.title = @_data
100
+ @body << "<h1>#{@meta.title}</h1>"
101
+ end
102
+
103
+ def pubdate
104
+ _debug "data = #@_data"
105
+ match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
106
+ junk, y, m, d = match.to_a
107
+ y, m, d = y.to_i, m.to_i, d.to_i
108
+ @meta.date = ::Date.new(y, m, d)
109
+ @meta.pubdate = "%04d-%02d-%02d" % [y, m, d]
110
+ end
111
+
112
+ def image # primitive so far
113
+ _debug "img: huh? <img src=#{_args.first}></img>"
114
+ fname = _args.first
115
+ path = "assets/#{fname}"
116
+ @body << "<img src=#{path}></img>"
117
+ end
118
+
119
+ def tags
120
+ _debug "args = #{_args}"
121
+ @meta.tags = _args
122
+ end
123
+
124
+ def views
125
+ _debug "data = #{_args}"
126
+ @meta.views = _args.dup # + ["main"]
127
+ end
128
+
129
+ def pin
130
+ _debug "data = #{_args}"
131
+ # verify only already-specified views?
132
+ @meta.pinned = _args.dup
133
+ end
134
+
135
+ # def liveblog_version
136
+ # end
137
+
138
+ def list
139
+ @body << "<ul>"
140
+ _body {|line| @body << "<li>#{line}</li>" }
141
+ @body << "</ul>"
142
+ end
143
+
144
+ def list!
145
+ @body << "<ul>"
146
+ lines = _body.each # {|line| @body << "<li>#{line}</li>" }
147
+ loop do
148
+ line = lines.next
149
+ line = _formatting(line)
150
+ if line[0] == " "
151
+ @body << line
152
+ else
153
+ @body << "<li>#{line}</li>"
154
+ end
155
+ end
156
+ @body << "</ul>"
157
+ end
158
+
159
+ def asset
160
+ @meta.assets ||= {}
161
+ list = _args
162
+ list.each {|asset| @meta.assets[asset] = find_asset(asset) }
163
+ # STDERR.puts red("\n [DEBUG] ") + "Asset(s): #{@meta.assets}"
164
+ end
165
+
166
+ def assets
167
+ @meta.assets ||= []
168
+ @meta.assets += _body
169
+ # STDERR.puts red("\n [DEBUG] ") + "Assets: #{_body.inspect}"
170
+ end
171
+
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
180
+
181
+ def teaser
182
+ @meta.teaser = _body_text
183
+ @body << @meta.teaser + "\n"
184
+ # FIXME
185
+ end
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.42
4
+ version: 0.8.43
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-22 00:00:00.000000000 Z
11
+ date: 2018-12-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com
@@ -26,12 +26,12 @@ files:
26
26
  - lib/standard.rb
27
27
  - lib/userapi.rb
28
28
  - livetext.gemspec
29
- - plugin/.calibre.rb.swp
30
29
  - plugin/bookish.rb
31
30
  - plugin/calibre.rb
32
31
  - plugin/liveblog.rb
33
32
  - plugin/livemagick.rb
34
33
  - plugin/markdown.rb
34
+ - plugin/old_liveblog.rb
35
35
  - plugin/pyggish.rb
36
36
  - plugin/tutorial.rb
37
37
  - test/affirm/kbks.jpg
@@ -127,18 +127,12 @@ files:
127
127
  - test/data/table_with_heredocs/expected-error.txt
128
128
  - test/data/table_with_heredocs/expected-output.txt
129
129
  - test/data/table_with_heredocs/source.lt3
130
- - test/lines.lt3
131
- - test/myfile.jpg
132
130
  - test/newtest
133
131
  - test/sdtest
134
- - test/somefile.jpg
135
132
  - test/test.rb
136
- - test/try.lt3
137
- - test/try2.lt3
138
- - test/try2.rb
139
133
  homepage: https://github.com/Hal9000/livetext
140
134
  licenses:
141
- - Ruby's license
135
+ - Ruby
142
136
  metadata: {}
143
137
  post_install_message:
144
138
  rdoc_options: []
Binary file
data/test/lines.lt3 DELETED
@@ -1,213 +0,0 @@
1
- tick: Single token, beginning of line
2
- `def is like a reserved word
3
-
4
- tick: Single token, middle of line
5
- They say `def is like a reserved word
6
-
7
- tick: Single token, end of line
8
- like a reserved word, is `def
9
-
10
- tick: Bracketed, normal
11
- This is `[code font] here
12
-
13
- tick: Bracketed, hits EOL
14
- This is `[code font here
15
-
16
- tick: followed by space
17
- This is not ` code
18
-
19
- tick: followed by EOL
20
- This also isn't code: `
21
-
22
- tick: Doubled, ignores comma
23
- This is ``code, of course
24
-
25
- tick: Doubled, ignores period
26
- This is ``code. Hooray, I guess.
27
-
28
- tick: Doubled, ignores right paren
29
- (By the way, this is ``code)
30
-
31
- tick: Doubled, ignores EOL
32
- Up to EOL, this is ``code
33
-
34
- uscore: Single token, beginning of line
35
- _This is italics
36
-
37
- uscore: Single token, middle of line
38
- And _this is italics
39
-
40
- uscore: Single token, end of line
41
- And so is _this
42
-
43
- uscore: Bracketed, normal
44
- The _[USS Enterprise] was here
45
-
46
- uscore: Bracketed, hits EOL
47
- Hey, it's the _[USS Enterprise
48
-
49
- uscore: followed by space
50
- This: _ is just an underscore
51
-
52
- uscore: followed by EOL
53
- This is just an underscore: _
54
-
55
- uscore: Doubled, ignores comma
56
- Just a __second, ok?
57
-
58
- uscore: Doubled, ignores period
59
- Just a __second. OK?
60
-
61
- uscore: Doubled, ignores right paren
62
- I'll (just a __second) be right there.
63
-
64
- uscore: Doubled, ignores EOL
65
- Be there in a __second
66
-
67
- Tick has precedence over underscore
68
- This is a `piece_of_code here
69
-
70
- under: Starts after double quote?
71
- He said, "_Please go away."
72
-
73
- Dollar sign followed by blank
74
- This: $ is a dollar sign
75
-
76
- Dollar sign followed by non-alpha
77
- I'd pay $3 for that
78
-
79
- Dollar sign followed by EOL
80
- This is a dollar sign: $
81
-
82
- Double dollar sign followed by blank
83
- This: $$ is not a function call
84
-
85
- Double dollar sign followed by non-alpha
86
- If I say $$-, that's not a function call
87
-
88
- Double dollar sign followed by EOL
89
- This is two dollar signs: $$
90
-
91
- Escaped *
92
- Asterisk followed by abc: \*abc
93
-
94
- Escaped _
95
- Underscore followed by abc: \_abc
96
-
97
- Escaped `
98
- Tick followed by abc: \`abc
99
-
100
- Escaped $
101
- This: \$var is not a variable
102
-
103
- Escaped $$
104
- This: \$\$func is not a function
105
-
106
- strike: Single token, beginning of line
107
- ~this - no, I mean that
108
-
109
- strike: Single token, middle of line
110
- They say ~redacted is fun
111
-
112
- strike: Single token, end of line
113
- Ignore this: ~foobar
114
-
115
- strike: Bracketed, normal
116
- This is ~[crossed out] text
117
-
118
- strike: Bracketed, hits EOL
119
- This is ~[more stuff crossed out
120
-
121
- strike: followed by space
122
- This is not ~ overstrike
123
-
124
- strike: followed by EOL
125
- This also isn't overstrike: `
126
-
127
- strike: Doubled, ignores comma
128
- This is ~~overstrike, of course
129
-
130
- strike: Doubled, ignores period
131
- This is ~~overstrike. Hooray, I guess.
132
-
133
- strike: Doubled, ignores right paren
134
- (By the way, this is ~~overstrike)
135
-
136
- strike: Doubled, ignores EOL
137
- Up to EOL, this is ~~redacted
138
-
139
- Trying $$b function, no param
140
- This is $$b being called
141
-
142
- Trying $$b function, brackets
143
- This is $$b[bold text] being called
144
-
145
- Trying $$b function, unterminated brackets
146
- This is $$b[bold text being called
147
-
148
- Trying $$b function, colon param
149
- This is $$b:token being called
150
-
151
- Try $$i
152
- There is $$i[some text] here
153
-
154
- Try $$t
155
- There is $$t[some text] here
156
-
157
- Try $$s
158
- There is $$s[some text] here
159
-
160
- Try $$bi
161
- There is $$bi[some text] here
162
-
163
- Try $$bt
164
- There is $$bt[some text] here
165
-
166
- Try $$bs
167
- There is $$bs[some text] here
168
-
169
- Try $$it
170
- There is $$it[some text] here
171
-
172
- Try $$is
173
- There is $$is[some text] here
174
-
175
- Try $$ts
176
- There is $$ts[some text] here
177
-
178
- Try $$bit
179
- There is $$bit[some text] here
180
-
181
- Try $$bis
182
- There is $$bis[some text] here
183
-
184
- Try $$bts
185
- There is $$bts[some text] here
186
-
187
- Try $$its
188
- There is $$its[some text] here
189
-
190
- Try $$bits
191
- There is $$bits[some text] here
192
-
193
- Escaped brackets inside bracketed function parameter
194
- Here is an $$t[\[:array, :expression\]] with escapes.
195
-
196
- Escape brackets inside *
197
- There are brackets *[\[\]] here
198
-
199
- Escape brackets inside _
200
- There are brackets _[\[\]] here
201
-
202
- Escape brackets inside `
203
- There are brackets `[\[\]] here
204
-
205
- Escape brackets inside ~
206
- There are brackets ~[\[\]] here
207
-
208
- Check output of $$date
209
- Today is $$date, I guess
210
-
211
- Check output of $$time
212
- Tick tock, it's $$time right now
213
-
data/test/myfile.jpg DELETED
Binary file
data/test/somefile.jpg DELETED
Binary file
data/test/try.lt3 DELETED
@@ -1,22 +0,0 @@
1
- .mixin livemagick
2
-
3
- .nopass
4
-
5
- .image 800 600 skyblue
6
- .canvas green 1 0
7
- .pen red red
8
- .font 80 AvantGarde
9
-
10
- .rectangle 250,100 300x300 green 9
11
-
12
- .text! 150,200 500x200
13
- This is
14
- only
15
- a test.
16
- .end
17
-
18
- .draw
19
-
20
- .save! somefile.jpg
21
-
22
-
data/test/try2.lt3 DELETED
@@ -1,27 +0,0 @@
1
- .mixin livemagick
2
-
3
- . nopass
4
- .nopara
5
-
6
- Here goes...
7
-
8
- .image 400 400 skyblue
9
- .canvas green 1 0
10
- .pen red red
11
- .font 80 Arial
12
-
13
- .rectangle 50,50 300x300 black 9
14
-
15
- .text! 0,150 400x200
16
- This is
17
- only
18
- a test.
19
- .end
20
-
21
- .draw
22
-
23
- Writing the file...
24
-
25
- .save! myfile.jpg
26
-
27
-
data/test/try2.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'rmagick'
2
-
3
- canvas = Magick::Draw.new
4
-
5
- canvas.fill_opacity(0)
6
- canvas.stroke('green')
7
- canvas.stroke_width(1)
8
- canvas.stroke("red")
9
-
10
- canvas.rectangle(x, y, x+width, y+height)
11
-
12
- text = "This is\n only\n a test."
13
-
14
- canvas.annotate(@image, width, height, x, y, str) do
15
- self.font_family = font
16
- self.fill = fill
17
- self.stroke = stroke
18
- self.pointsize = size
19
- self.font_weight = weight
20
- self.gravity = gravity
21
- end
22
-
23
- canvas.draw # ...
24
- canvas.save("whatever.jpg") # ...
25
-
26
-