Skip to content

jannapps/dollhouse-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dollhouse Blog

A simple, fast, and maintainable blog system built with Ruby on Rails that uses markdown files for content storage. Perfect for developers who want to write in markdown while having the power of Rails for dynamic features.

✨ Features

πŸ“ Content Management

  • Markdown-based content - Write content in simple, readable markdown files
  • Dynamic markdown content - Use ERB syntax within .md.erb files for dynamic content
  • Internal linking - Seamless navigation between markdown pages
  • No database required for content - All content stored as files in the filesystem

πŸ”§ Dynamic Content Capabilities

  • Real-time data - Current date, time, Rails version, environment info
  • ERB integration - Full access to Rails helpers, variables, and environment
  • Conditional content - Show different content based on environment or conditions
  • Dynamic loops - Generate lists and repeated content programmatically
  • Rails helpers - Access to all Rails view helpers within markdown

🎨 Design & User Experience

  • Modern web design - Responsive design with beautiful typography
  • Clean URLs - Simple routing like /page-name for markdown files
  • Fast loading - File-based content with efficient caching
  • Mobile-friendly - Responsive design that works on all devices

πŸ”’ Security & Quality

  • Security-first design - Whitelist-based file access prevents path traversal attacks
  • Zero security warnings - Passes Brakeman security scanning
  • Input validation - Strict validation of all user inputs
  • CI/CD pipeline - Automated security scanning, linting, and testing

⚑ Performance & Development

  • Fast development - Hot reloading in development mode
  • Reproducible environment - NixOS shell.nix for consistent development setup
  • Comprehensive testing - Full CI pipeline with security, style, and unit tests
  • Git workflow - Feature branches with squash merges for clean history

πŸ›  Technical Stack

  • Backend: Ruby on Rails 8.1.1
  • Ruby Version: 3.2.9
  • Markdown Processing: Redcarpet gem
  • Template Engine: ERB for dynamic content
  • Development Environment: NixOS with shell.nix
  • Web Server: Puma (port 9955)
  • Database: SQLite (for Rails features, not content)

πŸš€ Getting Started

Prerequisites

  • NixOS or Nix package manager
  • Git

Setup

  1. Clone the repository

    git clone https://github.com/jannapps/dollhouse-blog.git
    cd dollhouse-blog
  2. Enter development environment

    nix-shell
  3. Install dependencies

    bundle install
  4. Start the server

    bin/rails server --port=9955
  5. Visit your blog Open http://localhost:9955 in your browser

πŸ“– Creating Content

Static Markdown Pages

Create .md files in the posts/ directory:

# My New Page

This is a simple markdown page with **bold text** and [links](/).

## Features
- Lists work great
- So do code blocks

Dynamic Markdown Pages

Create .md.erb files for dynamic content:

# Welcome Page

Today is: <%= Date.current.strftime("%A, %B %d, %Y") %>

<% if Rails.env.development? %>
## Development Mode
Debug features are available!
<% end %>

## Random Numbers
<% 3.times do |i| %>
<%= i + 1 %>. Lucky number: **<%= rand(1..100) %>**
<% end %>

URL Structure

Files are automatically accessible via clean URLs:

  • posts/about.md β†’ /about
  • posts/contact.md.erb β†’ /contact
  • posts/blog-post.md β†’ /blog-post

πŸ”§ Development Workflow

Local CI Testing

Always run the complete CI suite before pushing:

# Complete CI pipeline
nix-shell --run "bin/brakeman" && \
nix-shell --run "bin/bundler-audit check --update" && \
nix-shell --run "bin/rubocop -a" && \
nix-shell --run "bin/rails test"

Git Workflow

  1. Create feature branches for all changes
  2. Run CI locally before committing
  3. Use squash merges to main branch
  4. Keep commit history clean and descriptive

Security Guidelines

  • Never use user parameters directly in file operations
  • Use whitelist-based file access with pre-approved mappings
  • Implement strict input validation (alphanumeric, dash, underscore only)
  • Always validate file paths are within expected directories

πŸ“ Project Structure

dollhouse-blog/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ home_controller.rb      # Homepage controller
β”‚   β”‚   └── pages_controller.rb     # Dynamic markdown page handler
β”‚   └── views/
β”‚       β”œβ”€β”€ home/
β”‚       β”‚   └── index.html.erb      # Homepage template
β”‚       └── pages/
β”‚           └── show.html.erb       # Markdown page template
β”œβ”€β”€ posts/                          # Markdown content directory
β”‚   β”œβ”€β”€ home.md                     # Homepage content
β”‚   β”œβ”€β”€ test.md                     # Example static page
β”‚   └── dynamic-example.md.erb      # Example dynamic page
β”œβ”€β”€ config/
β”‚   └── routes.rb                   # Dynamic routing configuration
β”œβ”€β”€ shell.nix                       # NixOS development environment
β”œβ”€β”€ CLAUDE.md                       # Development notes and CI process
└── README.md                       # This file

🎨 Layout System

The blog supports a flexible layout system using YAML frontmatter to specify different page layouts and widgets.

Available Layouts

  • βœ… single-column - Clean single column layout for focused content
  • βœ… two-column - Main content with sidebar for widgets

Planned Layouts

  • β­• three-column - Main content with dual sidebars (nav + widgets)
  • β­• card-grid - Grid layout for post listings, galleries, or portfolios
  • β­• masonry - Pinterest-style staggered grid for mixed content sizes
  • β­• full-width - Edge-to-edge content without container constraints
  • β­• narrow - Extra-narrow layout for long-form reading
  • β­• split-screen - Half content, half media layout
  • β­• hero-banner - Large header section with content below
  • β­• timeline - Chronological content with date markers
  • β­• comparison - Side-by-side content blocks
  • β­• landing-page - Multi-section layout with different backgrounds
  • β­• mobile-first-stack - Responsive stacking layout
  • β­• sidebar-overlay - Sidebar becomes slide-out drawer on mobile

Using Layouts

Add YAML frontmatter to your markdown files:

---
layout: two-column
title: My Page Title
sidebar: recent-posts
---

# My Content

This content will be displayed in a two-column layout with a sidebar widget.

πŸ” Example Pages

  • Homepage: / - Static markdown content with feature overview
  • Test Page: /test - Simple static markdown example
  • Dynamic Example: /dynamic-example - Comprehensive ERB features demo
  • Layout Example: /layout-example - Two-column layout with sidebar widget

πŸ§ͺ CI/CD Pipeline

The project includes comprehensive automated testing:

  • Brakeman: Security vulnerability scanning
  • bundler-audit: Dependency security checking
  • RuboCop: Code style and linting
  • Rails Tests: Application testing

All checks must pass before merging to main branch.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Run CI locally to ensure all checks pass
  4. Commit your changes with descriptive messages
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request with squash merge

πŸ“„ License

This project is open source and available under the MIT License.

πŸ”— Links

Using Docker or Podman

Note that this will build a production server.

  1. Generate a secret key

    ruby -e "require 'securerandom' puts \"SECRET_KEY_BASE=#{SecureRandom.hex(64)}\"" > .env
  2. Build the container

    docker build -t dollhouse_blog . 
  3. Run the container

    docker run -it -p 80:80 dollhouse_blog

    -it is required as otherwise you won't be able to use CTRL-C to exit the server.


Built with ❀️ using Ruby on Rails and markdown

About

A tiny blog webapp that renders markdown files. Also, an experiment in vibecoding.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors