giblish 0.8.2 → 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/unit_tests.yml +30 -0
  3. data/.gitignore +7 -3
  4. data/.ruby-version +1 -1
  5. data/Changelog.adoc +61 -0
  6. data/README.adoc +267 -0
  7. data/docs/concepts/text_search.adoc +213 -0
  8. data/docs/concepts/text_search_im/cgi-search_request.puml +35 -0
  9. data/docs/concepts/text_search_im/cgi-search_request.svg +397 -0
  10. data/docs/concepts/text_search_im/search_request.puml +40 -0
  11. data/docs/concepts/text_search_im/search_request.svg +408 -0
  12. data/docs/howtos/trigger_generation.adoc +180 -0
  13. data/docs/{setup_server_assets → howtos/trigger_generation_im}/Render Documents.png +0 -0
  14. data/docs/{setup_server_assets → howtos/trigger_generation_im}/View Documents.png +0 -0
  15. data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_hooks.graphml +0 -0
  16. data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_hooks.svg +0 -0
  17. data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_jenkins.graphml +0 -0
  18. data/docs/{setup_server_assets → howtos/trigger_generation_im}/deploy_with_jenkins.svg +0 -0
  19. data/docs/howtos/trigger_generation_im/docgen_github.puml +51 -0
  20. data/docs/{setup_server_assets → howtos/trigger_generation_im}/giblish_deployment.graphml +0 -0
  21. data/docs/howtos/trigger_generation_im/post-receive-example.sh +50 -0
  22. data/docs/reference/box_flow_spec.adoc +22 -0
  23. data/docs/reference/search_spec.adoc +185 -0
  24. data/giblish.gemspec +47 -29
  25. data/lib/giblish/adocsrc_providers.rb +23 -0
  26. data/lib/giblish/application.rb +214 -41
  27. data/lib/giblish/cmdline.rb +273 -259
  28. data/lib/giblish/config_utils.rb +41 -0
  29. data/lib/giblish/configurator.rb +163 -0
  30. data/lib/giblish/conversion_info.rb +120 -0
  31. data/lib/giblish/docattr_providers.rb +125 -0
  32. data/lib/giblish/docid/docid.rb +181 -0
  33. data/lib/giblish/github_trigger/webhook_manager.rb +64 -0
  34. data/lib/giblish/gitrepos/checkoutmanager.rb +124 -0
  35. data/lib/giblish/{gititf.rb → gitrepos/gititf.rb} +30 -4
  36. data/lib/giblish/gitrepos/gitsummary.erb +61 -0
  37. data/lib/giblish/gitrepos/gitsummaryprovider.rb +78 -0
  38. data/lib/giblish/gitrepos/history_pb.rb +41 -0
  39. data/lib/giblish/indexbuilders/d3treegraph.rb +88 -0
  40. data/lib/giblish/indexbuilders/depgraphbuilder.rb +109 -0
  41. data/lib/giblish/indexbuilders/dotdigraphadoc.rb +174 -0
  42. data/lib/giblish/indexbuilders/standard_index.erb +10 -0
  43. data/lib/giblish/indexbuilders/subtree_indices.rb +132 -0
  44. data/lib/giblish/indexbuilders/templates/circles.html.erb +111 -0
  45. data/lib/giblish/indexbuilders/templates/flame.html.erb +61 -0
  46. data/lib/giblish/indexbuilders/templates/tree.html.erb +366 -0
  47. data/lib/giblish/indexbuilders/templates/treemap.html.erb +127 -0
  48. data/lib/giblish/indexbuilders/verbatimtree.rb +94 -0
  49. data/lib/giblish/pathtree.rb +473 -74
  50. data/lib/giblish/resourcepaths.rb +150 -0
  51. data/lib/giblish/search/expand_adoc.rb +55 -0
  52. data/lib/giblish/search/headingindexer.rb +312 -0
  53. data/lib/giblish/search/request_manager.rb +110 -0
  54. data/lib/giblish/search/searchquery.rb +68 -0
  55. data/lib/giblish/search/textsearcher.rb +349 -0
  56. data/lib/giblish/subtreeinfobuilder.rb +77 -0
  57. data/lib/giblish/treeconverter.rb +272 -0
  58. data/lib/giblish/utils.rb +142 -294
  59. data/lib/giblish/version.rb +1 -1
  60. data/lib/giblish.rb +10 -7
  61. data/scripts/hooks/post-receive.example +66 -0
  62. data/{docgen/scripts/githook_examples → scripts/hooks}/post-update.example +0 -0
  63. data/{docgen → scripts}/resources/css/adoc-colony.css +0 -0
  64. data/scripts/resources/css/giblish-serif.css +419 -0
  65. data/scripts/resources/css/giblish.css +1979 -419
  66. data/{docgen → scripts}/resources/fonts/Ubuntu-B.ttf +0 -0
  67. data/{docgen → scripts}/resources/fonts/Ubuntu-BI.ttf +0 -0
  68. data/{docgen → scripts}/resources/fonts/Ubuntu-R.ttf +0 -0
  69. data/{docgen → scripts}/resources/fonts/Ubuntu-RI.ttf +0 -0
  70. data/{docgen → scripts}/resources/fonts/mplus1p-regular-fallback.ttf +0 -0
  71. data/{docgen → scripts}/resources/images/giblish_logo.png +0 -0
  72. data/{docgen → scripts}/resources/images/giblish_logo.svg +0 -0
  73. data/{docgen → scripts}/resources/themes/giblish.yml +0 -0
  74. data/scripts/wserv_development.rb +32 -0
  75. data/web_apps/cgi_search/gibsearch.rb +43 -0
  76. data/web_apps/gh_webhook_trigger/config.ru +2 -0
  77. data/web_apps/gh_webhook_trigger/gh_webhook_trigger.rb +73 -0
  78. data/web_apps/gh_webhook_trigger/public/dummy.txt +3 -0
  79. data/web_apps/sinatra_search/config.ru +2 -0
  80. data/web_apps/sinatra_search/public/dummy.txt +3 -0
  81. data/web_apps/sinatra_search/sinatra_search.rb +34 -0
  82. data/web_apps/sinatra_search/tmp/restart.txt +0 -0
  83. metadata +168 -73
  84. data/.rubocop.yml +0 -7
  85. data/.travis.yml +0 -3
  86. data/Changelog +0 -16
  87. data/Gemfile +0 -4
  88. data/README.adoc +0 -1
  89. data/Rakefile +0 -41
  90. data/bin/console +0 -14
  91. data/bin/setup +0 -8
  92. data/data/testdocs/malformed/no_header.adoc +0 -5
  93. data/data/testdocs/toplevel.adoc +0 -19
  94. data/data/testdocs/wellformed/adorned_purpose.adoc +0 -17
  95. data/data/testdocs/wellformed/docidtest/docid_1.adoc +0 -24
  96. data/data/testdocs/wellformed/docidtest/docid_2.adoc +0 -8
  97. data/data/testdocs/wellformed/simple.adoc +0 -14
  98. data/data/testdocs/wellformed/source_highlighting/highlight_source.adoc +0 -38
  99. data/docgen/resources/css/giblish.css +0 -1979
  100. data/docgen/scripts/Jenkinsfile +0 -18
  101. data/docgen/scripts/gen_adoc_org.sh +0 -58
  102. data/docs/README.adoc +0 -387
  103. data/docs/setup_server.adoc +0 -202
  104. data/lib/giblish/buildgraph.rb +0 -216
  105. data/lib/giblish/buildindex.rb +0 -459
  106. data/lib/giblish/core.rb +0 -451
  107. data/lib/giblish/docconverter.rb +0 -308
  108. data/lib/giblish/docid.rb +0 -180
  109. data/lib/giblish/docinfo.rb +0 -75
  110. data/lib/giblish/indexheadings.rb +0 -251
  111. data/lib/giblish-search.cgi +0 -459
  112. data/scripts/hooks/post-receive +0 -57
  113. data/scripts/publish_html.sh +0 -99
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56f7e50e079748482350108862650f943cd6266864b285a1845808443dd46489
4
- data.tar.gz: '0911983f515dd0e8719ef9836b69182f5e148b17101414cc703c080ee4681370'
3
+ metadata.gz: 306ffd38e0b46b1da0bde8fbfe13e25edd2271cf3c9e40a0bd595e0bd92ab474
4
+ data.tar.gz: 63124dcd57d6bc1a4b11c8b92b4250071b4d6bb1f3068e25e8465759722c2b82
5
5
  SHA512:
6
- metadata.gz: 57c8f2974c53343bca7b7bd92e2417441e1c203acbac40e3e35df0502a72eb8d305bc611850c8772675f75938df61c7f4c8032124273677c7ed7e95249066ef3
7
- data.tar.gz: 056b23e064ec6b71c96ef6071e5e8fe870693c0950999bea083c23e45d678287c8390f1da4343710ec853e5969632fb1e940fc9177ed7d1a5d430bcff3faa3f6
6
+ metadata.gz: 5f66a14a039fc925c55aef093b28db11f2aabc585b1dae43cf6ab39c42996c13ec85cfdd5f3c4decdc618caa0dfdaf8b43eb5152e9cf53c5f0e60ba50d1e9a52
7
+ data.tar.gz: 575c20796a4d9aef25f90760dd1fd9e1bf7897fe9284951486b214bda56cb28a835c2c6a9c8306c91c50764bfb1c3ca170756a276a45b27b94ffc59c2fe972ad
@@ -0,0 +1,30 @@
1
+ name: Giblish CI checks
2
+
3
+ on:
4
+ push:
5
+ branches: [personal/rillbert/svg_index]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: ["2.7", "3.0"]
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
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
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
- 2.7.3
1
+ 3.0.3
data/Changelog.adoc ADDED
@@ -0,0 +1,61 @@
1
+ = giblish changelog
2
+
3
+ == Not yet in place
4
+
5
+ * Update docs for giblish.
6
+ ** the later part of the trigger_generation doc
7
+ ** go through and fix spelling
8
+ * Update the default css for giblish html generation.
9
+ * Maybe put some effort into the ConversionInfo hierarchy
10
+
11
+ == v1.0.0
12
+
13
+ This release includes a complete refactoring of almost the entire code base.
14
+
15
+ Breaking changes::
16
+ * The '-w' flag is removed
17
+ * The text search parameters interface has changed completely. A written specification of this interface is included in the docs.
18
+ * The '-r' flag will, for html generation, *copy everything* under the given directory to the target location.
19
+ ** the previous restriction on folder names has been removed.
20
+ * 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.
21
+ * The doc attribute `:icons: font` is now set by default.
22
+ * The source highlighter attributes are now set as follows by default:
23
+ ** :source-highlighter: rouge :rouge-css: style :rouge-style: github
24
+ * The format of the index pages has been updated
25
+
26
+ Changes/New functionality::
27
+ * Rouge is used as source highlighter and the default is to use the following attributes:
28
+ ** :rouge-css: style
29
+ ** :rouge-style: github
30
+ * 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.
31
+ * 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.
32
+ * A --copy-asset-folders flag can be used to copying full directories from the source to the destination tree.
33
+ * Index pages are generated for each subdirectory in the target document tree.
34
+ * The format of the git summary page has been updated and more info included.
35
+ * The text search server-side cgi script has been rewritten.
36
+ * The text search for web-server-served html docs has been updated in the following ways:
37
+ ** the asciidoc 'include' directive is supported by expanding them and include the resulting text in the search database.
38
+ ** the implementation of the server-side search tools are written completely in ruby and does no longer depend on an external 'grep' tool.
39
+ ** almost all needed infrastructure for implementing a server-side search script has been implemented within the 'giblish' gem.
40
+ * The asciidoctor toolchain dependencies are updated to the latest versions (at the time of release).
41
+
42
+
43
+ == v0.8.0
44
+
45
+ * *Breaking change* require ruby 2.7
46
+ * update asciidoctor tool deps to latest versions
47
+
48
+ == v0.7.0
49
+
50
+ * *Breaking change* include the entire path in the -i and -j options
51
+ * *Breaking change* change the meaning of the -w flag (and rename the long form to --web-path)
52
+ and add the -mp flag.
53
+ This was done as a means to remove the hard-coded arguments to the search box html so that one
54
+ can generate html docs to a destination that is not the same as the one where they are deployed
55
+ on a web server.
56
+ * take the idprefix and idseparator into account when indexing sections for text search
57
+ * Add the font awesome css as link to search box and use the magnifying glass icon
58
+ * update README file
59
+ * handle the case where a 'index.adoc' file exists by making the basename configurable using the
60
+ '--index-basename' flag.
61
+ * update the dependencies to the latest asciidoctor-pdf release
data/README.adoc ADDED
@@ -0,0 +1,267 @@
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
+ * A (stripped-down but nonetheless useful) text-search of your (html) documents (requires that you view your docs via a web-server.
40
+ * 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).
41
+ * 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:
42
+ ** 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.
43
+ ** Validate doc id references during document rendering and thus be alerted to any invalid doc id references.
44
+ ** Let giblish generate a clickable graph of all document references (requires graphviz and the 'dot' tool).
45
+
46
+ NOTE: giblish shall be considered stable from a usage perspective, please report bugs to the issue tracker. It's API however, is to be considered alpha, meaning that future versions may break the current usage of cmd line flags, generated artifacts, styling or other functionality.
47
+
48
+ == Dependencies and credits
49
+
50
+ Giblish uses the awesome *asciidoctor* and *asciidoctor-pdf* projects under the hood. Thank you @mojavelinux and others for making these brilliant tools available!!
51
+
52
+ == Installation
53
+
54
+ gem install giblish
55
+
56
+ Want to get started straight away? Go directly to the <<usage_examples>>.
57
+
58
+ // install script for linux deps to the mathematica gem:
59
+ // https://github.com/gjtorikian/mathematical/blob/47041d5492cc7c5f04105031430fb44119406f49/script/install_linux_deps
60
+ //
61
+ // Graphviz needed for some tests to pass
62
+
63
+
64
+ === Some caveats
65
+
66
+ When using giblish for generating docs the following applies:
67
+
68
+ * giblish *will overwrite* files with the same name in the destination directory.
69
+ * giblish requires that the git working tree and index of the repo containing source documents are clean when generating documentation.
70
+ * 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.
71
+
72
+ == Contributing
73
+
74
+ If you want to contribute to giblish, great :) Use the standard GitHub flow of forking the repo and submit a pull request.
75
+
76
+ Pull requests must meet the following to be considered for merging:
77
+
78
+ * Tests have been added for new or updated functionality
79
+ * The code has been linted using the `standardrb` tool.
80
+ ** The version of standardrb shall be the same as the one used in the target branch for the PR.
81
+
82
+ To develop on giblish, you:
83
+
84
+ . Install ruby on your local machine (rbenv is a good choice for handling ruby installations)
85
+ . Clone or fork the repository
86
+ . Run the `bin/setup` script from a bash prompt
87
+
88
+ == Document ids and the reference graph
89
+
90
+ 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.
91
+
92
+ giblish extends the cross reference concept in asciidoc with a _document id_ mechanism. To use this, you need to:
93
+
94
+ . 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.
95
+ . 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.
96
+ . Run giblish with the -d switch when generating documents.
97
+
98
+ Using doc ids makes it possible for giblish to do two things:
99
+
100
+ . Make the reference from one document to another work even if one of the documents have been moved within the source tree.
101
+ . 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).
102
+
103
+ 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.
104
+
105
+ === Example of using the docid feature
106
+
107
+ 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.
108
+
109
+ Example document one::
110
+
111
+ [source,asciidoc]
112
+ ----
113
+ = Document one
114
+ :toc:
115
+ :numbered:
116
+ :docid: G-001
117
+
118
+ == Purpose
119
+
120
+ To illustrate the use of doc id.
121
+ ----
122
+
123
+ Example document two::
124
+ [source,asciidoc]
125
+ ----
126
+ = Document two
127
+ :toc:
128
+ :numbered:
129
+ :docid: G-002
130
+
131
+ == Purpose
132
+
133
+ 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).
134
+
135
+ You can use the same syntax as the normal asciidoc cross-ref but replace 'xref' with ':docid:' as shown below:
136
+
137
+ * <<:docid:G-002#purpose>> to refer to a specific section or anchor.
138
+ * <<:docid:G-002#purpose,The purpose section>> to refer to a specific section and display a specific text for the link.
139
+ ----
140
+
141
+ 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.
142
+
143
+ [[usage_examples]]
144
+ == Usage Examples
145
+
146
+ Here follows a number of usages for giblish in increasing order of complexity.
147
+
148
+ === Get available options
149
+
150
+ giblish -h
151
+
152
+ === Giblish html 'hello world'
153
+
154
+ giblish my_src_root my_dst_root
155
+
156
+ * 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.
157
+ * 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.
158
+
159
+ The default asciidoctor css will be used in the html conversion.
160
+
161
+ === Giblish pdf 'hello world'
162
+
163
+ giblish -f pdf my_src_root my_dst_root
164
+
165
+ * 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.
166
+ * 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.
167
+
168
+ The default asciidoctor pdf theme will be used in the pdf conversion.
169
+
170
+ === Using a custom css for the generated html
171
+
172
+ Generate html that can be browsed locally from file:://<my_dst_root>.
173
+
174
+ giblish -r path/to/my/resources -s mylayout my_src_root my_dst_root
175
+
176
+ * 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.
177
+ * 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.
178
+ * copy the `css`, `fonts` and `images` directories found under `<working_dir>/path/to/my/resources` to `my_dst_root/web_assets`
179
+ * link all generated html files to the css found at `/web_assets/css/mylayout.css`
180
+
181
+ === Using a custom pdf theme for the generated pdfs
182
+
183
+ giblish -f pdf -r path/to/my/resources -s mylayout my_src_root my_dst_root
184
+
185
+ * 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.
186
+ * the generated pdf will use the theme found at `<working_dir>/path/to/my/resources/themes/mylayout.yml`
187
+
188
+ === Generate html from multiple git branches
189
+
190
+ giblish -g "feature" my_src_root my_dst_root
191
+
192
+ * check-out each branch matching the regexp "feature" in turn
193
+ * for each checked-out branch,
194
+ ** convert the .adoc or .ADOC files under the dir `my_src_root` to html.
195
+ ** place the resulting files under the `my_dst_root/<branch_name>` dir.
196
+ ** 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.
197
+ * generate a summary page containing links to a all branches and place it in the `my_dst_root` dir.
198
+
199
+ === Publish the asciidoctor.org documents with text search
200
+
201
+ 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.
202
+
203
+ 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.
204
+
205
+ 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.
206
+
207
+ ==== Generating the html documents
208
+
209
+ 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.
210
+
211
+ The generated docs shall be accessible via _www.example.com/adocorg/with_search_
212
+
213
+ You need to provide two pieces of deployment info to giblish when generating the documents:
214
+
215
+ * the uri path where to access the deployed docs (/adocorg/with_search in this example)
216
+ * the path in the local file system on the web server where the search data can be accessed
217
+ (/var/www/html/site_1/adocorg/with_search in this example)
218
+
219
+ The following commands will generate the asciidoctor.org documentation and deploy the result to the web server.
220
+
221
+ . Clone the asciidoctor doc repo to your development machine
222
+ +
223
+ git clone https://github.com/asciidoctor/asciidoctor.org.git
224
+
225
+ . Generate the html documentation with the correct deployment info
226
+ +
227
+ 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
228
+ +
229
+ Explanation of the parameters and arguments::
230
+ * *pass:[-j '^.*_include.*']* - exclude everything in the __include_ directory. (the
231
+ asciidoctor.org repo stores partial docs here).
232
+ * *-m* - assemble the necessary search data to support text search and include this data as part of
233
+ the generated documents.
234
+ * *-mp /var/www/html/site_1/adocorg/with_search* - the file system path on the deployment machine where
235
+ the search data is located
236
+ * *-w /adocorg/with_search* - the uri path to the deployed docs
237
+ * *-g master* - publish all git branches that matches the regexp 'master' (i.e. only the 'master'
238
+ branch).
239
+ * *--index-basename "myindex"* - change the default name (index) that giblish uses for the generated
240
+ index page. This is needed since asciidoctor.org contains an
241
+ "index.adoc" file that would otherwise be overwritten by giblish.
242
+ * *asciidoctor.org/docs* - the root of the source document tree.
243
+ * *./generated_docs* - a temporary storage for the generated html docs on the local system.
244
+ +
245
+
246
+ . Copy the generated files to the web server
247
+
248
+ scp -r ./generated_docs rillbert@my.web.server.org:/var/www/adocorg/with_search/.
249
+ +
250
+
251
+
252
+ ==== Copy the text search script to the web server
253
+
254
+ This only needs to be done once (or if a new version of giblish breaks the currently used API).
255
+
256
+ 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
257
+
258
+ . Find the server side script that implements text search that is included with giblish
259
+
260
+ gem which giblish
261
+ +
262
+
263
+ 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`.
264
+
265
+ . 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`
266
+ +
267
+ 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
+