rss_sliml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/lib/rss_sliml.rb +99 -0
- metadata +107 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a93550f8338baea8bc2c99ff56085294f81bb5a
|
4
|
+
data.tar.gz: 54ad296f00be2d312f2dcf956b4dca5f2f9d32d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3779d86643b9fd76c858d8a4df0ee7030adede01ed4079c3eebd694a4b7b06fd14fe39d1bcf1eb688d478490ef1e3431b4efbb5fd13a7639c62962084ad7012b
|
7
|
+
data.tar.gz: d00c9eebcdb2b9a8a2c0c1a8b8707c0301761db415d431b94710d07371d304170ececccdf2b90148508900514703c1a461dc22f7ce9f4d8ad974db020cb7d657
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/lib/rss_sliml.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rss_sliml.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'line-tree'
|
7
|
+
require 'rexle-builder'
|
8
|
+
|
9
|
+
|
10
|
+
class RssSliml
|
11
|
+
|
12
|
+
attr_reader :to_xslt
|
13
|
+
|
14
|
+
def initialize(sliml=nil)
|
15
|
+
|
16
|
+
|
17
|
+
sliml ||= create_sliml()
|
18
|
+
@sliml = sliml
|
19
|
+
|
20
|
+
|
21
|
+
sliml.gsub!(/\{[^\}]+/) do |x|
|
22
|
+
x.gsub(/["']?(\S*)\$(\w+)([^"']*)["']?/,'\'\1{\2}\3\'')
|
23
|
+
end
|
24
|
+
|
25
|
+
xml = LineTree.new(sliml).to_xml declaration: false, pretty: true
|
26
|
+
|
27
|
+
@recxsl = xml.gsub(/<?\$(\w+)(?:\/>)?/, '<xsl:value-of select="\1"/>')
|
28
|
+
|
29
|
+
@to_xslt = build_xslt
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_sliml()
|
35
|
+
|
36
|
+
@sliml
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def build_xslt()
|
44
|
+
|
45
|
+
|
46
|
+
xml = RexleBuilder.new
|
47
|
+
raw_a = xml.xsl_stylesheet(xmlns_xsl: \
|
48
|
+
"http://www.w3.org/1999/XSL/Transform", version: "1.1") do
|
49
|
+
xml.xsl_output(method: "html", encoding: "utf-8", indent: "yes")
|
50
|
+
|
51
|
+
xml.xsl_template(match: '/') do
|
52
|
+
xml.html do
|
53
|
+
xml.head do
|
54
|
+
xml.title do
|
55
|
+
xml.xsl_value_of(select: '/rss/channel/title')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
xml.xsl_apply_templates(select: 'rss/channel')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
xml.xsl_template(match: 'channel') do
|
64
|
+
xml.body do
|
65
|
+
xml.div do
|
66
|
+
xml.xsl_apply_templates(select: 'item')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
xml.xsl_template(match: 'item') do
|
72
|
+
xml.rec_template
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
xml2 = Rexle.new(raw_a).xml(pretty: true).gsub('xsl_apply_templates',\
|
78
|
+
'xsl:apply-templates').gsub('xsl_value_of','xsl:value-of').\
|
79
|
+
gsub('xsl_template','xsl:template').\
|
80
|
+
gsub('xmlns_xsl','xmlns:xsl').gsub('xsl_for_each','xsl:for-each').\
|
81
|
+
gsub('xsl_','xsl:')
|
82
|
+
|
83
|
+
|
84
|
+
xml2.sub('<rec_template/>', @recxsl)
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_sliml()
|
88
|
+
|
89
|
+
"div
|
90
|
+
ul
|
91
|
+
li
|
92
|
+
a {href: '$link'} $title
|
93
|
+
div
|
94
|
+
$description
|
95
|
+
"
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rss_sliml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MTEwMjEyNDIzNVoXDTE2MTEwMTEyNDIzNVowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBAM7MRKPWIJMyb3mewzm0LjK0OqnSuMOAjsOK/32y6cH4j3MAVnCAlVBxZf9R
|
19
|
+
sgsX0uG/DM8lazh5Gn7SgRq0Xe+bHep5w5UnxHC/srGLx07UE+lG4TjT90HRVR3U
|
20
|
+
bpkAr/J6pWZ+5bvptny3VPwwI8SwGL538u2vIEMwKb/YUYBbycNOm52J01XRsZcH
|
21
|
+
agcSGL0R9Z1EhFhkc4B3Re0UWDlJIWMko+5qlBBi64TuV9nX1azASzx1d+k239u6
|
22
|
+
1wVPZ0/KKsOjSo7Gbk7y7Cja+3hN6ccF4cRC7+/TrCjUJigdKa8oEhpXKc0LKZqz
|
23
|
+
rNxVzKR8+n8WcCHt+O54mFJCW/sCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUXkM2kC9IterV9ar5eydUDjahNzYwJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAJ5kbp7NG
|
27
|
+
g+buFMLAm6Pb6+KZ9tI9+Oi4KjildE7V/wiGqq5Y5hO7tlN5l4ECL8D77z0CMKBy
|
28
|
+
baIv2vfsa2+tmAuwiAZeMrvV7gSEUkLkLcD+zM8nZAZKqMVst+Iith7hxoazMNy1
|
29
|
+
uwv340kcKu9j0ks61sik1XKDqhW4KA4Fa6miHJ+/A3HvSh6bYoqGwKO4bTmyK2JF
|
30
|
+
VeQNUnK7EuQUMZqfS/xV3yXO1FkuRB7tpFirM3ljxM1QiPJp3RyTWzuRIQB89Uin
|
31
|
+
2fw8q8yRQOc7X2ecOVinC2XvC5k9WjftjIVg6rM4pBW1JWERJWizB2BUTEUOJedk
|
32
|
+
4zWjam/Q00G9Og==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rexle-builder
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.2'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.1
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.2'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.2.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: line-tree
|
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.5
|
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.5
|
76
|
+
description:
|
77
|
+
email: james@r0bertson.co.uk
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- lib/rss_sliml.rb
|
83
|
+
homepage: https://github.com/jrobertson/rss_sliml
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Generates an RSS XML stylesheet using a kind of Slim template
|
107
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|