liveblog 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/liveblog.rb +27 -6
- metadata +23 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17a23b8215e37db1ab75a36b3fd42555339128e0
|
4
|
+
data.tar.gz: e404b6d3886c2f0e2e746f01ce239f0ad0981436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3a70ca3de1c7e834c5a42d0f2bf66a18817e3a57bad7ea8ca7482596e78d91af735efacbe566eece5a0a98aed76faad4fd21d3c2e84f0136bee8f73c0cd2cd
|
7
|
+
data.tar.gz: d7f0f7004c33f48ed0de4ed05abb35c71fe2f45ab307a025724682b799b2c72bd982aa1890b49661d0c9b344a21cf26fc80b6fd480feba858506a74d90bb1a3a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/liveblog.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'time'
|
6
6
|
require 'dynarex'
|
7
7
|
require 'fileutils'
|
8
|
+
require 'martile'
|
8
9
|
|
9
10
|
class LiveBlog
|
10
11
|
|
@@ -16,9 +17,7 @@ class LiveBlog
|
|
16
17
|
@t = Time.now
|
17
18
|
dxfile = File.join(path(), 'index.xml')
|
18
19
|
|
19
|
-
puts 'fxfile: ' + dxfile.inspect
|
20
20
|
File.exists?(dxfile) ? @dx = Dynarex.new(dxfile) : new_file()
|
21
|
-
puts '@dx : ' + @dx.inspect
|
22
21
|
|
23
22
|
end
|
24
23
|
|
@@ -41,15 +40,18 @@ EOF
|
|
41
40
|
|
42
41
|
end
|
43
42
|
|
44
|
-
def add_entry(hashtag,
|
43
|
+
def add_entry(hashtag, raw_entry)
|
45
44
|
|
45
|
+
entry = String.new(raw_entry)
|
46
46
|
a = @dx.all
|
47
47
|
rec = a.find {|section| section.x.lstrip.lines.first =~ /#\s*#{hashtag}/}
|
48
48
|
|
49
49
|
if rec then
|
50
|
-
|
50
|
+
|
51
|
+
hashtag = entry.slice!(/#\w+$/)
|
52
|
+
rec.x += "\n" + entry.rstrip
|
51
53
|
save()
|
52
|
-
|
54
|
+
|
53
55
|
[true, "%s %s/%s/index.html%s" % [entry, @urlbase, path(), hashtag]]
|
54
56
|
else
|
55
57
|
[false, 'rec not found']
|
@@ -69,6 +71,7 @@ EOF
|
|
69
71
|
|
70
72
|
@dx.save File.join(path(), 'index.xml')
|
71
73
|
File.write File.join(path(), 'index.txt'), @dx.to_s
|
74
|
+
save_html()
|
72
75
|
end
|
73
76
|
|
74
77
|
private
|
@@ -78,10 +81,28 @@ EOF
|
|
78
81
|
File.join [@t.year.to_s, Date::MONTHNAMES[@t.month].downcase[0..2], \
|
79
82
|
@t.day.to_s]
|
80
83
|
end
|
84
|
+
|
85
|
+
def save_html()
|
86
|
+
|
87
|
+
newfilepath = File.join(path(), 'formatted.xml')
|
88
|
+
FileUtils.cp File.join(path(), 'index.xml'), newfilepath
|
89
|
+
|
90
|
+
doc = Rexle.new File.read(newfilepath)
|
91
|
+
|
92
|
+
doc.root.xpath('records/section/x') do |x|
|
93
|
+
html = RDiscount.new(Martile.new(x.text).to_html).to_html
|
94
|
+
e = x.parent
|
95
|
+
x.delete
|
96
|
+
e.add Rexle.new("<x>%s</x>" % html).root
|
97
|
+
end
|
98
|
+
|
99
|
+
File.write newfilepath, doc.xml(pretty: true)
|
100
|
+
|
101
|
+
end
|
81
102
|
|
82
103
|
def ordinalize(n)
|
83
104
|
n.to_s + ( (10...20).include?(n) ? 'th' :
|
84
105
|
%w{ th st nd rd th th th th th th }[n % 10] )
|
85
106
|
end
|
86
107
|
|
87
|
-
end
|
108
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '1.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.
|
45
|
+
version: 1.5.4
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,27 @@ dependencies:
|
|
52
52
|
version: '1.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.5.
|
55
|
+
version: 1.5.4
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: martile
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.5'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.5.1
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.5'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.1
|
56
76
|
description:
|
57
77
|
email: james@r0bertson.co.uk
|
58
78
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|