Compare commits
	
		
			No commits in common. "e3642177343e1404550f6cc2e57bfdaa45fd89c2" and "d492b67dc11bf174eec25e0e4ade78b9af521ef2" have entirely different histories.
		
	
	
		
			e364217734
			...
			d492b67dc1
		
	
		
					 5 changed files with 28 additions and 67 deletions
				
			
		
							
								
								
									
										40
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										40
									
								
								README.md
									
										
									
									
									
								
							|  | @ -3,19 +3,8 @@ | ||||||
| This tool was made so I could write my content only in `gmi` and publish both a | This tool was made so I could write my content only in `gmi` and publish both a | ||||||
| gemini capsule and a website. | gemini capsule and a website. | ||||||
| 
 | 
 | ||||||
| For now, this is very rudimentary and things are bound to change... and break from | For now, this is very rudimentary and things are bound to change, especially the way | ||||||
| version to version. | I structure the directory where my content lives. | ||||||
| 
 |  | ||||||
| ## Features |  | ||||||
| 
 |  | ||||||
| - generates HTML from gemtext |  | ||||||
| - can synchronise your files with your server using rsync |  | ||||||
| 
 |  | ||||||
| ## Notes on usage |  | ||||||
| 
 |  | ||||||
| Good practice for gemini dictates that we don't use multiple `h1` titles in one page |  | ||||||
| and for that reason, the last (and therefore the first) `h1` title encountered will |  | ||||||
| be used as the title of the HTML page. |  | ||||||
| 
 | 
 | ||||||
| ## TODO | ## TODO | ||||||
| 
 | 
 | ||||||
|  | @ -34,14 +23,12 @@ be used as the title of the HTML page. | ||||||
| - [ ] move config file to `~/.config` with placeholder values | - [ ] move config file to `~/.config` with placeholder values | ||||||
|     - [X] check for a config file in `~/.config` |     - [X] check for a config file in `~/.config` | ||||||
| - [ ] maybe save the old Bash script somewhere for posterity ? | - [ ] maybe save the old Bash script somewhere for posterity ? | ||||||
| - [ ] reorganise the directory where the content is |  | ||||||
| 
 | 
 | ||||||
| ## My setup | ## My setup | ||||||
| 
 |  | ||||||
| My current folder structure for my capsule+website looks something like this: | My current folder structure for my capsule+website looks something like this: | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| myinternet | my-internet | ||||||
| ├── assets | ├── assets | ||||||
| │  ├── favicon.ico | │  ├── favicon.ico | ||||||
| │  └── style.css | │  └── style.css | ||||||
|  | @ -50,20 +37,9 @@ myinternet | ||||||
| │  │  └── index.gmi | │  │  └── index.gmi | ||||||
| │  ├── index.gmi | │  ├── index.gmi | ||||||
| │  └── projects.gmi | │  └── projects.gmi | ||||||
| ├── gmi-helper | ├── footer.gmi | ||||||
| │  └── footer.gmi | ├── html-output | ||||||
| ├── html-helper | └── html-parts | ||||||
| │  ├── footer-part.html |    ├── footer-part.html | ||||||
| │  └── header-part.html |    └── header-part.html | ||||||
| ├── README.md |  | ||||||
| └── web |  | ||||||
|    ├── favicon.ico |  | ||||||
|    ├── gemlog |  | ||||||
|    │  └── index.html |  | ||||||
|    ├── index.html |  | ||||||
|    ├── projects.html |  | ||||||
|    └── style.css |  | ||||||
| ``` | ``` | ||||||
| 
 |  | ||||||
| This is only meant as a reference if my code isn't clear enough and had too much |  | ||||||
| implicits |  | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								config.json
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								config.json
									
										
									
									
									
								
							|  | @ -1,11 +1,11 @@ | ||||||
| { | { | ||||||
| 	"dir_assets" 		: "path/to/assets", | 	"workdir" 		: "where/your/sources/live", | ||||||
| 	"dir_gmi_content"	: "path/to/content", | 	"dir_assets" 	: "assets", | ||||||
| 	"dir_gmi_helper"	: "path/to/gmi-helper", | 	"dir_source" 	: "content", | ||||||
| 	"dir_html_helper" 	: "path/to/html-helper", | 	"dir_helper" 	: "html-parts", | ||||||
| 	"dir_html_out" 		: "path/to/web", | 	"dir_o_html" 	: "html-output", | ||||||
| 	"rem_gmi" 			: "remote_server:path/to/gmi", | 	"rem_gmi" 		: "your/remote/gemini/path", | ||||||
| 	"rem_html" 			: "remote_server:path/to/gmi", | 	"rem_html" 		: "your/remote/html/path", | ||||||
| 	"port"				: "1312" | 	"port"			: "1312" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -7,14 +7,13 @@ cfg_file = xdg_path if xdg_path.exists() else "config.json" | ||||||
| with open(cfg_file) as f: | with open(cfg_file) as f: | ||||||
|     config = json.load(f) |     config = json.load(f) | ||||||
| 
 | 
 | ||||||
| DIR_ASSETS      = Path(config["dir_assets"]) | WORKDIR = Path(config["workdir"]) | ||||||
| DIR_SOURCE      = Path(config["dir_gmi_content"]) | DIR_ASSETS  = WORKDIR / config["dir_assets"] | ||||||
| DIR_GMI_HELPER  = Path(config["dir_gmi_helper"]) | DIR_SOURCE  = WORKDIR / config["dir_source"] | ||||||
| DIR_HELPER      = Path(config["dir_html_helper"]) | DIR_HELPER  = WORKDIR / config["dir_helper"] | ||||||
| DIR_O_HTML      = Path(config["dir_html_out"]) | DIR_O_HTML  = WORKDIR / config["dir_o_html"] | ||||||
|  | GMI_FOOTER  = WORKDIR / "footer.gmi" | ||||||
| 
 | 
 | ||||||
| GMI_FOOTER      = DIR_GMI_HELPER / "footer.gmi" | REM_HTML    = config["rem_html"] | ||||||
| 
 | REM_GMI     = config["rem_gmi"] | ||||||
| REM_HTML        = config["rem_html"] | RPORT       = config["port"] | ||||||
| REM_GMI         = config["rem_gmi"] |  | ||||||
| RPORT           = config["port"] |  | ||||||
|  |  | ||||||
|  | @ -156,7 +156,7 @@ def process_inline(line: str): | ||||||
| 
 | 
 | ||||||
| def repl_url(matchobj: re.Match): | def repl_url(matchobj: re.Match): | ||||||
|     url, text = matchobj.groupdict().values() |     url, text = matchobj.groupdict().values() | ||||||
|     if not re.findall(r'(http|gemini)', url): |     if not re.findall(r'=> (http|gemini)', url): | ||||||
|         url = re.sub(r'gmi$', r'html', url) |         url = re.sub(r'gmi$', r'html', url) | ||||||
|     return f'<a href="{url}">=> {text if text else url}</a><br>\n' |     return f'<a href="{url}">=> {text if text else url}</a><br>\n' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,3 @@ | ||||||
| import re |  | ||||||
| from gmirator.generate import ( | from gmirator.generate import ( | ||||||
|     process_file, |     process_file, | ||||||
|     process_list, |     process_list, | ||||||
|  | @ -12,26 +11,13 @@ def test_process_file(): | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
| def test_process_list(): | def test_process_list(): | ||||||
|     test_str = "this is a line outside a list" |  | ||||||
|     assert process_list(test_str, True) == ("</ul>\n\n", False) |  | ||||||
|     assert process_list(test_str, False) == (test_str, False) |  | ||||||
|     test_str = "* this is a list item" |  | ||||||
|     assert process_list(test_str, True) == ("<li>this is a list item</li>", True) |  | ||||||
|     assert process_list(test_str, False) == ("<ul>\n<li>this is a list item</li>", True) |  | ||||||
|     pass |     pass | ||||||
| 
 | 
 | ||||||
| def test_process_inline(): | def test_process_inline(): | ||||||
|     assert process_inline("*Hello* ~~world~~!") == "<em>Hello</em> <s>world</s>!" |     assert process_inline("*Hello* ~~world~~!") == "<em>Hello</em> <s>world</s>!" | ||||||
| 
 | 
 | ||||||
| def test_repl_url_external_gmi_url(): | def test_repl_url(): | ||||||
|     external_url = "=> gemini://domain/gempage.gmi\n" |     pass | ||||||
|     new_url = re.sub(r'^=> (?P<url>[^ ]*) ?(?P<text>.*)\n', repl_url, external_url) |  | ||||||
|     assert new_url == '<a href="gemini://domain/gempage.gmi">=> gemini://domain/gempage.gmi</a><br>\n' |  | ||||||
| 
 |  | ||||||
| def test_repl_url_internal_gmi_url(): |  | ||||||
|     external_url = "=> /gempage.gmi title\n" |  | ||||||
|     new_url = re.sub(r'^=> (?P<url>[^ ]*) ?(?P<text>.*)\n', repl_url, external_url) |  | ||||||
|     assert new_url == '<a href="/gempage.html">=> title</a><br>\n' |  | ||||||
| 
 | 
 | ||||||
| def test_repl_heading(): | def test_repl_heading(): | ||||||
|     pass |     pass | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue