ingo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.adoc +5 -0
  3. data/LICENSE +21 -0
  4. data/README.adoc +56 -0
  5. data/bin/ingo +20 -0
  6. data/lib/ingo.rb +108 -0
  7. metadata +64 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a47c7bce5fadf71f66343d35a49c5c7425bfdb22
4
+ data.tar.gz: 34824d2cb3fc282212a4cf755b8187c847fb250e
5
+ SHA512:
6
+ metadata.gz: d45f4f07f8151019ce16886d313cb6eefd7f6b97f1af93d5343bbd8376900d5c20e8bb51ec1cf2527a8f924aae8ffc8ea2c1b8053bb19a33efbfe4d6d3ef53c1
7
+ data.tar.gz: d9a7c90b2f79c1aab191e9fae838caddbfd34e982743d0e3b3d53b4c47b3d70f818f4c6ba7295f359c55054889a16e927aa12da6ef9f15d810aa8be42cc6f38c
data/CHANGELOG.adoc ADDED
@@ -0,0 +1,5 @@
1
+ = Changelog
2
+
3
+ == Unreleased
4
+
5
+ First version with initial feature set.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Florian Wilhelm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,56 @@
1
+ = Ingo: A static site generator built on http://asciidoctor.org/[Asciidoctor]
2
+
3
+ Ingo converts AsciiDoc files in a directory and converts them using http://asciidoctor.org/[Asciidoctor].
4
+ It is built for collecting notes in AciiDoc format and presenting them.
5
+
6
+ It is recommended to add `topics` to each file.
7
+
8
+ For example
9
+
10
+ ----
11
+ :topics: gardening, hobby, shopping
12
+ ----
13
+
14
+ defines three topics.
15
+ Ingo will create an index file for each topic linking to all documents with that topic.
16
+ Think of topics as "Categories" in wikipedia.
17
+ Ingo is meant to provide an alternative to wikis for note taking for individuals and teams.
18
+ In combination with Github/Gitlab and a CI service it can provide a similar experience for technical users.
19
+
20
+ Note that the files *must* be in a `docs` subdirectory of the project directory.
21
+ The resulting files are written to `output`.
22
+ An example project can be found at https://gitlab.com/fwilhe/berlin.
23
+
24
+ == How to build
25
+
26
+ .Install dependencies
27
+ ----
28
+ bundle install
29
+ ----
30
+
31
+ .Run tests
32
+ ----
33
+ bundle exec rake test
34
+ ----
35
+
36
+ == How to run
37
+
38
+ .Run program
39
+ ----
40
+ bin/ingo path
41
+ ----
42
+
43
+ == The name
44
+
45
+ Yes, I was thinking about https://gohugo.io/[Hugo] and just took another male name.
46
+
47
+ == Release process
48
+
49
+ This is still work in progress.
50
+ It needs automation wherever possible.
51
+
52
+ * Update changelog for upcoming release
53
+ * Remove `.unreleased` suffix from version and commit as "prepare release"
54
+ * Create and push git tag with the version number
55
+ * Build and publish the artifact(s)
56
+ * Update version and append `.unreleased` and commit as "prepare for next development iteration"
data/bin/ingo ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/ingo'
4
+
5
+ base_directory = ARGV[0]
6
+
7
+ if base_directory.nil?
8
+ puts 'This is ingo. Please provide a input directory like "ingo path/to/my/notes"'
9
+ else
10
+ if File.directory?(base_directory)
11
+ if File.directory?(base_directory + '/docs')
12
+ Class.new.extend(Ingo).convert_directory(base_directory)
13
+ Class.new.extend(Ingo).create_index_files(base_directory)
14
+ else
15
+ puts "#{base_directory}/docs is not a directory. Please consult the documentation."
16
+ end
17
+ else
18
+ puts "#{base_directory} is not a directory"
19
+ end
20
+ end
data/lib/ingo.rb ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'asciidoctor'
4
+ require 'fileutils'
5
+
6
+ module Ingo
7
+
8
+ def asciidoc_link(reference, text)
9
+ "link:#{reference}[#{text}]"
10
+ end
11
+
12
+ def output_file_name(input_file_name)
13
+ File.basename(input_file_name, '.*') + '.html'
14
+ end
15
+
16
+ def topics(document)
17
+ Asciidoctor.load_file(document).attributes['topics'].split(', ')
18
+ end
19
+
20
+ def list_of_topics(document)
21
+ lines = []
22
+ lines << ''
23
+ lines << 'Topics:'
24
+ lines << ''
25
+ asciidoctor_document = Asciidoctor.load_file(document)
26
+ if asciidoctor_document.attributes['topics']
27
+ topics = asciidoctor_document.attributes['topics'].split(', ')
28
+ topics.each do |t|
29
+ lines << "#{asciidoc_link(t + '-index.html', t)} "
30
+ end
31
+ else
32
+ puts "#{document} has no topics"
33
+ end
34
+ lines << ''
35
+
36
+ lines
37
+ end
38
+
39
+ def convert_directory(base_directory)
40
+ Dir.glob(File.join(base_directory, 'docs/**/*.adoc')) do |document|
41
+ lines = File.readlines(document)
42
+ lines += list_of_topics(document)
43
+ ad_doc = Asciidoctor::Document.new(lines, header_footer: true, safe: 'unsafe')
44
+ html = ad_doc.convert
45
+ FileUtils.mkdir_p(File.join(base_directory, 'output'))
46
+ File.open(File.join(base_directory, 'output', output_file_name(document)), 'w+') do |file|
47
+ file.puts html
48
+ end
49
+ end
50
+ end
51
+
52
+ def create_index_files(base_directory)
53
+ topics = populate_topics(base_directory)
54
+ meta_index = <<END
55
+ = Index
56
+
57
+ END
58
+ meta_index = write_indexes(base_directory, meta_index, topics)
59
+ write_meta_index(base_directory, meta_index)
60
+ end
61
+
62
+ def populate_topics(base_directory)
63
+ topics = Hash.new
64
+ Dir.glob base_directory + '/docs/**/*.adoc' do |doc|
65
+ asciidoctor_document = Asciidoctor.load_file doc
66
+ if asciidoctor_document.attributes['topics']
67
+ this_topics = asciidoctor_document.attributes['topics'].split(", ")
68
+ this_topics.each do |t|
69
+ if topics[t].nil?
70
+ topics[t] = []
71
+ end
72
+ topics[t] << output_file_name(doc)
73
+ end
74
+ end
75
+ end
76
+ topics
77
+ end
78
+
79
+ def write_indexes(base_directory, meta_index, topics)
80
+ topics.each do |t, docs|
81
+ meta_index += "* #{asciidoc_link(t + '-index.html', t)}\n"
82
+ index = <<END
83
+ == Index of #{t}
84
+
85
+ END
86
+ docs.each do |doc|
87
+ index += "* #{asciidoc_link(doc, File.basename(doc, '.*'))}\n"
88
+ end
89
+ html = Asciidoctor.convert(index, header_footer: true, safe: 'unsafe')
90
+ File.open(base_directory + '/output/' + t + '-index.html', 'w') do |f|
91
+ f.write(html)
92
+ end
93
+ end
94
+ meta_index
95
+ end
96
+
97
+ def write_meta_index(base_directory, meta_index)
98
+ html = Asciidoctor.convert(meta_index, header_footer: true, safe: 'unsafe')
99
+ File.open(base_directory + '/output/index.html', 'w') do |f|
100
+ f.write(html)
101
+ end
102
+ end
103
+
104
+ def run(base_directory)
105
+ convert_directory(base_directory)
106
+ create_index_files(base_directory)
107
+ end
108
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ingo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Florian Wilhelm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ description: Ingo converts AsciiDoc files in a directory and converts them using Asciidoctor.
28
+ It is built for collecting notes in AciiDoc format and presenting them.
29
+ email: florian-wilhelm@onlinehome.de
30
+ executables:
31
+ - ingo
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CHANGELOG.adoc
36
+ - LICENSE
37
+ - README.adoc
38
+ - bin/ingo
39
+ - lib/ingo.rb
40
+ homepage: https://gitlab.com/fwilhe/ingo
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.5.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A static site generator built on Asciidoctor
64
+ test_files: []