WBlog

repository·master·Indexed 42 days ago

https://github.com/windy/wblog

A mobile-first, open-source blog system built on Ruby on Rails 7.1. It features Markdown support with Rouge syntax highlighting, an independent comment and subscription system, and is optimized for responsive viewing across all devices. The tech stack includes Ruby 3.1.2, PostgreSQL, and Bootstrap 4, with deployment supported via mina, puma, and nginx.

Tokens
1.6K
Snippets
6
Records
10
Agent score
52%

What's inside WBlog

  1. Overview of WBlog features and tech stack

    master

    WBlog is an open-source Ruby on Rails blogging system designed primarily for mobile user experience.

    Key Features

    • Mobile-First: Responsive design supporting all screen sizes, including WeChat scan-to-read and sharing support.
    • Built-in Comment System: A clean and convenient standalone commenting system.
    • Markdown Support: Full Markdown support with syntax highlighting for technical blogs.
    • Independent: Designed to be as self-contained as possible.

    Tech Stack

    • Framework: Ruby on Rails 7.1
    • Language: Ruby 3.1.2
    • Frontend: Bootstrap 4, Slim
    • Database: PostgreSQL
    • Deployment: Mina
  2. Post your first blog article

    master

    Once the development server is running at http://localhost:3000, follow these steps to create content:

    1. Navigate to the admin dashboard at http://localhost:3000/admin.
    2. Log in using the username and password defined in db/seeds.rb.
    3. Use the admin interface to create and publish a new article.

    Features include Markdown support and code highlighting for technical articles.

  3. Deployment overview for WBlog

    master

    WBlog is designed to be deployed using the following stack:

    • Automation Tool: mina
    • Rack Container: puma
    • Reverse Proxy: nginx (recommended)

    For detailed deployment workflows, refer to the WBlog wiki.

  4. Install and run WBlog in development mode

    master

    WBlog is a Ruby on Rails 7.1 blog system designed for mobile-first responsiveness. To run it locally, you must use Linux or macOS.

    Prerequisites

    Ensure your system meets these minimum version requirements:

    • Ruby: >= 3.1.2
    • PostgreSQL: >= 9.x
    • Nginx: >= 1.4
    • Node.js: >= 1.18

    Setup Steps

    1. Clone the repository:

      git clone git@github.com:windy/wblog.git
      cd wblog
    2. Install dependencies: Install Rails dependencies using Bundler, then install Node dependencies using Yarn:

      gem install bundler
      bundle install
      npm install yarn -g
      yarn install
    3. Configure environment: Copy the example configuration files and update them with your local settings:

      cp config/application.yml.example config/application.yml
      cp config/database.yml.example config/database.yml

      Note: Update application.yml and database.yml with your specific credentials before proceeding.

    4. Initialize the database: Run the setup script to prepare the database:

      bin/setup
    5. Start the server: The easiest way to start the full development environment (including asset watchers) is:

      bin/dev

      Alternatively, you can run components in separate terminals:

      • Rails server: bin/rails s
      • JS compilation (watch mode): bin/yarn build --watch
      • CSS compilation (watch mode): bin/yarn build:css --watch

    Access the application at http://localhost:3000. If connection errors occur, verify your database user and password (default is admin/admin).

    # Full development startup
    bin/dev
  5. Set up the WBlog development environment

    master

    WBlog is a standard Ruby on Rails application. To set up a local development environment, ensure you have the following system dependencies installed:

    • Ruby: 3.1.2
    • PostgreSQL: >= 9.x
    • Node.js: >= 18

    Follow these steps to install dependencies and configure the application:

    # 1. Install Rails dependencies
    gem install bundler
    bundle install
    
    # 2. Install Node dependencies
    npm install yarn -g
    yarn install
    
    # 3. Copy and update configuration files
    cp config/application.yml.example config/application.yml
    cp config/database.yml.example config/database.yml
  6. Start the WBlog development server

    master

    After completing the setup steps (installing gems, node dependencies, and configuring application.yml and database.yml), you can start the application using the following command:

    bin/dev

    Once the server is running, you can access the administration panel at http://localhost:3000/admin to publish your first blog post.

  7. Set up the development environment using bin/setup

    master

    The bin/setup script automates the initialization and updating of your local development environment. It is idempotent, meaning you can run it multiple times without side effects.

    Running this script performs the following actions:

    1. Installs Ruby dependencies via bundler.
    2. Installs JavaScript dependencies using bin/yarn.
    3. Creates configuration files (config/database.yml and config/application.yml) from their .example templates if they do not already exist.
    4. Prepares the database using bin/rails db:prepare.
    5. Seeds the database using bin/rails db:seed.
    6. Clears old logs and temporary files.
    7. Restarts the application server.
    bin/setup
  8. Run the development server with bin/dev

    master

    The bin/dev script is a shell script used to start the WBlog development environment. It automatically ensures foreman is installed via RubyGems and then uses it to run the processes defined in Procfile.dev.

    To run the server on a specific port, set the PORT environment variable before executing the script. If no port is specified, it defaults to 3000.

    # Run on default port 3000
    ./bin/dev
    
    # Run on a custom port
    PORT=4000 ./bin/dev
    
    # Pass additional arguments to foreman
    ./bin/dev --some-foreman-flag
  9. Use CodeHTML for Markdown rendering with Rouge syntax highlighting

    master

    The CodeHTML class is a custom Redcarpet HTML renderer that integrates Rouge for syntax highlighting. When initializing CodeHTML, it automatically merges a default configuration that sets link_attributes: { target: "_blank" }, ensuring all links generated from Markdown open in a new tab by default. This class is intended to be used as a renderer for the Redcarpet Markdown engine.

    # Example usage with Redcarpet
    renderer = CodeHTML.new
    markdown = Redcarpet::Markdown.new(renderer)
    html_output = markdown.render("# Your Markdown Content")