Project

trusty-cms

0.05
A long-lived project that still receives updates
TrustyCms is a simple and powerful publishing system designed for small teams. It is built with Rails and is similar to Textpattern or MovableType, but is a general purpose content management system--not merely a blogging engine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
>= 0
>= 0.9.5, < 1.3.0
~> 2.9.1
>= 4.2.2, < 4.4.0
>= 0.2, < 2.0
>= 0
~> 2.7
>= 5.0, < 6.0
>= 0
~> 0.7
~> 7.0.0
< 14.0
>= 5.1, < 7.0
= 4.3.3
>= 2.7.1, < 2.9.0
>= 1.2.3, < 2.1.0
>= 3.2, < 5.0
>= 3, < 5
~> 16.0.0
= 5.2.2
>= 0
>= 1.7.8, < 3.2.0
>= 2.0.1, < 3.2.0
~> 4.2.1
 Project Readme

Welcome to TrustyCMS

Gem Version

TrustyCMS is a branch of Radiant CMS. Its goal is to pull the Radiant framework into Rails 7 with minimal changes to its infrastructure.

TrustyCMS is a no-fluff, open source content management system designed for small teams. It is similar to Textpattern or MovableType, but is a general purpose content management system (not just a blogging engine). TrustyCMS is a Rails engine and is built to be installed into an existing Rails 7 application as a gem.

CircleCI: CircleCI

CodeClimate: Code Climate

TrustyCMS features:

  • An elegant user interface
  • The ability to arrange pages in a hierarchy with drag and drop
  • Flexible templating with layouts, snippets, page parts, and a custom tagging language
  • A simple user management/permissions system
  • Support for Markdown and Textile as well as traditional HTML (it's easy to create other filters)
  • An advanced plugin system
  • Asset management & searching
  • Serve multiple sites (domains) from a single instance
  • Social sharing buttons
  • Reusable bits of content (Snippets)
  • Allows Rails controllers/actions to use Trusty CMS layouts as their "layout"
  • Operates in two modes: dev and production depending on the URL
  • A caching system which expires pages every 5 minutes
  • Built using Ruby on Rails (version 7)

License

TrustyCMS is released under the MIT license. The Radiant portions of the codebase are copyright (c) John W. Long and Sean Cribbs; anything after the fork is copyright (c) Pittsburgh Cultural Trust. A copy of the MIT license can be found in the LICENSE file.

Installation and Setup

TrustyCMS is a traditional Ruby on Rails engine, meaning that you can configure and run it the way you would a normal gem, like Devise.

See the INSTALL.md file for more instructions.

Installation

Prerequisites:

Steps:

  1. Fork this repository to your Github account.

  2. Clone your fork to your machine.

  3. cd into the directory you just cloned into.

  4. Follow the INSTALL.md instructions to setup an empty app with TrustyCMS installed. To modify TrustyCMS, point your dependency to the local path of your fork.

    gem 'trusty-cms', path: '../trusty-cms'

  5. Set up your databases in your Rails application:

     bundle exec rake db:create
     bundle exec rake db:migrate
    
  6. Run the tests to make sure they pass (If they don't, file a bug!):

     rspec
    

Custom Page Type Routes Setup

Additional configuration is required to ensure correct URL generation in the admin interface — specifically for the "Edit Page" dropdown and the "Save and View Draft" functionality.

To enable this, create the following initializer: config/initializers/page_type_routes.rb

In this file, define a CUSTOM_PAGE_TYPE_ROUTES hash constant that maps custom Page model class names to the corresponding route segments defined in your config/routes.rb file. For example, the BlogPage model maps to the route get 'blog/:slug', so its route segment is 'blog'.

For custom Page models that rely on default routing behavior, define a DEFAULT_PAGE_TYPE_ROUTES array listing their class names. TrustyCMS will use these mappings to correctly build page URLs for use in the admin UI.

CUSTOM_PAGE_TYPE_ROUTES = {
  BlogPage: 'blog',
  DonationPage: 'donate',
  ExhibitionPage: 'exhibit',
  NonTicketedEventPage: 'event',
  PackagePage: 'package',
  PersonPage: 'biography',
  ProductionPage: 'production',
  VenuePage: 'venues',
}.freeze

DEFAULT_PAGE_TYPE_ROUTES = %w[
  ConstituencyPage
  FacilityPage
  FileNotFoundPage
  RailsPage
].freeze

Save and View Draft Caching

To ensure that pages and drafts under development are not cached by the browser or content delivery networks (such as CloudFront), the CMS appends a trusty-no-cache URL parameter containing the current date and time when a user selects Save and View Draft or Save and View Page.

Because the trusty-no-cache parameter is always unique, it effectively bypasses caching mechanisms at both the CDN and browser levels, ensuring the user receives the most up-to-date version of the content with every request. Note that additional CDN configuration may be required to ensure query parameters are respected.

Page Status Refresh Setup

To ensure Scheduled Pages automatically update their status to Published after their designated Publish Date & Time, follow these steps to set up an automated refresh using AWS Lambda and EventBridge.

1. Generate a Bearer Token
Open a Rails console and run the following command:

rails c

Then generate a token:

SecureRandom.base58(24)

2. Store the Token in Rails Credentials
To store your token securely, edit your Rails credentials by running the following command:

bin/rails encrypted:edit config/credentials.yml.enc

Then, add the token to your credentials file under the trusty_cms namespace:

trusty_cms:
  page_status_bearer_token: '<your bearer token>'

3. Add Google Tag Manager Container ID (Optional) If you'd like to enable trusty-cms to submit Google Tag Manager data for tracking admin page activity (this does not include public-facing pages), add your Google Tag Manager Container ID to the trusty_cms section of your credentials.yml.enc file:

trusty_cms:
 page_status_bearer_token: '<your bearer token>'
 gtm_container_id: 'GTM-xxxxxx'

4. Create a Ruby Lambda Function in AWS

  • Log into AWS Lambda and create a new Ruby Lambda function.
  • Note the Ruby version used, as you'll need it locally.
  • Use rbenv to manage the Ruby version locally:
    rbenv install 3.3.0
    rbenv local 3.3.0

5. Write the Lambda Function Code
In your local development environment:

  • Create a new folder and open it in your IDE.
  • Save the following code in a file named lambda_handler.rb:
require 'httparty'

def lambda_handler(event:, context:)
  uri = ENV['API_ENDPOINT']
  token = ENV['BEARER_TOKEN']

  response = HTTParty.post(
    uri,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': "Bearer #{token}"
    }
  )

  if response.success?
    puts "Success: #{response.body}"
  else
    puts "Error: #{response.code} - #{response.message}"
  end
end

6. Install Dependencies
Run the following commands in your terminal:

gem install bundler
bundle init

Add the dependency to your Gemfile:

gem 'httparty'

Install dependencies locally:

bundle config set --local path 'vendor/bundle'
bundle install

7. Package the Lambda Function
Archive your function and dependencies:

zip -r lambda_package.zip .

8. Upload to AWS Lambda

  • In AWS Lambda, open your function.
  • Select Upload From > .zip file.
  • Upload the lambda_package.zip file.

9. Configure Environment Variables
In the AWS Lambda Configuration:

  • Go to Environment Variables > Edit.
  • Add the following:
    • API_ENDPOINT: <your-url>/page-status/refresh
    • BEARER_TOKEN: <your bearer token>

10. Set Up EventBridge Trigger

  • In Configuration Settings > Triggers, create a new EventBridge Trigger.
  • Set the Schedule to match your desired page status refresh frequency.

Your setup is now complete, and Scheduled Pages will automatically update their status via the AWS Lambda and EventBridge integration.

Contributing to TrustyCMS

When you're ready to make a change:

  1. Add the pgharts fork as a git remote called "upstream": git remote add upstream https://github.com/pgharts/trusty-cms.git so that you can keep up with changes that other people make.
  2. Fetch the remote you just added: git fetch upstream.
  3. Start a new branch for the change you're going to make. Name it something having to do with the changes, like " fix-queries" if you are going to try to fix some queries. Base this branch on upstream/master by running git checkout -b fix-queries upstream/master.
  4. Make your changes and commit them. Please include tests!
  5. Run the tests and make sure they pass.
  6. Push your changes to your github fork: git push origin fix-queries.
  7. Send a pull request to the pgharts fork.

Support

All of the development for TrustyCMS happens on Github:

https://github.com/pgharts/trusty-cms

TrustyCMS is supported in part by:

Enjoy!

-- The TrustyCMS Dev Team