diff options
-rw-r--r-- | res/about/help.gmi | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/res/about/help.gmi b/res/about/help.gmi index f71f5164..32cb0595 100644 --- a/res/about/help.gmi +++ b/res/about/help.gmi | |||
@@ -57,7 +57,7 @@ If one seeks to just read text and view images, this is absurd overkill. Having | |||
57 | 57 | ||
58 | One way to browse Gemini content is via web browser extensions or proxies that translate the content for the web. This may be a sufficient and easy solution for you. However, native clients such as Lagrange also benefit from the simpleness of the protocol and the content. The experience can be optimized, and the software runs well even on simple hardware like the Raspberry Pi. | 58 | One way to browse Gemini content is via web browser extensions or proxies that translate the content for the web. This may be a sufficient and easy solution for you. However, native clients such as Lagrange also benefit from the simpleness of the protocol and the content. The experience can be optimized, and the software runs well even on simple hardware like the Raspberry Pi. |
59 | 59 | ||
60 | # User interface | 60 | # 1 User interface |
61 | 61 | ||
62 | Lagrange's user interface is modeled after web browsers: | 62 | Lagrange's user interface is modeled after web browsers: |
63 | 63 | ||
@@ -75,9 +75,9 @@ The user interface has been designed for both mouse and keyboard based use. When | |||
75 | * Tab (or ↓) to move focus to the lookup results | 75 | * Tab (or ↓) to move focus to the lookup results |
76 | * Enter to select "CAPCOM" | 76 | * Enter to select "CAPCOM" |
77 | 77 | ||
78 | ## Navigation | 78 | ## 1.1 Navigation |
79 | 79 | ||
80 | ### URL entry and quick search | 80 | ### 1.1.1 URL entry and quick search |
81 | 81 | ||
82 | The URL input field is in its typical location in the navigation bar. It can be accessed quickly by pressing ${CTRL+}L. You can then type or paste an URL and press Enter to load the page. | 82 | The URL input field is in its typical location in the navigation bar. It can be accessed quickly by pressing ${CTRL+}L. You can then type or paste an URL and press Enter to load the page. |
83 | 83 | ||
@@ -87,7 +87,7 @@ Search within cached pages is limited to the (small) set of pages that Lagrange | |||
87 | 87 | ||
88 | Note that the navigation stack is saved to a file when Lagrange is shut down and restored on the next launch. This means the next time you launch Lagrange, you can still search the contents of past pages. However, navigation stacks are tab-specific, so closing a tab will delete its history as well. | 88 | Note that the navigation stack is saved to a file when Lagrange is shut down and restored on the next launch. This means the next time you launch Lagrange, you can still search the contents of past pages. However, navigation stacks are tab-specific, so closing a tab will delete its history as well. |
89 | 89 | ||
90 | ### Links | 90 | ### 1.1.2 Links |
91 | 91 | ||
92 | The type and destination of a link are indicated by the link's icon and color: ➤ links to the same domain, and 🌐 to a different domain. The colors are: | 92 | The type and destination of a link are indicated by the link's icon and color: ➤ links to the same domain, and 🌐 to a different domain. The colors are: |
93 | 93 | ||
@@ -100,19 +100,19 @@ Link colors remain the same regardless of which color theme is being used for pa | |||
100 | 100 | ||
101 | When you move the mouse cursor over a link, additional information will appear: the destination domain, with the URL scheme shown for non-Gemini links, and the date of the last visit to the URL. | 101 | When you move the mouse cursor over a link, additional information will appear: the destination domain, with the URL scheme shown for non-Gemini links, and the date of the last visit to the URL. |
102 | 102 | ||
103 | ### Note about caching | 103 | ### 1.1.3 Page caching |
104 | 104 | ||
105 | When navigating to a new page, the old page is cached in memory. If you navigate back, the cached copy of the page is restored. Think of it as rewinding time — you return to a past time as if nothing had happened. The same applies to forward navigation; cached pages are loaded if available. This allows back and forward navigation to happen instantly, without any network requests. | 105 | When navigating to a new page, the old page is cached in memory. If you navigate back, the cached copy of the page is restored. Think of it as rewinding time — you return to a past time as if nothing had happened. The same applies to forward navigation; cached pages are loaded if available. This allows back and forward navigation to happen instantly, without any network requests. |
106 | 106 | ||
107 | The page cache is saved to a file when Lagrange is shut down so it can be restored on the next launch. | 107 | The page cache is saved to a file when Lagrange is shut down so it can be restored on the next launch. |
108 | 108 | ||
109 | ### Opening links in a new tab | 109 | ### 1.1.4 Opening links in a new tab |
110 | 110 | ||
111 | Holding down ${CTRL} when left-clicking on a link causes it to open in a new tab. Alternatively, middle-clicking a link has the same effect. | 111 | Holding down ${CTRL} when left-clicking on a link causes it to open in a new tab. Alternatively, middle-clicking a link has the same effect. |
112 | 112 | ||
113 | Right-clicking on a link shows a link-specific context menu. From there, you can also open the link in a new background tab, which will keep the current tab open. | 113 | Right-clicking on a link shows a link-specific context menu. From there, you can also open the link in a new background tab, which will keep the current tab open. |
114 | 114 | ||
115 | ### Opening links using the keyboard | 115 | ### 1.1.5 Opening links using the keyboard |
116 | 116 | ||
117 | Lagrange has two modes for navigating links with the keyboard. The first uses a modifier key (${ALT} by default): while the modifier is pressed, alphanumeric shortcuts are shown for each visible link in the window. You can then press the corresponding key, still holding the modifier, to open a link. The second mode is based on letters only and focuses on the page row keys. You press and release the activation key ("F" by default) to show the link shortcut letters. In this mode the shortcuts are not in alphabetic order, but instead roughly sorted based on proximity to the F and J keys. You may find this easier to use since it is a simple sequence of key presses without using modifiers, allowing one to keep fingers on or near the home row. | 117 | Lagrange has two modes for navigating links with the keyboard. The first uses a modifier key (${ALT} by default): while the modifier is pressed, alphanumeric shortcuts are shown for each visible link in the window. You can then press the corresponding key, still holding the modifier, to open a link. The second mode is based on letters only and focuses on the page row keys. You press and release the activation key ("F" by default) to show the link shortcut letters. In this mode the shortcuts are not in alphabetic order, but instead roughly sorted based on proximity to the F and J keys. You may find this easier to use since it is a simple sequence of key presses without using modifiers, allowing one to keep fingers on or near the home row. |
118 | 118 | ||
@@ -120,13 +120,13 @@ You can give it a try now with the link below. Either hold down ${ALT}, or press | |||
120 | 120 | ||
121 | => gemini://gemini.circumlunar.space/ Project Gemini | 121 | => gemini://gemini.circumlunar.space/ Project Gemini |
122 | 122 | ||
123 | ## Tabs | 123 | ## 1.2 Tabs |
124 | 124 | ||
125 | Press ${CTRL+}T to open a new tab, and ${CTRL+}W to close the current tab. Right-clicking on buttons in the tab bar shows a context menu for additional tab-related functions. | 125 | Press ${CTRL+}T to open a new tab, and ${CTRL+}W to close the current tab. Right-clicking on buttons in the tab bar shows a context menu for additional tab-related functions. |
126 | 126 | ||
127 | The set of open tabs is restored when you launch Lagrange. | 127 | The set of open tabs is restored when you launch Lagrange. |
128 | 128 | ||
129 | ## Sidebars | 129 | ## 1.3 Sidebars |
130 | 130 | ||
131 | The sidebars can be toggled via menus or by pressing ${SHIFT+}${CTRL+}L or ${SHIFT+}${CTRL+}P (for the left/right sidebar, respectively). Both sidebars have five tabs: | 131 | The sidebars can be toggled via menus or by pressing ${SHIFT+}${CTRL+}L or ${SHIFT+}${CTRL+}P (for the left/right sidebar, respectively). Both sidebars have five tabs: |
132 | 132 | ||
@@ -138,7 +138,7 @@ The sidebars can be toggled via menus or by pressing ${SHIFT+}${CTRL+}L or ${SHI | |||
138 | 138 | ||
139 | ${CTRL+}1 through ${CTRL+}5 switch between the left sidebar tabs, or hide the sidebar if the current tab's key is pressed. You can also press Escape to dismiss sidebars. | 139 | ${CTRL+}1 through ${CTRL+}5 switch between the left sidebar tabs, or hide the sidebar if the current tab's key is pressed. You can also press Escape to dismiss sidebars. |
140 | 140 | ||
141 | ## Bookmarks | 141 | ## 1.4 Bookmarks |
142 | 142 | ||
143 | Press ${CTRL+}D to bookmark the currently open URL. | 143 | Press ${CTRL+}D to bookmark the currently open URL. |
144 | 144 | ||
@@ -152,7 +152,7 @@ In addition to a title, bookmarks can have tags. Some tags have a special meanin | |||
152 | * A "subscribed" tag means that Lagrange will periodically fetch the bookmarked page and look for Gemini feed links. All the found links that match the required style ("YYYY-MM-DD Entry title") will appear in the Feeds sidebar tab. | 152 | * A "subscribed" tag means that Lagrange will periodically fetch the bookmarked page and look for Gemini feed links. All the found links that match the required style ("YYYY-MM-DD Entry title") will appear in the Feeds sidebar tab. |
153 | * "headings" can be used together with "subscribed" to subscribe to new headings instead of Gemini feed links. | 153 | * "headings" can be used together with "subscribed" to subscribe to new headings instead of Gemini feed links. |
154 | 154 | ||
155 | ## Feeds | 155 | ## 1.5 Feeds |
156 | 156 | ||
157 | You may be familiar with RSS and Atom XML feeds from the web. Lagrange does _not_ support RSS or Atom, only Gemini feeds. A Gemini feed is simply a regular 'text/gemini' page that contains one or more links whose labels are formatted in a particular way. | 157 | You may be familiar with RSS and Atom XML feeds from the web. Lagrange does _not_ support RSS or Atom, only Gemini feeds. A Gemini feed is simply a regular 'text/gemini' page that contains one or more links whose labels are formatted in a particular way. |
158 | 158 | ||
@@ -167,13 +167,13 @@ The Feeds sidebar tab displays recent feed entries. From there you can open entr | |||
167 | To see all entries from all feeds, open the "Feed entries" page. This page also shows how long has it been since the previous feed refresh. | 167 | To see all entries from all feeds, open the "Feed entries" page. This page also shows how long has it been since the previous feed refresh. |
168 | => about:feeds | 168 | => about:feeds |
169 | 169 | ||
170 | ## Identities (client certificates) | 170 | ## 1.6 Identities (client certificates) |
171 | 171 | ||
172 | Gemini uses TLS client certificates for user/session identification purposes. Unlike on the web where user identity tracking is covert and automatic, client certificates must be manually taken into use, and you are able to define how long each certificate remains valid. The term "Identity" is used in Lagrange to refer to client certificates. | 172 | Gemini uses TLS client certificates for user/session identification purposes. Unlike on the web where user identity tracking is covert and automatic, client certificates must be manually taken into use, and you are able to define how long each certificate remains valid. The term "Identity" is used in Lagrange to refer to client certificates. |
173 | 173 | ||
174 | The Identities sidebar tab shows all identities known to Lagrange. Press ${CTRL+}4 to show it. This includes identities created in Lagrange and any identities based on imported X.509 certificates. | 174 | The Identities sidebar tab shows all identities known to Lagrange. Press ${CTRL+}4 to show it. This includes identities created in Lagrange and any identities based on imported X.509 certificates. |
175 | 175 | ||
176 | ### Creating a new identity | 176 | ### 1.6.1 Creating a new identity |
177 | 177 | ||
178 | Click on the 👤 button in the navigation bar and select "New Identity...". The shortcut for this is ${SHIFT+}${CTRL+}N. | 178 | Click on the 👤 button in the navigation bar and select "New Identity...". The shortcut for this is ${SHIFT+}${CTRL+}N. |
179 | 179 | ||
@@ -181,7 +181,7 @@ Consider any information you enter in the certificate as public — only the Com | |||
181 | 181 | ||
182 | The "Temporary" option prevents the identity from being saved persistently — it will be deleted as soon as you quit Lagrange. Otherwise, the certificate and its private key are written to .crt and .pem files. | 182 | The "Temporary" option prevents the identity from being saved persistently — it will be deleted as soon as you quit Lagrange. Otherwise, the certificate and its private key are written to .crt and .pem files. |
183 | 183 | ||
184 | ### Using an identity | 184 | ### 1.6.2 Using an identity |
185 | 185 | ||
186 | You will need to select an identity when you encounter this error message: | 186 | You will need to select an identity when you encounter this error message: |
187 | 187 | ||
@@ -191,14 +191,14 @@ Clicking on an identity in the sidebar will toggle it on/off for the currently o | |||
191 | 191 | ||
192 | As the sidebar is not keyboard-navigable, note that identities can also be accessed via lookup results. Identities matching the search terms are shown as the last category in the lookup results list. From there, one can toggle an identity for the current page, or stop using it on all pages. | 192 | As the sidebar is not keyboard-navigable, note that identities can also be accessed via lookup results. Identities matching the search terms are shown as the last category in the lookup results list. From there, one can toggle an identity for the current page, or stop using it on all pages. |
193 | 193 | ||
194 | ### Importing existing certificates | 194 | ### 1.6.3 Importing existing certificates |
195 | 195 | ||
196 | At launch, Lagrange looks through its "idents" directory to see if any new certificates have been copied there. (See "Runtime files" below for the location.) The file format must be PEM. Both a certificate (.crt) and its private key (.key) must be found in "idents" and they must have matching file names. For example: | 196 | At launch, Lagrange looks through its "idents" directory to see if any new certificates have been copied there. (See "Runtime files" below for the location.) The file format must be PEM. Both a certificate (.crt) and its private key (.key) must be found in "idents" and they must have matching file names. For example: |
197 | * mycert.crt | 197 | * mycert.crt |
198 | * mycert.key | 198 | * mycert.key |
199 | Lagrange will add a note to the imported identities to mark them as "Imported". | 199 | Lagrange will add a note to the imported identities to mark them as "Imported". |
200 | 200 | ||
201 | ## Downloads | 201 | ## 1.7 Downloads |
202 | 202 | ||
203 | Press ${CTRL+}S to save the contents of the current page to the Downloads folder. This works on all pages regardless of whether Lagrange can display the contents or not. | 203 | Press ${CTRL+}S to save the contents of the current page to the Downloads folder. This works on all pages regardless of whether Lagrange can display the contents or not. |
204 | 204 | ||
@@ -208,15 +208,15 @@ The 🔃 button on the right side of the URL input field is the Reload/Stop butt | |||
208 | 208 | ||
209 | The location where downloaded files are saved can be changed in Preferences. The default location is "Downloads" in your home directory. | 209 | The location where downloaded files are saved can be changed in Preferences. The default location is "Downloads" in your home directory. |
210 | 210 | ||
211 | ## Customization | 211 | # 2 Customization |
212 | 212 | ||
213 | You can find a number of settings in Preferences to customize the user interface and page contents. | 213 | You can find a number of settings in Preferences to customize the user interface and page contents. |
214 | 214 | ||
215 | ### Browsing behavior | 215 | ## 2.1 Browsing behavior |
216 | 216 | ||
217 | One important characteristic of Gemini is that you remain in control of what gets loaded and when. The browser will not suddenly fetch a ton of images, autoplay videos, or make surreptitious connections to any tracking servers — each network request is purposeful and manually triggered. With this in mind, the "Load image on scroll" option is provided to assist keyboard-only browsing and to facilitate a focused reading experience. When enabled, if there is an image link visible on the page and you press Space or ↓, it will be loaded and shown inline _instead_ of the view scrolling down. This allows you to read and see all the content of the page while only tapping on a single key on the keyboard. | 217 | One important characteristic of Gemini is that you remain in control of what gets loaded and when. The browser will not suddenly fetch a ton of images, autoplay videos, or make surreptitious connections to any tracking servers — each network request is purposeful and manually triggered. With this in mind, the "Load image on scroll" option is provided to assist keyboard-only browsing and to facilitate a focused reading experience. When enabled, if there is an image link visible on the page and you press Space or ↓, it will be loaded and shown inline _instead_ of the view scrolling down. This allows you to read and see all the content of the page while only tapping on a single key on the keyboard. |
218 | 218 | ||
219 | ### Window and UI options | 219 | ## 2.2 Window and UI options |
220 | 220 | ||
221 | Lagrange supports configuring dark and light UI modes separately. | 221 | Lagrange supports configuring dark and light UI modes separately. |
222 | 222 | ||
@@ -231,7 +231,7 @@ Options for wide window sizes: | |||
231 | 231 | ||
232 | * Site icon: If there is room on the left side of the page text, the site icon appears there along with the top level heading. This allows one to keep better track of the current reading position in long documents. | 232 | * Site icon: If there is room on the left side of the page text, the site icon appears there along with the top level heading. This allows one to keep better track of the current reading position in long documents. |
233 | 233 | ||
234 | ### Color themes | 234 | ## 2.3 Color themes |
235 | 235 | ||
236 | Page content color themes are selected on the "Colors" tab of Preferences. The "Dark theme" is active in dark UI mode, and the "Light theme" is active in light UI mode. | 236 | Page content color themes are selected on the "Colors" tab of Preferences. The "Dark theme" is active in dark UI mode, and the "Light theme" is active in light UI mode. |
237 | 237 | ||
@@ -243,7 +243,7 @@ Page content color themes are selected on the "Colors" tab of Preferences. The " | |||
243 | * Sepia: Light sepia background with black text. Does not change depending on domain; use this for readability if you prefer a sepia reading experience. | 243 | * Sepia: Light sepia background with black text. Does not change depending on domain; use this for readability if you prefer a sepia reading experience. |
244 | * High Contrast: White background with black text. Does not change depending on domain; use this for readability if you prefer maximum contrast between text and the background. | 244 | * High Contrast: White background with black text. Does not change depending on domain; use this for readability if you prefer maximum contrast between text and the background. |
245 | 245 | ||
246 | ### Page style | 246 | ## 2.4 Page style |
247 | 247 | ||
248 | The "Style" tab of the Preferences dialog lets you customize the appearance and layout of page content. | 248 | The "Style" tab of the Preferences dialog lets you customize the appearance and layout of page content. |
249 | 249 | ||
@@ -262,13 +262,13 @@ Other style options: | |||
262 | * Quote indicator: Quoted text is shown in an italic font. Additionally, you can select between a quotation mark icon and the traditional vertical line along the left edge of the quote. | 262 | * Quote indicator: Quoted text is shown in an italic font. Additionally, you can select between a quotation mark icon and the traditional vertical line along the left edge of the quote. |
263 | * Big 1st paragraph: When enabled, the leading paragraph on the page is shown in a slightly larger font. | 263 | * Big 1st paragraph: When enabled, the leading paragraph on the page is shown in a slightly larger font. |
264 | 264 | ||
265 | ### Proxies | 265 | ## 2.5 Proxies |
266 | 266 | ||
267 | Gemini allows relaying requests via a proxy server. On the "Proxies" tab, you can configure proxy servers for Gemini, Gopher, and HTTP/HTTPS requests. | 267 | Gemini allows relaying requests via a proxy server. On the "Proxies" tab, you can configure proxy servers for Gemini, Gopher, and HTTP/HTTPS requests. |
268 | 268 | ||
269 | When an HTTP proxy server is configured, HTTP/HTTPS links will no longer open in the system's default web browser but will be loaded via the proxy, expecting it to serve a 'text/gemini' version of the link contents. | 269 | When an HTTP proxy server is configured, HTTP/HTTPS links will no longer open in the system's default web browser but will be loaded via the proxy, expecting it to serve a 'text/gemini' version of the link contents. |
270 | 270 | ||
271 | ### Keybindings | 271 | ## 2.6 Keybindings |
272 | 272 | ||
273 | The "Keys" tab lets you change which keys are bound to UI commands. Click on an item with the mouse and then press the new key combination that you want bound to it. Right-click on a binding to erase it or reset it to the default. | 273 | The "Keys" tab lets you change which keys are bound to UI commands. Click on an item with the mouse and then press the new key combination that you want bound to it. Right-click on a binding to erase it or reset it to the default. |
274 | 274 | ||
@@ -276,9 +276,9 @@ Erasing a binding can be useful to disable certain features. For example, if you | |||
276 | 276 | ||
277 | To reset all bindings to their defaults, quit Lagrange and delete the "bindings.txt" file in Lagrange's runtime directory. This is a platform-dependent location; see below for more information (under "Runtime files"). | 277 | To reset all bindings to their defaults, quit Lagrange and delete the "bindings.txt" file in Lagrange's runtime directory. This is a platform-dependent location; see below for more information (under "Runtime files"). |
278 | 278 | ||
279 | # OS integration | 279 | # 3 OS integration |
280 | 280 | ||
281 | ## Command line options | 281 | ## 3.1 Command line options |
282 | 282 | ||
283 | ### URLs | 283 | ### URLs |
284 | URLs on the command line are opened after Lagrange has launched. If more than one URL is given, multiple tabs will be opened. For example: | 284 | URLs on the command line are opened after Lagrange has launched. If more than one URL is given, multiple tabs will be opened. For example: |
@@ -292,17 +292,17 @@ Debugging utility: internal events are printed to stdout. | |||
292 | ### --sw | 292 | ### --sw |
293 | Disable hardware accelerated graphics. Note that software rendering is anyway used as a fallback, so usually this option should not be necessary. | 293 | Disable hardware accelerated graphics. Note that software rendering is anyway used as a fallback, so usually this option should not be necessary. |
294 | 294 | ||
295 | ## Opening Gemini links | 295 | ## 3.2 Opening Gemini links |
296 | 296 | ||
297 | On macOS and Windows, Lagrange registers itself as a "gemini:" URL scheme handler, so you can click on Gemini links in any application to open Lagrange with that URL. | 297 | On macOS and Windows, Lagrange registers itself as a "gemini:" URL scheme handler, so you can click on Gemini links in any application to open Lagrange with that URL. |
298 | 298 | ||
299 | Likewise (on macOS), .gmi/.gemini file extensions are registered as file formats that Lagrange can view so Finder will know how to open those automatically using Lagrange. | 299 | Likewise (on macOS), .gmi/.gemini file extensions are registered as file formats that Lagrange can view so Finder will know how to open those automatically using Lagrange. |
300 | 300 | ||
301 | ## Drop and drop | 301 | ## 3.3 Drop and drop |
302 | 302 | ||
303 | You can drag and drop .gmi files on the Lagrange window to open them in the current tab. Dropping multiple files opens them in separate tabs. This is the recommended way to view local files, because there is no "Open File" menu item. You may also type "file://" URLs in the URL field. | 303 | You can drag and drop .gmi files on the Lagrange window to open them in the current tab. Dropping multiple files opens them in separate tabs. This is the recommended way to view local files, because there is no "Open File" menu item. You may also type "file://" URLs in the URL field. |
304 | 304 | ||
305 | ## Runtime files | 305 | ## 3.4 Runtime files |
306 | 306 | ||
307 | Lagrange stores user-specific persistent files in one of the following locations (depending on the operating system): | 307 | Lagrange stores user-specific persistent files in one of the following locations (depending on the operating system): |
308 | 308 | ||
@@ -322,7 +322,7 @@ Other Unix : ~/.config/lagrange/ | |||
322 | * trusted.txt | 322 | * trusted.txt |
323 | * visited.txt | 323 | * visited.txt |
324 | 324 | ||
325 | # MIME hooks | 325 | # 4 MIME hooks |
326 | 326 | ||
327 | MIME hooks enable piping Gemini responses through external programs for arbitrary processing. This allows leveraging scripting languages and binary executables to perform format conversions, content transformation, and data analysis. | 327 | MIME hooks enable piping Gemini responses through external programs for arbitrary processing. This allows leveraging scripting languages and binary executables to perform format conversions, content transformation, and data analysis. |
328 | 328 | ||
@@ -335,13 +335,13 @@ Example use cases: | |||
335 | * Converting HTML or Markdown to 'text/gemini' | 335 | * Converting HTML or Markdown to 'text/gemini' |
336 | * Language translations | 336 | * Language translations |
337 | 337 | ||
338 | ## Interface | 338 | ## 4.1 Interface |
339 | 339 | ||
340 | When a hook is called, it is given the MIME type and parameters via command line arguments. The response body is provided via stdin. The request's URL is available in the REQUEST_URL environment variable. | 340 | When a hook is called, it is given the MIME type and parameters via command line arguments. The response body is provided via stdin. The request's URL is available in the REQUEST_URL environment variable. |
341 | 341 | ||
342 | The MIME type and parameters are split at semicolons, so "text/gemini; lang=ja" would be called as: | 342 | The MIME type and parameters are split at semicolons, so "text/gemini; lang=ja" would be called as: |
343 | ``` | 343 | ``` |
344 | hookprogram text/gemini lang=ja | 344 | hookprogram text/gemini lang=ja |
345 | ``` | 345 | ``` |
346 | 346 | ||
347 | Output from the program (via stdout) must be a valid "20" Gemini response that includes the new MIME type: | 347 | Output from the program (via stdout) must be a valid "20" Gemini response that includes the new MIME type: |
@@ -352,7 +352,7 @@ Output from the program (via stdout) must be a valid "20" Gemini response that i | |||
352 | 352 | ||
353 | Any output that does not follow this format is considered to mean that the hook refused to process the contents. The next hook will be offered the response instead. | 353 | Any output that does not follow this format is considered to mean that the hook refused to process the contents. The next hook will be offered the response instead. |
354 | 354 | ||
355 | ## mimehooks.txt syntax | 355 | ## 4.2 mimehooks.txt syntax |
356 | 356 | ||
357 | Like other Lagrange configuration lines, mimehooks.txt has a simple line-oriented syntax. Lagrange must be restarted for changes to the configuration file to take effect. | 357 | Like other Lagrange configuration lines, mimehooks.txt has a simple line-oriented syntax. Lagrange must be restarted for changes to the configuration file to take effect. |
358 | 358 | ||
@@ -370,7 +370,7 @@ application/xml | |||
370 | 370 | ||
371 | The hook program is executed directly without involving the shell. This means scripts must be invoked via the interpreter executable. | 371 | The hook program is executed directly without involving the shell. This means scripts must be invoked via the interpreter executable. |
372 | 372 | ||
373 | ## Example: Converting from Atom to Gemini | 373 | ## 4.3 Example: Converting from Atom to Gemini |
374 | 374 | ||
375 | The following simple Python script demonstrates how a MIME hook could be used to parse an Atom XML document using Python 3 and output a Gemini feed index page based on the parsed entries. This is just a simple example; a more robust script could include more content from the Atom feed and handle errors, too. | 375 | The following simple Python script demonstrates how a MIME hook could be used to parse an Atom XML document using Python 3 and output a Gemini feed index page based on the parsed entries. This is just a simple example; a more robust script could include more content from the Atom feed and handle errors, too. |
376 | ``` | 376 | ``` |
@@ -381,7 +381,7 @@ def atomtag(n): | |||
381 | return '{http://www.w3.org/2005/Atom}' + n | 381 | return '{http://www.w3.org/2005/Atom}' + n |
382 | 382 | ||
383 | root = ET.fromstring(sys.stdin.read()) | 383 | root = ET.fromstring(sys.stdin.read()) |
384 | if root.tag != atomtag('feed'): | 384 | if root.tag != atomtag('feed'): |
385 | sys.exit(0) | 385 | sys.exit(0) |
386 | feed_title = '' | 386 | feed_title = '' |
387 | feed_author = '' | 387 | feed_author = '' |
@@ -390,19 +390,19 @@ for child in root: | |||
390 | if child.tag == atomtag('title'): | 390 | if child.tag == atomtag('title'): |
391 | feed_title = child.text | 391 | feed_title = child.text |
392 | elif child.tag == atomtag('entry'): | 392 | elif child.tag == atomtag('entry'): |
393 | feed_entries.append(child) | 393 | feed_entries.append(child) |
394 | print("20 text/gemini\r") | 394 | print("20 text/gemini\r") |
395 | print(f'# {feed_title}') | 395 | print(f'# {feed_title}') |
396 | for entry in feed_entries: | 396 | for entry in feed_entries: |
397 | entry_date = '' | 397 | entry_date = '' |
398 | entry_title = '' | 398 | entry_title = '' |
399 | entry_link = '' | 399 | entry_link = '' |
400 | for child in entry: | 400 | for child in entry: |
401 | if child.tag == atomtag('updated'): | 401 | if child.tag == atomtag('updated'): |
402 | entry_date = child.text[:10] | 402 | entry_date = child.text[:10] |
403 | elif child.tag == atomtag('title'): | 403 | elif child.tag == atomtag('title'): |
404 | entry_title = child.text | 404 | entry_title = child.text |
405 | elif child.tag == atomtag('link'): | 405 | elif child.tag == atomtag('link'): |
406 | entry_link = child.attrib['href'] | 406 | entry_link = child.attrib['href'] |
407 | print(f'=> {entry_link} {entry_date} {entry_title}') | 407 | print(f'=> {entry_link} {entry_date} {entry_title}') |
408 | ``` | 408 | ``` |