HUB
Sign inSign up
radvent logo

haru/radvent

By haru

•Updated 19 days ago

radvent container

Image
0

5.1K

haru/radvent repository overview

⁠radvent

MIT License build Maintainability codecov Ask DeepWiki

Japansese/日本語⁠

An Advent Calendar-style blog web application. Write articles in Markdown and they are automatically published on their scheduled date.

This is a fork of nanonanomachine/radvent⁠ with the following additions and enhancements:

  • User authentication (Devise)
  • Per-user event management (multiple boards with public / protected / private visibility and membership control)
  • Multiple Advent Calendar events
  • Likes and comments
  • File attachments (CarrierWave)

The Markdown editor uses EasyMDE⁠, the Markdown parser uses marked⁠, and syntax highlighting uses highlight.js⁠.


⁠Table of Contents


⁠Tech Stack

CategoryTechnology
LanguageRuby >= 3.3
FrameworkRuby on Rails 8.1
Frontendesbuild / PostCSS (Bootstrap 5 / mdb-ui-kit) / @hotwired/stimulus
Markdown EditorEasyMDE (easy-markdown-editor)
TemplatesHAML
AuthenticationDevise
DB (development)SQLite3
DB (production)SQLite3 / MySQL 5.7+ / PostgreSQL
TestingRSpec / FactoryBot / SimpleCov
CIGitHub Actions

⁠Development Setup

⁠Prerequisites
  • Ruby >= 3.3
  • Node.js / Yarn
  • SQLite3 (default)
⁠Steps
# 1. Install dependencies
bundle install
yarn install

# 2. Generate default config files
#    Creates config/database.yml / config/secrets.yml / config/initializers/devise.rb
bundle exec rake radvent:generate_default_settings

# 3. Create database, run migrations, and seed data
bundle exec rake db:create db:migrate db:seed
⁠Default Admin User

After seeding (db:seed), the following admin account is available. Please change the password after your first login.

FieldValue
Email[email protected]⁠
Passwordadminadmin

⁠Starting the App

bundle exec rails s

Access the app at http://localhost:3000.

The app supports Japanese and English locales, and automatically switches based on your browser's language settings.


⁠Testing

The test framework used is RSpec.

⁠Run All Tests
bundle exec rspec spec
⁠Run Specific Tests
# Model specs only
bundle exec rspec spec/models

# Controller specs only
bundle exec rspec spec/controllers

# Single file
bundle exec rspec spec/models/user_spec.rb

# Specific line in a file
bundle exec rspec spec/models/user_spec.rb:42
⁠Coverage Report

After running tests, a coverage report is generated at coverage/index.html (SimpleCov / LCOV format).

bundle exec rspec spec
open coverage/index.html
⁠Test Structure
DirectoryContents
spec/models/Model specs
spec/controllers/Controller specs
spec/helpers/Helper specs
spec/uploaders/Uploader specs
spec/views/View specs
spec/factories/FactoryBot factory definitions

⁠Production Deployment

# 1. Generate config files
bundle exec rake radvent:generate_default_settings

# 2. Precompile assets
bundle exec rake assets:precompile RAILS_ENV=production

# 3. Run database migrations
bundle exec rake db:migrate RAILS_ENV=production

# 4. Set secret key and start
export SECRET_KEY_BASE=$(bundle exec rails secret)
bundle exec rails s -e production

Note: Uploaded images are stored under storage/protected_uploads in the application directory (override with RADVENT_PROTECTED_UPLOAD_DIR) and served only to users who may read the article. Back up and persist this directory together with public/uploads.


⁠Docker

⁠Running with docker run
docker run -d -p 3000:3000 -v /host/data/directory:/var/radvent_data haru/radvent

Note: Uploaded images are stored under /var/radvent_data/protected_uploads (set with RADVENT_PROTECTED_UPLOAD_DIR) and served only to users who may view the article. Mount /var/radvent_data as a volume so they persist. Images uploaded before protected storage was introduced remain in /var/radvent_data/uploads and stay publicly accessible.

⁠docker-compose Example (MySQL)
services:
  radvent:
    image: haru/radvent:latest
    ports:
      - "3000:3000"
    restart: unless-stopped
    volumes:
      - "./docker/data:/var/radvent_data"
      - "./log:/usr/local/radvent/log"
    links:
      - mysql
    environment:
      DB: mysql
      DB_USERNAME: root
      DB_PASSWORD: example
      DB_HOST: mysql
      DB_CREATE_ON_START: "true"
  mysql:
    image: mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - "./docker/mysql:/var/lib/mysql"
⁠docker-compose Example (PostgreSQL)
services:
  radvent:
    image: haru/radvent:latest
    ports:
      - "3000:3000"
    volumes:
      - "./docker/data:/var/radvent_data"
      - "./log:/usr/local/radvent/log"
    restart: unless-stopped
    environment:
      DB: postgres
      DB_USERNAME: postgres
      DB_PASSWORD: example
      DB_HOST: postgres
      DB_CREATE_ON_START: "true"
  postgres:
    image: postgres
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: example
    volumes:
      - "./docker/postgres:/var/lib/postgresql"
⁠Environment Variables
KeyValueDefault
DBsqlite3 / mysql / postgressqlite3
DB_NAMEDatabase nameradvent
DB_USERNAMEDB username—
DB_PASSWORDDB password—
DB_HOSTDB hostname—
DB_PORTDB port numberMySQL: 3306 / PostgreSQL: 5432
DB_CREATE_ON_STARTSet to true to run db:create on startupfalse
RADVENT_TITLESite name displayed in the headerAdvent Calendar
RADVENT_PROTECTED_UPLOAD_DIRDirectory for uploaded images served with access control (relative paths are resolved against the app root)storage/protected_uploads (Docker: /var/radvent_data/protected_uploads)
RADVENT_URLSite URL used in links inside mails, e.g. https://advent.example.com. Required for password reset mails—
RADVENT_MAIL_FROMSender address of password reset mails (most SMTP servers reject the default)[email protected]
SMTP_ADDRESSSMTP server host name. Required for password reset mails—
SMTP_PORTSMTP port587
SMTP_USERNAMESMTP user name—
SMTP_PASSWORDSMTP password—
SMTP_AUTHENTICATIONplain / login / cram_md5 / xoauth2 (anything else fails the boot)—
SMTP_DOMAINHELO domain—
SMTP_ENABLE_STARTTLS_AUTOSet to false (any case) to disable STARTTLS; any other value keeps it enabledtrue

Password reset mails: RADVENT_URL and SMTP_ADDRESS must be set for password reset mails to be delivered. To avoid revealing which addresses are registered, the app always answers a reset request with the same message; if the mail cannot be sent, the failure is only written to the log (Password reset mail was not delivered, with the exception class only). The app warns at boot when RADVENT_URL, SMTP_ADDRESS or RADVENT_MAIL_FROM is unset, and refuses to boot when RADVENT_URL, SMTP_PORT or SMTP_AUTHENTICATION is set to an unusable value.

Rate limits and account lockout: Sign-in is limited to 10 attempts per minute per client IP address, sign-up and password reset requests to 5 per hour per client IP address, and reset mail to one per address every 5 minutes. Ten consecutive failed sign-ins lock the account for 15 minutes (a password reset unlocks it). Counters are shared by all processes through Solid Cache in the primary database (run db:migrate; the Docker image does this on start). If you run behind a reverse proxy or CDN, add its address to config.action_dispatch.trusted_proxies, otherwise every client counts as one address. Log lines to monitor: Account locked: user_id=, Rate limit exceeded: and SolidCacheStore: increment failed (production only: the counter store failed and requests were let through).


⁠Architecture

⁠Entity Relationship Diagram
Board ──< Event ──< AdventCalendarItem >── User
  │                       │
  └──< BoardMembership    └── Item ──< Comment
         >── User                └──< Like >── User
ModelDescription
UserDevise-authenticated user. Has admin flag
BoardContainer for events. Two types: top (system-wide) and user (user-created), with public / protected / private visibility
BoardMembershipJoin table between Board and User (membership management)
EventAdvent Calendar event. Belongs to a Board
AdventCalendarItemCalendar date slot (date is Integer 1–31)
ItemMarkdown article. Has a one-to-one relationship with AdventCalendarItem
LikeLike on an article
CommentComment on an article (stores user_name as a string only)
AttachmentFile attachment via CarrierWave

⁠License

MIT⁠


⁠Credits

Tag summary

Content type

Image

Digest

sha256:ad277b1c7…

Size

848.2 MB

Last updated

19 days ago

docker pull haru/radvent