From: David Jacquin Date: Tue, 13 Jan 2026 22:28:32 +0000 (-0800) Subject: Initial commit X-Git-Url: http://davidlandia.com/gitweb?a=commitdiff_plain;h=654caa1474f1f5c39e48fbeb7a99a64b699ade0d;p=website.git Initial commit --- 654caa1474f1f5c39e48fbeb7a99a64b699ade0d diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..15a2799 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.0 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..7693295 --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +# Gemfile +source "https://rubygems.org" + +ruby "3.3.8" + +gem "kramdown" +gem "rss" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..7510d5a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,22 @@ +GEM + remote: https://rubygems.org/ + specs: + kramdown (2.5.1) + rexml (>= 3.3.9) + rexml (3.4.4) + rss (0.3.1) + rexml + +PLATFORMS + ruby + x86_64-linux + +DEPENDENCIES + kramdown + rss + +RUBY VERSION + ruby 3.3.8p144 + +BUNDLED WITH + 2.7.2 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..17c9842 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2024 Bradley Taunt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9d7e5a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +build: + rm -rf build && mkdir build + ruby wruby.rb + +clean: + rm -rf build/* + +.PHONY: build clean diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e584ab --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# wruby + +* Minimal blog and static site generator built with Ruby +* Licensed under [MIT](https://choosealicense.com/licenses/mit/) +* The "w" is silent... + +## Setup + +1. `gem install bundler` +2. `bundle install` + +## Getting Started + +Make your changes in the main configuration file `_config.yml` file (site URL, your name, +etc.). + +* Blog posts go under the `posts` directory as markdown files +* Posts need to be structured with an `h1` on the first line, a space on the second, and the date on the third line (ie. 2024-07-20) +* Pages go under the `pages` directory as markdown files +* Media (images, videos etc) go in the root `public` directory +* Main styling is found in `public/style.css` (feel free to get creative!) + +## Defaults + +* The homepage only displays the first `5` posts. You can configure this in `_config.yml` under `post_count`. +* The full blog post index will be generated at `yoursite.com/posts` +* This means you need to have a `posts.md` file in your `pages` directory (or change `posts_index` the core `_config.yml`) +* Your generated files can be compressed by default by setting the `compress_site` to `true` + +## Running + +1. `wruby` is based off of Ruby 3.3.0 (use `rbenv` or `rvm` to avoid privilege conflicts) +2. Install bundler: `gem install bundler` +3. Install gems: `bundle install` +4. Run `make build` in the root directory +5. Upload `build` folder to your server +6. Share your blog or site! \ No newline at end of file diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..dbf5ad6 --- /dev/null +++ b/_config.yml @@ -0,0 +1,26 @@ +# Core site settings +site_url: 'https://davidlandia.com' +site_name: 'Davidlandia' +author_name: 'David Jacquin' + +# Main directories +directories: + posts: 'posts' + pages: 'pages' + public: 'public' + output: 'build' + posts_output: 'build/posts' + pages_output: 'build/' + +# File, index, RSS naming +files: + header: '_includes/header.html' + footer: '_includes/footer.html' + root_index: 'index.md' + posts_index: 'pages/posts.md' + rss: 'build/index.rss' + +# Extras +misc: + post_count: 5 + compress_site: false diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 0000000..52ea2c3 --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,17 @@ + + + diff --git a/_includes/header.html b/_includes/header.html new file mode 100644 index 0000000..d2291a1 --- /dev/null +++ b/_includes/header.html @@ -0,0 +1,22 @@ + + + + + + + + {{TITLE}} + + + + + +
+ +
+
+ diff --git a/index.md b/index.md new file mode 100644 index 0000000..b16fb98 --- /dev/null +++ b/index.md @@ -0,0 +1,14 @@ +# Davidlandia + +This is my website built with [Wruby](https://wruby.btxx.org/) (the ‘W’ is silent). + +## Features of 'Wruby' + +* Fast, OS-agnostic site generator +* Auto-generated, valid [RSS feed](/index.rss) +* Custom `header.html` and `footer.html` templates +* Not much else (this is a *good* thing!) + +## Latest Posts + +[comment]: # (Your latest posts will be added here on build) diff --git a/pages/about.md b/pages/about.md new file mode 100644 index 0000000..e05bb04 --- /dev/null +++ b/pages/about.md @@ -0,0 +1,3 @@ +# About + +Hello! My name is David and this is ***MY*** blog! I've never had a blog before, which is both exiting and provides many problems. Chief among them is what to do with it. Should it have cool features? If so what? What sort of stuff should I write about? How truthful should I be? It will likely be a while before I answer any of these questions, if I answer them at all. I'm usually a private person so I might never end up posting anything at all. But I would be remiss not to mention that I quite like the idea of writing a blog and of figuring out the infrastructure to sustain it. diff --git a/pages/posts.md b/pages/posts.md new file mode 100644 index 0000000..afdca85 --- /dev/null +++ b/pages/posts.md @@ -0,0 +1 @@ +# All Posts diff --git a/posts/my-first-post.md b/posts/my-first-post.md new file mode 100644 index 0000000..8c7fc9e --- /dev/null +++ b/posts/my-first-post.md @@ -0,0 +1,5 @@ +# Baby's First Post + +2026-01-09 + +This is the first post on this blog! What will be here in the future I cannot say but I hope it will be more good than bad. diff --git a/public/images/cat.jpg b/public/images/cat.jpg new file mode 100644 index 0000000..29b054d Binary files /dev/null and b/public/images/cat.jpg differ diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..181aeca --- /dev/null +++ b/public/style.css @@ -0,0 +1,172 @@ +@import url("syntax.css"); + +*{box-sizing:border-box;} + +body { + background: #f2f2f2; + font-family: Verdana, sans-serif; + line-height: 1.33; + margin: 0 auto; + max-width: 680px; + padding: 0 10px; + width: 100%; +} + +header nav ul { + list-style: none; + margin: 10px 0 0 0; + padding: 0; +} +header nav ul li { + display: inline-block; + margin: 0 10px 10px 0; +} +header nav a { + background: white; + border: 1px solid black; + cursor: pointer; + display: block; + padding: 6px; +} + +main { + background: white; + border: 1px solid; + margin: 0; + padding: 0 15px; +} +main p { + text-align: justify; +} + +h1 { + border-bottom: 1px solid; + line-height: 1.25; + margin: 15px 0 0 0; +} + +ul.posts { + list-style: none; + padding-left: 0; +} +ul.posts li a { + display: block; + margin-bottom: 15px; +} + +h2{ + border-bottom: 1px solid lightgrey; + font-size: 18px; + margin: 2rem 0 0; +} + +h3 { + font-size: 16px; +} + +dd { + margin-bottom: 10px; +} +dt:not(:has(a)) { + font-weight: 600; +} + +img{height:auto;max-width:100%;} + +blockquote { + color: brown; + font-style: italic; +} + +figure { margin: 2.5rem auto; } +figure img { display: block; margin: 0 auto 10px; } +figcaption { opacity: 0.7; text-align: center; } + +pre, p code, li code { font-size: 14px; } + +pre { + background: #f2f2f2; + padding: 6px; + overflow: auto; +} +pre:has(code.language-diagram) { + background: none; +} + +table { + border-collapse: collapse; + margin: 2rem 0; + text-align: left; + width: 100%; +} +table caption { + background: #f2f2f2; + padding: 4px; +} +table tr { + border-bottom: 1px solid; +} +table td, table th { + padding: 4px; +} + +footer { + padding: 0 10px; + margin: 1rem 0 2rem; +} + +.footnotes { + font-size: 90%; + margin-top: 2rem; +} + +.footer-nav h3 { + margin-bottom: 0; +} +.footer-nav ul { + list-style: none; + margin-top: 0; + padding: 0; +} +.footer-nav ul li { + display: inline-block; + margin-right: 8px; +} + +.w-100 { + max-width: 100px; +} + +@media(max-width: 620px) { + body { + padding: 10px; + } + header nav ul { + margin: 0; + } + .footer-nav { + display: block; + } +} + +@media(prefers-color-scheme: dark) { + body { + background-color: black; + } + header nav a { + background: black; + border-color: white; + } + main { + background: #1d1d1d; + } + pre { + background: black; + } + blockquote { + color: lightgoldenrodyellow; + } + table caption { + background: black; + } +} diff --git a/public/syntax.css b/public/syntax.css new file mode 100644 index 0000000..a8f6ab6 --- /dev/null +++ b/public/syntax.css @@ -0,0 +1,163 @@ +.highlight table td { padding: 5px; } +.highlight table pre { margin: 0; } +.highlight { + color: #FFFFFF; + background-color: #231529; +} +.highlight .c, .highlight .ch, .highlight .cd, .highlight .cm, .highlight .cpf, .highlight .c1, .highlight .cs { + color: #6D6E70; + font-style: italic; +} +.highlight .cp { + color: #41ff5b; + font-weight: bold; +} +.highlight .err { + color: #FFFFFF; + background-color: #CC0000; +} +.highlight .gr { + color: #FFFFFF; + background-color: #CC0000; +} +.highlight .k, .highlight .kd, .highlight .kv { + color: #FFF02A; + font-weight: bold; +} +.highlight .o, .highlight .ow { + color: #41ff5b; +} +.highlight .p, .highlight .pi { + color: #41ff5b; +} +.highlight .gd { + color: #CC0000; +} +.highlight .gi { + color: #3FB34F; +} +.highlight .ge { + font-style: italic; +} +.highlight .gs { + font-weight: bold; +} +.highlight .gt { + color: #FFFFFF; + background-color: #766DAF; +} +.highlight .gl { + color: #FFFFFF; + background-color: #766DAF; +} +.highlight .kc { + color: #9f93e6; + font-weight: bold; +} +.highlight .kn { + color: #FFFFFF; + font-weight: bold; +} +.highlight .kp { + color: #FFFFFF; + font-weight: bold; +} +.highlight .kr { + color: #FFFFFF; + font-weight: bold; +} +.highlight .gh { + color: #FFFFFF; + font-weight: bold; +} +.highlight .gu { + color: #FFFFFF; + font-weight: bold; +} +.highlight .kt { + color: #FAAF4C; + font-weight: bold; +} +.highlight .no { + color: #FAAF4C; + font-weight: bold; +} +.highlight .nc { + color: #FAAF4C; + font-weight: bold; +} +.highlight .nd { + color: #FAAF4C; + font-weight: bold; +} +.highlight .nn { + color: #FAAF4C; + font-weight: bold; +} +.highlight .bp { + color: #FAAF4C; + font-weight: bold; +} +.highlight .ne { + color: #FAAF4C; + font-weight: bold; +} +.highlight .nl { + color: #9f93e6; + font-weight: bold; +} +.highlight .nt { + color: #9f93e6; + font-weight: bold; +} +.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo, .highlight .mx { + color: #9f93e6; + font-weight: bold; +} +.highlight .ld { + color: #9f93e6; + font-weight: bold; +} +.highlight .ss { + color: #9f93e6; + font-weight: bold; +} +.highlight .s, .highlight .sa, .highlight .sb, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .sh, .highlight .sx, .highlight .sr, .highlight .s1 { + color: #fff0a6; + font-weight: bold; +} +.highlight .se { + color: #FAAF4C; + font-weight: bold; +} +.highlight .sc { + color: #FAAF4C; + font-weight: bold; +} +.highlight .si { + color: #FAAF4C; + font-weight: bold; +} +.highlight .nb { + font-weight: bold; +} +.highlight .ni { + color: #999999; + font-weight: bold; +} +.highlight .w { + color: #BBBBBB; +} +.highlight .nf, .highlight .fm { + color: #41ff5b; +} +.highlight .py { + color: #41ff5b; +} +.highlight .na { + color: #41ff5b; +} +.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm { + color: #41ff5b; + font-weight: bold; +} diff --git a/recipes/test.md b/recipes/test.md new file mode 100644 index 0000000..855fbaf --- /dev/null +++ b/recipes/test.md @@ -0,0 +1,5 @@ +# Test + +2026-01-08 + +CONTENT THUS IS CONTENT diff --git a/wruby.rb b/wruby.rb new file mode 100644 index 0000000..35b907e --- /dev/null +++ b/wruby.rb @@ -0,0 +1,140 @@ +require 'kramdown' +require 'fileutils' +require 'date' +require 'rss' +require 'find' +require 'yaml' + +# Load configuration +config = YAML.load_file('_config.yml') + +site_url = config['site_url'] +site_name = config['site_name'] +author_name = config['author_name'] + +posts_dir = config['directories']['posts'] +pages_dir = config['directories']['pages'] +public_dir = config['directories']['public'] +output_dir = config['directories']['output'] +posts_output_dir = config['directories']['posts_output'] +pages_output_dir = config['directories']['pages_output'] + +header_file = config['files']['header'] +footer_file = config['files']['footer'] +root_index_file = config['files']['root_index'] +posts_index_file = config['files']['posts_index'] +rss_file = config['files']['rss'] + +post_count = config['misc']['post_count'] +compress_site = config['misc']['compress_site'] + +# Make sure output directories exist +[output_dir, posts_output_dir, pages_output_dir].each { |dir| FileUtils.mkdir_p(dir) } + +# Read the footer content +footer_content = File.read(footer_file) + +# Replace the title meta tag in the header.html +def replace_title_placeholder(header_content, title) + header_content.gsub('{{TITLE}}', "#{title}") +end + +# Grab the title from each markdown file +def extract_title_from_md(lines) + first_line = lines.first + first_line&.start_with?('# ') ? first_line[2..-1].strip : 'Blog Index' +end + +# Convert markdown files +def process_markdown_files(input_directory, output_directory, header_content, footer_content) + items = Dir.glob("#{input_directory}/**/*.md").map do |path| + md_content = File.read(path) + lines = md_content.lines + + title = extract_title_from_md(lines) + date = Date.parse(lines[2]&.strip || '') rescue Date.today + html_content = Kramdown::Document.new(md_content).to_html + + relative_path = path.sub("#{input_directory}/", '').sub('.md', '') + item_dir = File.join(output_directory, relative_path) + output_file = File.join(item_dir, 'index.html') + FileUtils.mkdir_p(item_dir) + + header = replace_title_placeholder(header_content, title) + File.write(output_file, header + html_content + footer_content) + + { title: title, date: date, link: "#{relative_path}/", content: html_content } + end +end + +# Create the root index file +def generate_index(posts, header_content, footer_content, root_index_file, post_count, output_dir, posts_dir) + root_index_content = File.read(root_index_file) + root_title = extract_title_from_md(root_index_content.lines) + root_html = Kramdown::Document.new(root_index_content).to_html + + header = replace_title_placeholder(header_content, root_title) + + index_content = header + root_html + "\n" + footer_content + + File.write("#{output_dir}/index.html", index_content) +end + +# Create the full posts list page +def generate_full_posts_list(posts, header_content, footer_content, posts_index_file, output_dir, posts_dir) + posts_index_content = File.read(posts_index_file) + posts_title = extract_title_from_md(posts_index_content.lines) + posts_html = Kramdown::Document.new(posts_index_content).to_html + + header = replace_title_placeholder(header_content, posts_title) + + list_content = header + posts_html + "\n" + footer_content + + File.write("#{output_dir}/posts/index.html", list_content) +end + +# Generate the RSS 2.0 feed +def generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir) + rss = RSS::Maker.make("2.0") do |maker| + maker.channel.author = author_name + maker.channel.updated = Time.now.to_s + maker.channel.title = "#{site_name} RSS Feed" + maker.channel.description = "The official RSS Feed for #{site_url}" + maker.channel.link = site_url + + posts.each do |post| + date = Date.parse(post[:date].to_s).to_time + 12*60*60 # Force time to midday + item_link = "#{site_url}/#{posts_dir}/#{post[:link]}" + item_title = post[:title] + item_content = post[:content] + + maker.items.new_item do |item| + item.link = item_link + item.title = item_title + item.updated = date.to_s + item.pubDate = date.rfc822 + item.description = item_content + end + end + end + + File.write(rss_file, rss) +end + +# Process header, posts, pages, etc. +header_content = File.read(header_file) + +posts = process_markdown_files(posts_dir, posts_output_dir, header_content, footer_content).sort_by { |post| -post[:date].to_time.to_i } +pages = process_markdown_files(pages_dir, pages_output_dir, header_content, footer_content) + +generate_index(posts, header_content, footer_content, root_index_file, post_count, output_dir, posts_dir) +generate_full_posts_list(posts, header_content, footer_content, posts_index_file, output_dir, posts_dir) +FileUtils.cp_r(public_dir, output_dir) +generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir) +system("find #{output_dir} -type f \\( -name '*.html' -o -name '*.css' \\) -exec gzip -k -f {} \\;") if compress_site == true + +puts "Blog built successfully in '#{output_dir}' folder. Have a great day!"