giblish 0.8.2 → 2.0.0.pre.alpha1
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.
- checksums.yaml +4 -4
- data/.github/workflows/unit_tests.yml +30 -0
- data/.gitignore +7 -3
- data/.ruby-version +1 -1
- data/Changelog.adoc +59 -0
- data/README.adoc +261 -0
- data/docs/concepts/text_search.adoc +213 -0
- data/docs/concepts/text_search_im/cgi-search_request.puml +35 -0
- data/docs/concepts/text_search_im/cgi-search_request.svg +397 -0
- data/docs/concepts/text_search_im/search_request.puml +40 -0
- data/docs/concepts/text_search_im/search_request.svg +408 -0
- data/docs/howtos/trigger_generation.adoc +180 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/Render Documents.png +0 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/View Documents.png +0 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_hooks.graphml +0 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_hooks.svg +0 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_jenkins.graphml +0 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_jenkins.svg +0 -0
- data/docs/howtos/trigger_generation_im/docgen_github.puml +51 -0
- data/docs/{setup_server_assets → howtos/trigger_generation_im}/giblish_deployment.graphml +0 -0
- data/docs/howtos/trigger_generation_im/post-receive-example.sh +50 -0
- data/docs/reference/box_flow_spec.adoc +22 -0
- data/docs/reference/search_spec.adoc +185 -0
- data/giblish.gemspec +54 -32
- data/lib/giblish/adocsrc_providers.rb +23 -0
- data/lib/giblish/application.rb +214 -41
- data/lib/giblish/cmdline.rb +273 -259
- data/lib/giblish/config_utils.rb +41 -0
- data/lib/giblish/configurator.rb +163 -0
- data/lib/giblish/conversion_info.rb +120 -0
- data/lib/giblish/docattr_providers.rb +125 -0
- data/lib/giblish/docid/docid.rb +181 -0
- data/lib/giblish/github_trigger/webhook_manager.rb +64 -0
- data/lib/giblish/gitrepos/checkoutmanager.rb +124 -0
- data/lib/giblish/{gititf.rb → gitrepos/gititf.rb} +30 -4
- data/lib/giblish/gitrepos/gitsummary.erb +61 -0
- data/lib/giblish/gitrepos/gitsummaryprovider.rb +78 -0
- data/lib/giblish/gitrepos/history_pb.rb +41 -0
- data/lib/giblish/indexbuilders/d3treegraph.rb +88 -0
- data/lib/giblish/indexbuilders/depgraphbuilder.rb +109 -0
- data/lib/giblish/indexbuilders/dotdigraphadoc.rb +174 -0
- data/lib/giblish/indexbuilders/standard_index.erb +10 -0
- data/lib/giblish/indexbuilders/subtree_indices.rb +132 -0
- data/lib/giblish/indexbuilders/templates/circles.html.erb +111 -0
- data/lib/giblish/indexbuilders/templates/flame.html.erb +61 -0
- data/lib/giblish/indexbuilders/templates/tree.html.erb +366 -0
- data/lib/giblish/indexbuilders/templates/treemap.html.erb +127 -0
- data/lib/giblish/indexbuilders/verbatimtree.rb +94 -0
- data/lib/giblish/pathtree.rb +473 -74
- data/lib/giblish/resourcepaths.rb +150 -0
- data/lib/giblish/search/expand_adoc.rb +55 -0
- data/lib/giblish/search/headingindexer.rb +312 -0
- data/lib/giblish/search/request_manager.rb +110 -0
- data/lib/giblish/search/searchquery.rb +68 -0
- data/lib/giblish/search/textsearcher.rb +349 -0
- data/lib/giblish/subtreeinfobuilder.rb +77 -0
- data/lib/giblish/treeconverter.rb +272 -0
- data/lib/giblish/utils.rb +142 -294
- data/lib/giblish/version.rb +1 -1
- data/lib/giblish.rb +10 -7
- data/scripts/hooks/post-receive.example +66 -0
- data/{docgen/scripts/githook_examples → scripts/hooks}/post-update.example +0 -0
- data/{docgen → scripts}/resources/css/adoc-colony.css +0 -0
- data/scripts/resources/css/giblish-serif.css +419 -0
- data/scripts/resources/css/giblish.css +1979 -419
- data/{docgen → scripts}/resources/fonts/Ubuntu-B.ttf +0 -0
- data/{docgen → scripts}/resources/fonts/Ubuntu-BI.ttf +0 -0
- data/{docgen → scripts}/resources/fonts/Ubuntu-R.ttf +0 -0
- data/{docgen → scripts}/resources/fonts/Ubuntu-RI.ttf +0 -0
- data/{docgen → scripts}/resources/fonts/mplus1p-regular-fallback.ttf +0 -0
- data/{docgen → scripts}/resources/images/giblish_logo.png +0 -0
- data/{docgen → scripts}/resources/images/giblish_logo.svg +0 -0
- data/{docgen → scripts}/resources/themes/giblish.yml +0 -0
- data/scripts/wserv_development.rb +32 -0
- data/web_apps/cgi_search/gibsearch.rb +43 -0
- data/web_apps/gh_webhook_trigger/config.ru +2 -0
- data/web_apps/gh_webhook_trigger/gh_webhook_trigger.rb +73 -0
- data/web_apps/gh_webhook_trigger/public/dummy.txt +3 -0
- data/web_apps/sinatra_search/config.ru +2 -0
- data/web_apps/sinatra_search/public/dummy.txt +3 -0
- data/web_apps/sinatra_search/sinatra_search.rb +34 -0
- data/web_apps/sinatra_search/tmp/restart.txt +0 -0
- metadata +188 -85
- data/.rubocop.yml +0 -7
- data/.travis.yml +0 -3
- data/Changelog +0 -16
- data/Gemfile +0 -4
- data/README.adoc +0 -1
- data/Rakefile +0 -41
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/data/testdocs/malformed/no_header.adoc +0 -5
- data/data/testdocs/toplevel.adoc +0 -19
- data/data/testdocs/wellformed/adorned_purpose.adoc +0 -17
- data/data/testdocs/wellformed/docidtest/docid_1.adoc +0 -24
- data/data/testdocs/wellformed/docidtest/docid_2.adoc +0 -8
- data/data/testdocs/wellformed/simple.adoc +0 -14
- data/data/testdocs/wellformed/source_highlighting/highlight_source.adoc +0 -38
- data/docgen/resources/css/giblish.css +0 -1979
- data/docgen/scripts/Jenkinsfile +0 -18
- data/docgen/scripts/gen_adoc_org.sh +0 -58
- data/docs/README.adoc +0 -387
- data/docs/setup_server.adoc +0 -202
- data/lib/giblish/buildgraph.rb +0 -216
- data/lib/giblish/buildindex.rb +0 -459
- data/lib/giblish/core.rb +0 -451
- data/lib/giblish/docconverter.rb +0 -308
- data/lib/giblish/docid.rb +0 -180
- data/lib/giblish/docinfo.rb +0 -75
- data/lib/giblish/indexheadings.rb +0 -251
- data/lib/giblish-search.cgi +0 -459
- data/scripts/hooks/post-receive +0 -57
- data/scripts/publish_html.sh +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc5f7111b85423074f87986b2750ce3fa61dbf4364331a80481d0d5cc881673
|
4
|
+
data.tar.gz: 53fd77b1ac62eec70539e744950cfc8f121532f9639eb2bcb860d6142443474f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa8d72424dc2cb581e90bf383849cb8043b13ca1aed2c5fe3a4b1d9a20aedccf69f6ac9936e7439ae1887074bf274a47553907bce1ce78decd68da207ca3b91
|
7
|
+
data.tar.gz: b579918b4aa8c68d0f9e1ac57a878e3279b3c8404e6f5e677e91859a6af45983feaca033bf051eff56ac7e4f45556f13faa5b79a7bbcb7fc47f18684b5fa952f
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Giblish CI checks
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [personal/rillbert/*, main]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: ["3.0", "3.1"]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- name: Install binutils
|
16
|
+
run: |
|
17
|
+
sudo apt -y install binutils
|
18
|
+
- name: Install needed packages
|
19
|
+
run: |
|
20
|
+
sudo apt-get -y install libpango1.0-dev graphviz
|
21
|
+
- name: Checkout Giblish
|
22
|
+
uses: actions/checkout@v2
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- name: Run tests
|
29
|
+
run: |
|
30
|
+
bundle exec rake
|
data/.gitignore
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
/test/tmp/
|
10
10
|
/test/version_tmp/
|
11
11
|
/tmp/
|
12
|
+
/.vscode/
|
12
13
|
|
13
14
|
# Used by dotenv library to load environment variables.
|
14
15
|
# .env
|
@@ -42,12 +43,15 @@ build-iPhoneSimulator/
|
|
42
43
|
|
43
44
|
# for a library or gem, you might want to ignore these files since the code is
|
44
45
|
# intended to run in multiple environments; otherwise, check them in:
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
Gemfile.lock
|
47
|
+
.ruby-version
|
48
|
+
.ruby-gemset
|
48
49
|
|
49
50
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
51
|
.rvmrc
|
51
52
|
|
52
53
|
# RubyMine idea files
|
53
54
|
/.idea/
|
55
|
+
|
56
|
+
# Local playground
|
57
|
+
sandbox.rb
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.2
|
data/Changelog.adoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
= giblish changelog
|
2
|
+
|
3
|
+
== Not yet in place
|
4
|
+
|
5
|
+
* Update docs for giblish.
|
6
|
+
** write detailed instructions on howto setup the doc generation examples
|
7
|
+
* Update the default css for giblish html generation.
|
8
|
+
|
9
|
+
== v1.0.0
|
10
|
+
|
11
|
+
This release includes a complete refactoring of almost the entire code base.
|
12
|
+
|
13
|
+
Breaking changes::
|
14
|
+
* The '-w' flag is removed
|
15
|
+
* The text search parameters interface has changed completely. A written specification of this interface is included in the docs.
|
16
|
+
* The '-r' flag will, for html generation, *copy everything* under the given directory to the target location.
|
17
|
+
** the previous restriction on folder names has been removed.
|
18
|
+
* The '-s' flag now instructs giblish to use any matching style found under the resource directory given by the '-r' flag. The exact path is no longer necessary.
|
19
|
+
* The doc attribute `:icons: font` is now set by default.
|
20
|
+
* The source highlighter attributes are now set as follows by default:
|
21
|
+
** :source-highlighter: rouge :rouge-css: style :rouge-style: github
|
22
|
+
* The format of the index pages has been updated
|
23
|
+
|
24
|
+
Changes/New functionality::
|
25
|
+
* Rouge is used as source highlighter and the default is to use the following attributes:
|
26
|
+
** :rouge-css: style
|
27
|
+
** :rouge-style: github
|
28
|
+
* A --server-css-path flag can be used to set a path to the css file used by generated html documents when served via a web server.
|
29
|
+
* A --server-search-path flag can be used to set the URI path to the location of a server-side search script that can supply the user with search results.
|
30
|
+
* A --copy-asset-folders flag can be used to copying full directories from the source to the destination tree.
|
31
|
+
* Index pages are generated for each subdirectory in the target document tree.
|
32
|
+
* The format of the git summary page has been updated and more info included.
|
33
|
+
* The text search server-side cgi script has been rewritten.
|
34
|
+
* The text search for web-server-served html docs has been updated in the following ways:
|
35
|
+
** the asciidoc 'include' directive is supported by expanding them and include the resulting text in the search database.
|
36
|
+
** the implementation of the server-side search tools are written completely in ruby and does no longer depend on an external 'grep' tool.
|
37
|
+
** almost all needed infrastructure for implementing a server-side search script has been implemented within the 'giblish' gem.
|
38
|
+
* The asciidoctor toolchain dependencies are updated to the latest versions (at the time of release).
|
39
|
+
|
40
|
+
|
41
|
+
== v0.8.0
|
42
|
+
|
43
|
+
* *Breaking change* require ruby 2.7
|
44
|
+
* update asciidoctor tool deps to latest versions
|
45
|
+
|
46
|
+
== v0.7.0
|
47
|
+
|
48
|
+
* *Breaking change* include the entire path in the -i and -j options
|
49
|
+
* *Breaking change* change the meaning of the -w flag (and rename the long form to --web-path)
|
50
|
+
and add the -mp flag.
|
51
|
+
This was done as a means to remove the hard-coded arguments to the search box html so that one
|
52
|
+
can generate html docs to a destination that is not the same as the one where they are deployed
|
53
|
+
on a web server.
|
54
|
+
* take the idprefix and idseparator into account when indexing sections for text search
|
55
|
+
* Add the font awesome css as link to search box and use the magnifying glass icon
|
56
|
+
* update README file
|
57
|
+
* handle the case where a 'index.adoc' file exists by making the basename configurable using the
|
58
|
+
'--index-basename' flag.
|
59
|
+
* update the dependencies to the latest asciidoctor-pdf release
|
data/README.adoc
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
= giblish
|
2
|
+
:docid: G-001
|
3
|
+
:numbered:
|
4
|
+
|
5
|
+
image::https://github.com/rillbert/giblish/actions/workflows/unit_tests.yml/badge.svg["Build Status"]
|
6
|
+
|
7
|
+
[abstract]
|
8
|
+
== Purpose
|
9
|
+
|
10
|
+
giblish converts a source directory tree containing AsciiDoc files to a destination directory tree containing the corresponding html or pdf files. It adds some handy tools for easier navigation of the resulting destination tree.
|
11
|
+
|
12
|
+
== Examples
|
13
|
+
|
14
|
+
IMPORTANT: The examples below are *not* the official documentation for the corresponding projects.
|
15
|
+
|
16
|
+
[cols="1,1,5"]
|
17
|
+
|===
|
18
|
+
|Project |Link to example |Comment
|
19
|
+
|
20
|
+
|The `giblish` documentation
|
21
|
+
|https://www.rillbert.se/giblish_examples/giblish/main/index.html[here]
|
22
|
+
|The documentation of giblish (same as you find in GitHub).
|
23
|
+
|
24
|
+
|Raspberry Pi documentation
|
25
|
+
|https://www.rillbert.se/giblish_examples/rpi_docs/giblish_example/index.html[example]
|
26
|
+
|The original documentation site uses Jekyl for site generation, the link points to a mirror where some small tweaks to the docs were made to make them suitable for generation with giblish.
|
27
|
+
|
28
|
+
|The *old* asciidoctor docs
|
29
|
+
|https://www.rillbert.se/giblish_examples/asciidoctor_docs/master/newindex.html[example]
|
30
|
+
|An example of how giblish can generate the master branch of the official asciidoc.org documentation git repo can be found at
|
31
|
+
|
32
|
+
|===
|
33
|
+
|
34
|
+
== `giblish` features
|
35
|
+
|
36
|
+
The features of giblish include:
|
37
|
+
|
38
|
+
* An index page listing all rendered documents with clickable links.
|
39
|
+
* If the source directory tree is part of a git repository, giblish can generate separate html/pdf trees for branches and/or tags that match a user specified regexp (see examples below).
|
40
|
+
* Document ids - Note: the implementation of this is giblish-specific and thus you need to render your adoc files using giblish to make this work as intended. You can use document ids to:
|
41
|
+
** Reference one doc in the source tree from another doc without depending on file names or relative paths. The referenced doc can thus be moved within the source tree or change its file name and the reference will still be valid.
|
42
|
+
** Validate doc id references during document rendering and thus be alerted to any invalid doc id references.
|
43
|
+
** Let giblish generate a clickable graph of all document references (requires graphviz and the 'dot' tool).
|
44
|
+
* A stripped-down, but nonetheless useful, text-search of your html documents. This requires that you publish your docs to a web-server and setup an application on that same web-server. `giblish` provides most of the scaffolding though.
|
45
|
+
|
46
|
+
== Dependencies and credits
|
47
|
+
|
48
|
+
Giblish uses the awesome *asciidoctor* and *asciidoctor-pdf* projects under the hood. Thank you @mojavelinux and others for making these brilliant tools available!!
|
49
|
+
|
50
|
+
== Installation
|
51
|
+
|
52
|
+
gem install giblish
|
53
|
+
|
54
|
+
Want to get started straight away? Go directly to the <<usage_examples>>.
|
55
|
+
|
56
|
+
=== Some caveats
|
57
|
+
|
58
|
+
When using giblish for generating docs the following applies:
|
59
|
+
|
60
|
+
* giblish *will overwrite* files with the same name in the destination directory.
|
61
|
+
* giblish requires that the git working tree and index of the repo containing source documents are clean when generating documentation.
|
62
|
+
* giblish will make explicit check-outs of all the branches or tags that matches the selection criteria. The working dir of the source git repo will thus have the last branch that giblish checked-out as the current branch after doc generation.
|
63
|
+
|
64
|
+
== Contributing
|
65
|
+
|
66
|
+
If you want to contribute to giblish, great :) Use the standard GitHub flow of forking the repo and submit a pull request.
|
67
|
+
|
68
|
+
Pull requests must meet the following to be considered for merging:
|
69
|
+
|
70
|
+
* Tests have been added for new or updated functionality
|
71
|
+
* The code has been linted using the `standardrb` tool.
|
72
|
+
** The version of standardrb shall be the same as the one used in the target branch for the PR.
|
73
|
+
|
74
|
+
To develop on giblish, you:
|
75
|
+
|
76
|
+
. Install ruby on your local machine (rbenv is a good choice for handling ruby installations)
|
77
|
+
. Install necessary dependencies to install the ruby 'mathematica' gem, see eg https://github.com/gjtorikian/mathematical/blob/47041d5492cc7c5f04105031430fb44119406f49/script/install_linux_deps
|
78
|
+
. Install graphviz
|
79
|
+
. Clone or fork the repository
|
80
|
+
. Run the `bin/setup` script from a bash prompt
|
81
|
+
|
82
|
+
== Document ids and the reference graph
|
83
|
+
|
84
|
+
NOTE: This is a non-standard extension of asciidoc. If you use this feature, you will need to generate your documents using giblish to make this work as intended.
|
85
|
+
|
86
|
+
giblish extends the cross reference concept in asciidoc with a _document id_ mechanism. To use this, you need to:
|
87
|
+
|
88
|
+
. Add a `:docid:` entry in your document's header section. The doc id can consist of up to 10 characters and must be unique within the set of documents generated by giblish.
|
89
|
+
. Refer to a document using the syntax `pass:[<<:docid:a_doc_id>>]` where `a_doc_id` is the doc id of a document in the same git repo.
|
90
|
+
. Run giblish with the -d switch when generating documents.
|
91
|
+
|
92
|
+
Using doc ids makes it possible for giblish to do two things:
|
93
|
+
|
94
|
+
. Make references from one document in the tree to another work even if one of the documents have been moved within the document source tree.
|
95
|
+
. Produce a clickable 'map' of the generated documents where the different references are clearly seen. This feature require that the 'dot' tool, part of the graphwiz package is installed on the machine where giblish is run.
|
96
|
+
|
97
|
+
The use of the -d switch makes giblish parse the document twice, once to map up the doc ids and all references to them, once to actually generate the output documentation. Thus, you pay a performance penalty but this should not be a big inconvenience since the generation is quite fast in itself.
|
98
|
+
|
99
|
+
=== Example of using the docid feature
|
100
|
+
|
101
|
+
Consider that you have two documents located somewhere in the same folder tree, document one and document two. You could then use the docid feature of giblish to refer to one document from the other as in the example below.
|
102
|
+
|
103
|
+
Example document one::
|
104
|
+
|
105
|
+
[source,asciidoc]
|
106
|
+
----
|
107
|
+
= Document one
|
108
|
+
:toc:
|
109
|
+
:numbered:
|
110
|
+
:docid: G-001
|
111
|
+
|
112
|
+
== Purpose
|
113
|
+
|
114
|
+
To illustrate the use of doc id.
|
115
|
+
----
|
116
|
+
|
117
|
+
Example document two::
|
118
|
+
[source,asciidoc]
|
119
|
+
----
|
120
|
+
= Document two
|
121
|
+
:toc:
|
122
|
+
:numbered:
|
123
|
+
:docid: G-002
|
124
|
+
|
125
|
+
== Purpose
|
126
|
+
|
127
|
+
To illustrate the use of doc id. You can refer to document one as <<:docid:G-001>>. This will display a clickable link with the doc id (G-001 in this case).
|
128
|
+
|
129
|
+
You can use the same syntax as the normal asciidoc cross-ref but replace 'xref' with ':docid:' as shown below:
|
130
|
+
|
131
|
+
* <<:docid:G-002#purpose>> to refer to a specific section or anchor.
|
132
|
+
* <<:docid:G-002#purpose,The purpose section>> to refer to a specific section and display a specific text for the link.
|
133
|
+
----
|
134
|
+
|
135
|
+
The above reference will work even if either document changes location or file name as long as both documents are parsed by giblish in the same run.
|
136
|
+
|
137
|
+
[[usage_examples]]
|
138
|
+
== Usage Examples
|
139
|
+
|
140
|
+
Here follows a number of usages for giblish in increasing order of complexity.
|
141
|
+
|
142
|
+
=== Get available options
|
143
|
+
|
144
|
+
giblish -h
|
145
|
+
|
146
|
+
=== Giblish html 'hello world'
|
147
|
+
|
148
|
+
giblish my_src_root my_dst_root
|
149
|
+
|
150
|
+
* convert all .adoc or .ADOC files under the dir `my_src_root` to html and place the resulting files under the `my_dst_root` dir.
|
151
|
+
* generate an index page named `index.html` that contains links and some info about the converted files. The file is placed in the `my_dst_root` dir.
|
152
|
+
|
153
|
+
The default asciidoctor css will be used in the html conversion.
|
154
|
+
|
155
|
+
=== Giblish pdf 'hello world'
|
156
|
+
|
157
|
+
giblish -f pdf my_src_root my_dst_root
|
158
|
+
|
159
|
+
* convert all .adoc or .ADOC files under the dir `my_src_root` to pdf and place the resulting files under the `my_dst_root` dir.
|
160
|
+
* generate an index page named `index.pdf` that contains links and some info about the converted files. The file is placed in the `my_dst_root` dir.
|
161
|
+
|
162
|
+
The default asciidoctor pdf theme will be used in the pdf conversion.
|
163
|
+
|
164
|
+
=== Using a custom css for the generated html
|
165
|
+
|
166
|
+
Generate html that can be browsed locally from file:://<my_dst_root>.
|
167
|
+
|
168
|
+
giblish -r path/to/my/resources -s mylayout my_src_root my_dst_root
|
169
|
+
|
170
|
+
* convert all .adoc or .ADOC files under the dir `my_src_root` to html and place the resulting files under the `my_dst_root` dir.
|
171
|
+
* generate an index page named `index.html` that contains links and some info about the converted files. The file is placed in the `my_dst_root` dir.
|
172
|
+
* copy everything found under `<working_dir>/path/to/my/resources` to `my_dst_root/web_assets`
|
173
|
+
* link all generated html files to the mylayout.css found somewhere under `/web_assets`
|
174
|
+
|
175
|
+
=== Using a custom pdf theme for the generated pdfs
|
176
|
+
|
177
|
+
giblish -f pdf -r path/to/my/resources -s mylayout my_src_root my_dst_root
|
178
|
+
|
179
|
+
* convert all .adoc or .ADOC files under the dir `my_src_root` to pdf and place the resulting files under the `my_dst_root` dir. some info about the converted files. The file is placed in the `my_dst_root` dir.
|
180
|
+
* the pdfs will be rendered using the theme file named mylayout.yml found somewhere under `<working_dir>/path/to/my/resources`
|
181
|
+
|
182
|
+
=== Generate html from multiple git branches
|
183
|
+
|
184
|
+
giblish -g "feature" my_src_root my_dst_root
|
185
|
+
|
186
|
+
* check-out each branch matching the regexp "feature" in turn
|
187
|
+
* for each checked-out branch,
|
188
|
+
** convert the .adoc or .ADOC files under the dir `my_src_root` to html.
|
189
|
+
** place the resulting files under the `my_dst_root/<branch_name>` dir.
|
190
|
+
** generate an index page named `index.html` that contains links and some info about the converted files. The file is placed in the `my_dst_root/<branch_name` dir.
|
191
|
+
* generate a summary page containing links to a all branches and place it in the `my_dst_root` dir.
|
192
|
+
|
193
|
+
// === Publish the asciidoctor.org documents with text search
|
194
|
+
|
195
|
+
// giblish can be used to generate html docs suitable for serving via a web server (e.g. Apache). You can use the cgi script included in the giblish gem to provide text search capabilities.
|
196
|
+
|
197
|
+
// Here is an example of how to publish the docs in the official asciidoctor.org git repo to a web server, including index pages and text search.
|
198
|
+
|
199
|
+
// NOTE: No consideration has been taken to how permissions are set up on the web server. Just running the below commands as-is on e.g.a standard apache set-up will bail out with 'permission denied' errors.
|
200
|
+
|
201
|
+
// ==== Generating the html documents
|
202
|
+
|
203
|
+
// The example assumes that you have one machine where you generate the documents and another machine that runs a web server to which you have ssh access.
|
204
|
+
|
205
|
+
// The generated docs shall be accessible via _www.example.com/adocorg/with_search_
|
206
|
+
|
207
|
+
// You need to provide two pieces of deployment info to giblish when generating the documents:
|
208
|
+
|
209
|
+
// * the uri path where to access the deployed docs (/adocorg/with_search in this example)
|
210
|
+
// * the path in the local file system on the web server where the search data can be accessed
|
211
|
+
// (/var/www/html/site_1/adocorg/with_search in this example)
|
212
|
+
|
213
|
+
// The following commands will generate the asciidoctor.org documentation and deploy the result to the web server.
|
214
|
+
|
215
|
+
// . Clone the asciidoctor doc repo to your development machine
|
216
|
+
// +
|
217
|
+
// git clone https://github.com/asciidoctor/asciidoctor.org.git
|
218
|
+
|
219
|
+
// . Generate the html documentation with the correct deployment info
|
220
|
+
// +
|
221
|
+
// giblish -j '^.*_include.*' -m -mp /var/www/html/site_1/adocorg/with_search -w /adocorg/with_search -g master --index-basename "myindex" asciidoctor.org/docs ./generated_docs
|
222
|
+
// +
|
223
|
+
// Explanation of the parameters and arguments::
|
224
|
+
// * *pass:[-j '^.*_include.*']* - exclude everything in the __include_ directory. (the
|
225
|
+
// asciidoctor.org repo stores partial docs here).
|
226
|
+
// * *-m* - assemble the necessary search data to support text search and include this data as part of
|
227
|
+
// the generated documents.
|
228
|
+
// * *-mp /var/www/html/site_1/adocorg/with_search* - the file system path on the deployment machine where
|
229
|
+
// the search data is located
|
230
|
+
// * *-w /adocorg/with_search* - the uri path to the deployed docs
|
231
|
+
// * *-g master* - publish all git branches that matches the regexp 'master' (i.e. only the 'master'
|
232
|
+
// branch).
|
233
|
+
// * *--index-basename "myindex"* - change the default name (index) that giblish uses for the generated
|
234
|
+
// index page. This is needed since asciidoctor.org contains an
|
235
|
+
// "index.adoc" file that would otherwise be overwritten by giblish.
|
236
|
+
// * *asciidoctor.org/docs* - the root of the source document tree.
|
237
|
+
// * *./generated_docs* - a temporary storage for the generated html docs on the local system.
|
238
|
+
// +
|
239
|
+
|
240
|
+
// . Copy the generated files to the web server
|
241
|
+
|
242
|
+
// scp -r ./generated_docs rillbert@my.web.server.org:/var/www/adocorg/with_search/.
|
243
|
+
// +
|
244
|
+
|
245
|
+
|
246
|
+
// ==== Copy the text search script to the web server
|
247
|
+
|
248
|
+
// This only needs to be done once (or if a new version of giblish breaks the currently used API).
|
249
|
+
|
250
|
+
// IMPORTANT: The current version of giblish expects the script to be found at the URI path `/cgi-bin/giblish-search.cgi`. This might be customizable in future versions but is currently hard-coded. Thus, if your web-server serves pages at www.mywebsite.com, the search script must be accessible at www.mywebsite.com/cgi-bin/giblish-search.cgi
|
251
|
+
|
252
|
+
// . Find the server side script that implements text search that is included with giblish
|
253
|
+
|
254
|
+
// gem which giblish
|
255
|
+
// +
|
256
|
+
|
257
|
+
// In my case this returns `/var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib/giblish.rb`. This means that I will find the script in the same directory, i.e. `/var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib`.
|
258
|
+
|
259
|
+
// . Copy the server side script to the /cgi-bin dir on the web server. In this example the cgi-bin dir is configured to be `/var/www/cgi-bin`
|
260
|
+
// +
|
261
|
+
// scp /var/lib/ruby/gems/2.4.0/gems/giblish-0.5.2/lib/giblish-search.cgi rillbert@my.web.server.org:/var/www/cgi-bin/giblish-search.cgi
|
@@ -0,0 +1,213 @@
|
|
1
|
+
= giblish text search
|
2
|
+
:docid: G-004
|
3
|
+
:imagesdir: text_search_im
|
4
|
+
|
5
|
+
== Overview
|
6
|
+
|
7
|
+
giblish includes an implementation of full text search for html documents if they are published via a web server. Two things must be met to enable this functionality:
|
8
|
+
|
9
|
+
. A specific set of options must be given to giblish during the generation of the html documents. This will ensure that giblish:
|
10
|
+
.. copies a search index to the same tree as the generated html documents.
|
11
|
+
.. includes an html form at the top of each generated document that the user can interact with to send search queries.
|
12
|
+
. A server-side search application must be setup on the web server that hosts the generated html docs.
|
13
|
+
.. The application must be invoked as a result of a search query from one of the generated html documents and return the corresponding search result to the user.
|
14
|
+
.. The same instance of a search application can be used for multiple document repositories deployed on the same web server.
|
15
|
+
|
16
|
+
The server-side script can be implemented in many ways, the giblish gem provides helper classes that implement most of the heavy-lifting. It also contains template scripts for using CGI or a sinatra web app hosted in the Phusion Passenger application server to initiate a search.
|
17
|
+
|
18
|
+
The specification of the search query parameters can be found in <<:docid:G-002>>.
|
19
|
+
|
20
|
+
== Text search using CGI
|
21
|
+
|
22
|
+
CGI is the solution with fewest external dependencies (and worst performance). Below is an overview of the involved actors.
|
23
|
+
|
24
|
+
.CGI script example
|
25
|
+
image::cgi-search_request.svg[]
|
26
|
+
|
27
|
+
Giblish contains two template scripts to get you started:
|
28
|
+
|
29
|
+
. gibsearch.rb - a naive implementation of a CGI script in ruby that uses the helper classes provided by giblish to retrieve and format an html response triggered by a search request to a web server.
|
30
|
+
. wserv_development.rb - a naive implementation of a boot-strap script for an instance of Webrick, a web server written in ruby, that serves html pages on localhost:8000
|
31
|
+
|
32
|
+
IMPORTANT: The template scripts in giblish are provided as examples and are not tested in any form of production use.
|
33
|
+
|
34
|
+
.Using CGI and ruby's built-in Webrick server
|
35
|
+
====
|
36
|
+
This is the most basic example, it assumes that all documents and tools are run on a local machine. To publish documents to the world, you would replace Webrick with Apache, Nginx or other, more production-friendly web server.
|
37
|
+
|
38
|
+
[source,bash]
|
39
|
+
----
|
40
|
+
# install giblish
|
41
|
+
gem install giblish
|
42
|
+
|
43
|
+
# install webrick
|
44
|
+
gem install webrick
|
45
|
+
|
46
|
+
# cd to your directory of choice, called top_dir in this example
|
47
|
+
cd top_dir
|
48
|
+
|
49
|
+
# clone the repo containing the docs (using the giblish repo as
|
50
|
+
# an example)
|
51
|
+
git clone https://github.com/rillbert/giblish.git
|
52
|
+
|
53
|
+
# generate html docs from all 1.x tags
|
54
|
+
giblish -t "^v1" -m giblish html_docs
|
55
|
+
|
56
|
+
# Copy the cgi template provided in the giblish gem to the directory
|
57
|
+
# for the html docs.
|
58
|
+
# The template is named 'gibsearch.rb' and resides under
|
59
|
+
# 'web_apps/cgi_search' relative to the dir of the installed
|
60
|
+
# giblish gem.
|
61
|
+
# The below uses bash to find the template, copy and rename it to
|
62
|
+
# 'gibsearch.cgi' to make it smoother to use the cgi binding in webrick.
|
63
|
+
cp "$(dirname $(gem which giblish))/../web_apps/cgi_search/gibsearch.rb" html_docs/gibsearch.cgi
|
64
|
+
|
65
|
+
# copy a boot-strap script for Webrick from the giblish gem
|
66
|
+
cp "$(dirname $(gem which giblish))/../scripts/wserv_development.rb"
|
67
|
+
|
68
|
+
# start a web server using the boot-strap script
|
69
|
+
#
|
70
|
+
# If you deviate from this example regarding paths, you need to
|
71
|
+
# adjust the boot-strap script accordingly
|
72
|
+
ruby wserv_development.rb
|
73
|
+
|
74
|
+
# browse to localhost:8000
|
75
|
+
firefox localhost:8000
|
76
|
+
|
77
|
+
# click on one of the 1.x tags to see the docs for that tag
|
78
|
+
|
79
|
+
# search docs using the form in the index page.
|
80
|
+
----
|
81
|
+
====
|
82
|
+
|
83
|
+
== Text search using a web application hosted by Passenger
|
84
|
+
|
85
|
+
This setup has more dependencies than the CGI example. The upsides are e.g. stateful execution, better performance, more versatile.
|
86
|
+
|
87
|
+
This example uses Apache2, Passenger and Sinatra to deploy the server-side text search as a web application. There are a gazillion other tech stacks/permutations to provide the same functionality.
|
88
|
+
|
89
|
+
IMPORTANT: Full installation instructions of Apache2, Passenger or their interconnection is out of scope for this example. Security is also out of scope so you will probably want to harden this before using it in production.
|
90
|
+
|
91
|
+
.Passenger web-app example
|
92
|
+
image::search_request.svg[]
|
93
|
+
|
94
|
+
=== Setup a sinatra app under apache/passenger
|
95
|
+
|
96
|
+
This example is based on the info found in these links:
|
97
|
+
|
98
|
+
* https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/apache/oss/bionic/deploy_app.html#nonrails_preparing-the-app-s-environment
|
99
|
+
* https://newbedev.com/how-do-i-set-up-a-sinatra-app-under-apache-with-passenger
|
100
|
+
|
101
|
+
|
102
|
+
.Deploy a text search application under Apache/Passenger
|
103
|
+
====
|
104
|
+
Preconditions::
|
105
|
+
* You have a working installation of
|
106
|
+
** Apache (version >= 2.4)
|
107
|
+
** Ruby (version >= 2.7)
|
108
|
+
** giblish (version >= 1.0)
|
109
|
+
* The generated html documents are stored under `/var/www/html/mydomain`
|
110
|
+
* The web server will serve the docs from the domain `www.mydomain.se`
|
111
|
+
* The search script is accessible via the url `www.mydomain.se:1233/gibsearch`
|
112
|
+
|
113
|
+
.Setup Passenger under apache
|
114
|
+
[source, bash]
|
115
|
+
----
|
116
|
+
# list available modules
|
117
|
+
sudo apachectl -M
|
118
|
+
|
119
|
+
# install the apache passenger module
|
120
|
+
sudo apt install libapache2-mod-passenger
|
121
|
+
|
122
|
+
# check that passanger is running
|
123
|
+
sudo /usr/sbin/passenger-memory-stats
|
124
|
+
|
125
|
+
# determining the ruby command for passenger (Ex: /usr/bin/ruby2.7)
|
126
|
+
passenger-config about ruby-command
|
127
|
+
|
128
|
+
# install sinatra
|
129
|
+
sudo gem install sinatra --no-document
|
130
|
+
|
131
|
+
# add an apache 'site-available' config file for your app
|
132
|
+
sudo nano /etc/apache2/sites-available/100-gibsearch.conf
|
133
|
+
|
134
|
+
# use the following as a starting point for your config file but
|
135
|
+
# tweak it to your situation
|
136
|
+
<VirtualHost *:1233>
|
137
|
+
ServerName mydomain.se
|
138
|
+
|
139
|
+
# Tell Apache and Passenger where your app's 'public' directory is
|
140
|
+
# NOTE: Passenger requires a 'public' dir even if it is empty
|
141
|
+
DocumentRoot /var/www/mydoain/apps/gibsearch/public
|
142
|
+
|
143
|
+
PassengerRuby /usr/bin/ruby2.7
|
144
|
+
|
145
|
+
# Relax Apache security settings
|
146
|
+
<Directory /var/www/mydomain/apps/gibsearch/public>
|
147
|
+
Allow from all
|
148
|
+
Options -MultiViews
|
149
|
+
Require all granted
|
150
|
+
</Directory>
|
151
|
+
</VirtualHost>
|
152
|
+
|
153
|
+
# add an entry in Apache's ports.conf file
|
154
|
+
cd /etc/apache2/
|
155
|
+
sudo nano ports.conf
|
156
|
+
|
157
|
+
# add the following line in the ports.conf file and save it
|
158
|
+
Listen 1233
|
159
|
+
|
160
|
+
# symlink site-available to sites-enabled
|
161
|
+
sudo ln -s /etc/apache2/sites-available/100-gibsearch.conf .
|
162
|
+
|
163
|
+
# restart apache
|
164
|
+
sudo apache2ctl restart
|
165
|
+
----
|
166
|
+
|
167
|
+
.Deploy the text search web application
|
168
|
+
[source,bash]
|
169
|
+
----
|
170
|
+
# the giblish gem contains a template application called
|
171
|
+
# 'sinatra_search' that you can use to start out with.
|
172
|
+
#
|
173
|
+
# copy the files from the giblish gem to where you want to deploy
|
174
|
+
# the web app under apache, eg:
|
175
|
+
cd /var/www/mydomain/apps/
|
176
|
+
cp -r "$(dirname $(gem which giblish))/../web_apps/sinatra_search" gibsearch
|
177
|
+
|
178
|
+
# when you're done, you should have something similar to this on your
|
179
|
+
# server
|
180
|
+
$ tree gibsearch/
|
181
|
+
gibsearch/
|
182
|
+
|----- config.ru
|
183
|
+
|----- public
|
184
|
+
| |-- dummy.txt
|
185
|
+
|----- sinatra_search.rb
|
186
|
+
|-- tmp
|
187
|
+
|-- restart.txt
|
188
|
+
|
189
|
+
# you will want to tweak:
|
190
|
+
# the URL_PATH_MAPPINGS hash in the sinatra_search.rb file
|
191
|
+
# to your situation.
|
192
|
+
|
193
|
+
# you can restart your app using
|
194
|
+
touch gibsearch/tmp/restart.txt
|
195
|
+
|
196
|
+
----
|
197
|
+
|
198
|
+
.Generate docs compatible with the text search web application
|
199
|
+
[source,bash]
|
200
|
+
----
|
201
|
+
# cd to your directory of choice, called top_dir in this example
|
202
|
+
cd top_dir
|
203
|
+
|
204
|
+
# clone the repo containing the docs (using the giblish repo as
|
205
|
+
# an example)
|
206
|
+
git clone https://github.com/rillbert/giblish.git
|
207
|
+
|
208
|
+
# generate html docs from all 1.x tags
|
209
|
+
cd /var/www/html/mydomain
|
210
|
+
giblish -c -t "^v1" -m --server-search-path www.mydomain.se:1233/gibsearch giblish html_docs
|
211
|
+
|
212
|
+
----
|
213
|
+
====
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@startuml
|
2
|
+
!theme cerulean-outline
|
3
|
+
' !theme spacelab
|
4
|
+
hide footbox
|
5
|
+
autonumber
|
6
|
+
|
7
|
+
title "Using CGI for search requests"
|
8
|
+
|
9
|
+
actor Viewer as Vi
|
10
|
+
|
11
|
+
box "The Document Hosting Server" #EEEEEE
|
12
|
+
participant "Web Server" as Webserv
|
13
|
+
participant "Search Result\nGenerator\n(CGI)" as Searcher
|
14
|
+
note over of Searcher
|
15
|
+
The CGI script could use the
|
16
|
+
""Giblish::RequestManager""
|
17
|
+
class to do most of the work.
|
18
|
+
end note
|
19
|
+
database "Search index" as Index
|
20
|
+
end box
|
21
|
+
|
22
|
+
Vi -> Webserv : Search Query\n(html POST)
|
23
|
+
Webserv -> Searcher : Invoke CGI\nscript
|
24
|
+
Searcher -> Index : Search the\nindex
|
25
|
+
Searcher -> Webserv : Return serch\nresult (html)
|
26
|
+
note right
|
27
|
+
Giblish contains help classes
|
28
|
+
that provide most of the heavy
|
29
|
+
lifting for retrieving and
|
30
|
+
formatting the search result.
|
31
|
+
end note
|
32
|
+
Webserv -> Vi : return search\nresult
|
33
|
+
@enduml
|
34
|
+
|
35
|
+
|