Browse Source

Example site and first generator

master
Exa Stencil 4 months ago
parent
commit
b27e42b2f1
7 changed files with 95 additions and 1 deletions
  1. +2
    -0
      .gitignore
  2. +1
    -1
      README.gmi
  3. +27
    -0
      example/index.gmi
  4. +6
    -0
      example/posts/footer.gmi
  5. +8
    -0
      example/posts/header.gmi
  6. +3
    -0
      example/posts/hello-world.gmi
  7. +48
    -0
      huge.rb

+ 2
- 0
.gitignore View File

@ -0,0 +1,2 @@
/public_gemini
/public_html

+ 1
- 1
README.gmi View File

@ -8,7 +8,7 @@ This project has a few goals:
* Manage content in a lowest common denominator format (text/gemini)
* Generate markup idempotently for different formats
* Have no dependencies (OK, I want to learn bash)
* Reduce the tedium of posting content with helpers
## Usage


+ 27
- 0
example/index.gmi View File

@ -0,0 +1,27 @@
# Example Site
This is a sample site to test the generation of gemini and web content from a single source. It is meant to reduce the overhead of testing the generator by giving it content to process.
* It should produce this file with the correct markup.
* It should recursively process folders as well.
* The `posts` folder will have some extra processing.
## Markdown
Very simple markdown can be included in content. This will be eventually be parsed in formats that support it, i.e. HTML, but may be stripped from gemtext. I am considering leaving some Markdown there for clients who decide to render it. I'm not decided yet.
## Headers and Footers
If any folder has a `header.gmi` or a `footer.gmi` in it, it won't be rendered. Instead it will be prepended or appended respectively to every file in that folder.
## Templating
Files ending in `.gmi.erb` will be processed with Embedded Ruby.
## Frontmatter
There will need to be some way to specify attributes for files to be used in the templates. This is important for publish dates and tags on posts, which will vary, but needs to appear in the headers and footers.
### Reference
=> gemini://gemini.circumlunar.space/docs/ Gemini Documentation

+ 6
- 0
example/posts/footer.gmi View File

@ -0,0 +1,6 @@
- - - - - - - - - -
Author: Exa Stencil
=> https://creativecommons.org/licenses/by-sa/4.0/ © CC-BY-SA 4.0

+ 8
- 0
example/posts/header.gmi View File

@ -0,0 +1,8 @@
```
▄▄▄ .▐▄• ▄ ▄▄▄· • ▌ ▄ ·. ▄▄▄·▄▄▌ ▄▄▄ . .▄▄ · ▪ ▄▄▄▄▄▄▄▄ .
▀▄.▀· █▌█▌▪▐█ ▀█ ·██ ▐███▪▐█ ▄███• ▀▄.▀· ▐█ ▀. ██ •██ ▀▄.▀·
▐▀▀▪▄ ·██· ▄█▀▀█ ▐█ ▌▐▌▐█· ██▀·██ ▪ ▐▀▀▪▄ ▄▀▀▀█▄▐█· ▐█.▪▐▀▀▪▄
▐█▄▄▌▪▐█·█▌▐█▪ ▐▌██ ██▌▐█▌▐█▪·•▐█▌ ▄▐█▄▄▌ ▐█▄▪▐█▐█▌ ▐█▌·▐█▄▄▌
▀▀▀ •▀▀ ▀▀ ▀ ▀ ▀▀ █▪▀▀▀.▀ .▀▀▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀
```

+ 3
- 0
example/posts/hello-world.gmi View File

@ -0,0 +1,3 @@
# Hello World
This is just a simple post.

+ 48
- 0
huge.rb View File

@ -0,0 +1,48 @@
#!/bin/ruby
require 'fileutils'
def generate_gemini(path)
target_path = "../public_gemini/#{path}"
target_folder = target_path.split('/')[0...-1].join('/')
target = ""
puts target_path
# Optional header
folder = path.split('/')[0...-1]
header = (folder + %w[header.gmi]).join '/'
if File.exists? header
File.open header do |file|
target << file.read
end
end
File.open path do |file|
target << file.read
end
# Optional footer
footer = (folder + %w[footer.gmi]).join '/'
if File.exists? header
File.open footer do |file|
target << file.read
end
end
# Ensure the folder exists
FileUtils.mkdir_p target_folder
# Write the file
File.open target_path, 'w' do |file|
file.write target
end
end
# Find all Gemini content
Dir['**/*.gmi'].each do |path|
next if File.basename(path) == 'header.gmi'
next if File.basename(path) == 'footer.gmi'
puts "Processing #{path}..."
generate_gemini path
end

Loading…
Cancel
Save