jekyll-rdfa 0.0.0

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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll-rdfa.rb +66 -0
  3. metadata +48 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a59f920826b4e3710f65ffb0518103b5cc914cff
4
+ data.tar.gz: 327f33616c9e8050da6bbccaa7aca8d94a6b2c94
5
+ SHA512:
6
+ metadata.gz: 5e1b4a2c37a117af5e062c2f107e790d9546cca52088c32eab12b132ef0fa271cd34437d30163f4e4cd2b143b003e86fbf1202c938428f632263b5254f00eb01
7
+ data.tar.gz: ffb83e56b25d0268586dedea889fefbc81ba096659cc032568300e633aa7c6ffb9da810d87cf023cab8f375b555416af4d913ec3f7513430e72229f99df4357e
@@ -0,0 +1,66 @@
1
+ module Jekyll
2
+ class RdfaPage < Page
3
+ end
4
+
5
+ class RdfaGenerator < Generator
6
+ priority :low
7
+ safe true
8
+
9
+ def generate(site)
10
+ require 'fileutils'
11
+ require 'json'
12
+ require 'json/ld'
13
+ require 'rdf'
14
+ require 'rdf/turtle'
15
+ require 'rdf/rdfa'
16
+
17
+ converter = site.getConverterImpl(Jekyll::Converters::Markdown)
18
+
19
+ graph = RDF::Graph.new
20
+ site.posts.each do |post|
21
+ html = converter.convert(post.content)
22
+
23
+ attribs = {}
24
+ attribs[:vocab] = post.data["vocab"] if post.data.member? "vocab"
25
+ if post.data.member? "resource"
26
+ attribs[:resource] = post.data["resource"]
27
+ attribs[:typeof] = post.data["typeof"] if post.data.member? "typeof"
28
+ end
29
+ if post.data.member? "prefix"
30
+ prefixes = post.data["prefix"]
31
+ .to_a.map { |key, value| "#{key}: #{value}" }
32
+ .join " "
33
+ attribs[:prefix] = prefixes
34
+ end
35
+
36
+ unless attribs.empty?
37
+ markup = attribs
38
+ .to_a
39
+ .map { |key, value| " #{key}='#{value}'"}
40
+ .join ""
41
+ html = "<div#{markup}>#{html}</div>"
42
+ end
43
+ # puts post.inspect
44
+ # puts html
45
+ # puts
46
+ graph.from_rdfa html
47
+ end
48
+
49
+ dirname = "_linked-data"
50
+ FileUtils.mkpath(dirname) unless File.exists?(dirname)
51
+
52
+ File.open("#{dirname}/posts.ttl", 'w') do |file|
53
+ file.write(graph.to_ttl)
54
+ end
55
+ site.static_files << Jekyll::StaticFile.new(
56
+ site, "_linked-data", "", "posts.ttl"
57
+ )
58
+ File.open("#{dirname}/posts.json", 'w') do |file|
59
+ file.write(graph.dump(:jsonld, standard_prefixes: true))
60
+ end
61
+ site.static_files << Jekyll::StaticFile.new(
62
+ site, "_linked-data", "", "posts.json"
63
+ )
64
+ end
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-rdfa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Rochester
8
+ - Purdom Lindblad
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-10-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: |-
15
+ A Jekyll generator to scan for RDFa-encoded data
16
+ in posts and dumps the entire graph out to a JSON-LD and Turtle
17
+ file.
18
+ email: erochest@virginia.edu
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - lib/jekyll-rdfa.rb
24
+ homepage: http://www.ericrochester.com/jekyll-rdfa/
25
+ licenses:
26
+ - Apache-2
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.4.8
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: A Jekyll generator for RDFa.
48
+ test_files: []