{"id":19150040,"url":"https://github.com/smashingboxes/cardboard-admin-archive","last_synced_at":"2025-07-26T03:04:48.241Z","repository":{"id":6725299,"uuid":"7971145","full_name":"smashingboxes/cardboard-admin-archive","owner":"smashingboxes","description":"Rails 4 CMS","archived":false,"fork":false,"pushed_at":"2016-05-20T14:14:14.000Z","size":2119,"stargazers_count":65,"open_issues_count":19,"forks_count":13,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-05-07T05:06:35.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://smashingboxes.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smashingboxes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-02T03:38:29.000Z","updated_at":"2024-09-07T06:10:10.000Z","dependencies_parsed_at":"2022-08-24T17:42:19.873Z","dependency_job_id":null,"html_url":"https://github.com/smashingboxes/cardboard-admin-archive","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/smashingboxes/cardboard-admin-archive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fcardboard-admin-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fcardboard-admin-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fcardboard-admin-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fcardboard-admin-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smashingboxes","download_url":"https://codeload.github.com/smashingboxes/cardboard-admin-archive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smashingboxes%2Fcardboard-admin-archive/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267109941,"owners_count":24037627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:10:27.028Z","updated_at":"2025-07-26T03:04:48.222Z","avatar_url":"https://github.com/smashingboxes.png","language":"Ruby","readme":"# Cardboard\n[![Code Climate](https://codeclimate.com/github/smashingboxes/cardboard.png)](https://codeclimate.com/github/smashingboxes/cardboard)\n[![Build Status](https://travis-ci.org/smashingboxes/cardboard.svg?branch=master)](https://travis-ci.org/smashingboxes/cardboard)\n[![Stories in Ready](https://badge.waffle.io/smashingboxes/cardboard.png?label=ready\u0026title=Ready)](https://waffle.io/smashingboxes/cardboard)\n\nCardboard is a simple CMS Engine for your Rails 4 applications.\n\n## Features\n* Build for Rails 4\n* Make your site and your admin area the standard rails way (no complex engines)\n* Create pages and site settings in seconds\n* Repeatable page parts\n* Write your views in haml/slim/erb...! (no restrictive DSL or templating language)\n* Your customers will love the UI/UX\n* Easy to extend and customize\n* It's like your favorite admin interface gem just had a baby with a CMS\n\n![alt text](https://github.com/smashingboxes/cardboard/wiki/images/2a.jpg \"screenshot1\")\n\n## Updating from 0.2 -\u003e 0.3\nSome changes were made to the database. Before updating make sure to have a look at the [new migration](https://github.com/smashingboxes/cardboard/blob/master/spec/dummy/db/migrate/20150119175934_create_cardboard.cardboard.rb)\n\n## Requirements\n* An authentication solution. For example, [here is what you need to do](https://github.com/plataformatec/devise#getting-started) to get **Devise** installed.\n* [ImageMagick](http://www.imagemagick.org/)\n* **Rails 4.x** and **Ruby 2.x**\n\n## Installation\nAdd the gem to the _Gemfile_\n\n```ruby\ngem 'cardboard_cms'\n```\n\nRun bundler and cardboard's install generator\n```sh\nbundle install\nrails generate cardboard:install\nrake db:migrate\n```\n\nEdit your _config/cardboard.yml_ file then run\n```sh\nrake cardboard:seed\n```\n\n## Usage\n### Get a page\nAdd a file in your _app/views/pages_ (or _app/views/templates_) with filename matching the identifier of the page. Inside this file you can access the page with:\n```ruby\ncurrent_page\n```\n\n### Fetch a page part\n```ruby\ncurrent_page.get 'slideshow'\n```\n\n### Fetch a repeatable page part\nRepeatable parts returns an active record collection. This means that regular Rails methods such as `where`, `limit`, `first`, `each`, etc can be used on page parts\n```slim\n- current_page.get('slideshow').each do |slide|\n  p = image_tag slide.attr('image1').thumb('600x300').url, alt: slide.attr('description') if slide.attr('image1')\n```\n\n### Fetch a single field\nIf this part is **not repeatable** you can use both\n```ruby\ncurrent_page.get('intro').attr 'text1'\n# Or\ncurrent_page.get 'intro.text1'\n```\n\n### Image Fields methods\nImages returned by `:image` type fields are [Dragonfly](http://markevans.github.io/dragonfly/) objects. As such, it's possible to edit them directly from the view.\n```ruby\nif image = current_page.get('intro.image1')\n  image.url                 # URL of the modified image\n  image.thumb('40x30#').url  # resize, crop if necessary to maintain aspect ratio (centre gravity)\n  image.process(:greyscale).thumb('40x30#').url\nend # Hint: remember to check if image is not nil before calling methods on it\n```\n\nMore options and methods are available at [Dragonfly's Documentation](http://markevans.github.io/dragonfly/file.ImageMagick.html)\n\n### File field methods\nSimilarly to images, files are also Dragonfly objects. This allows such methods as:\n```ruby\nfile.format                     # =\u003e :pdf\nfile.name                       # =\u003e \"some.pdf\"\nnumber_to_human_size(file.size) # =\u003e \"486 KB\"\n```\n\n## Create Pages\nTo add pages to cardboard edit _config/cardboard.yml_. See a sample [_cardboard.yml_](https://github.com/smashingboxes/cardboard/blob/master/spec/dummy/config/cardboard.yml)\n```yml\npages:\n  home_page:\n    title: Default page title\n    parts:\n      slideshow:\n        repeatable: true\n        fields:\n          image1:\n            type: image\n            required: true\n            default: CrashTest.jpg\ntemplates:\n  two_column:\n    parts:\n      main:\n        fields:\n          body:\n            type: rich_text\n```\n\npages, parts and fields take identifiers (`:home_page`, `:slideshow` and `:image1`) used to reference the data form the views. Choose these names carefully!\n\n#### Pages\nEach page section starts with the name of it's unique identifier. This name is used to reference the page in the code an thus should not change throughout the life of the project.\n\nKey | Type | Default | Definition\n---|--- | ---|---\n[parts](#parts) | hash | `nil` |a list of page parts\ntitle | string | identifier | name of the page as shown in the nav bar\nposition | integer | auto-increment | position of the page on the nav bar (the lowest position is the home page!)\nparent_id | string | `nil` | identifier of the parent page (used for nested pages)\ncontroller_action | string | `'pages#identifier'` | go to a specific controller example `'blog#index'`. In that case, the page identifier is passed in the params. If you'd like to still have the current_page goodness, make your controller inherit from `UrlController`\n\n#### Templates\nTemplates are declared exactly like pages. They allow for the creation of pages directly from the admin interface. One key difference between templates and pages is the location of the view files which will be under _app/views/templates_.\n\n#### Parts\nEach part sub-section starts with the name of it's unique identifier. This name is used to reference the part in the code an thus should not change throughout the life of the project.\n\nKey | Type | Default | Definition\n---|--- | ---|---\n[fields](#fields) | hash | `nil` | list of fields that make this part's form\nposition | integer | auto-increment | position of the part on the admin page\nrepeatable | boolean or string | `false` | can the client add multiple of these parts (example a slide in a slideshow), if a string is passed, `true` is assumed and the string becomes the label for a single part\n\n#### Fields\nEach field sub-section starts with the name of it's unique identifier. This name is used to reference the field in the code an thus should not change throughout the life of the project.\n\nKey | Type | Default | Definition\n---|--- | ---|---\nlabel | string | identifier | form field label\nhint | string | `nil` | form field hint\nplaceholder | string | `nil` | form field placeholder\nposition | integer | auto-increment | position of the field within the part (only for the admin area)\nrequired | boolean | `true` | must this field have a value for the form to save\ntype | string | `'string'` | choose between: `'boolean'`, `'date'`, `'decimal'`, `'file'`, `'image'`, `'integer'`, `'rich_text'`, `'text'`, `'string'`, `'resource_link'` (needs value: resource_linked, same as the controller name ex: `'pianos'`), `'external_link'` (needs value: `'http://site.com'`)\ndefault | string | `nil` | set the value but don't overwrite (only set if `nil`). Put default images in _/assets/images/defaults_ and default files in _/assets/files/defaults_\nvalue | string | `nil` | USE ONLY FOR types `'resource_link'` and `'external_link'` (this will overwrite user input, in most cases use the **_default_** key instead)\n\n## Create Resources\nTo add an admin area for a model simply type (make sure the model exists first and migrations have been run)\n```sh\nrails generate cardboard:resource model_name\n```\n\nThen customize the _controllers/cardboard/model_name_controller.rb_ and associated views to your heart's desire.\n\nThe default cardboard resource scaffold help you quickly get started by making the most of the following gems.\n\nGem | Description\n--- | ---\n[Simple Form](https://github.com/plataformatec/simple_form) | Forms made easy! It's tied to a simple DSL, with no opinion on markup.\n[Kaminari](https://github.com/amatsuda/kaminari) | A Scope \u0026 Engine based, clean, powerful, customizable and sophisticated paginator\n[Ransack](https://github.com/activerecord-hackery/ransack) | Object-based searching and filtering\n[Dragonfly](https://github.com/markevans/dragonfly) | On-the-fly image processing and file uploading\n\n\n### Menu options\nYou can customize the menu for this resource by adding to the controller class:\n```ruby\nmenu  label: 'Test', priority: 1\n```\n\nYou can also choose to remove a resource from the menu\n```ruby\nmenu  false\n```\n\n### Sorting\nYou can customize the sorting for this resource by adding to the controller class:\n```ruby\ndefault_order 'name DESC' # default: 'updated_at desc'\n```\n\nYou can pass any **Ransack** sort order, which includes associations. Example:\n```ruby\ndefault_order 'user_name' # belongs to a user\n```\n\n#### Filter helper\nYou can show filters on your resource index page simply by adding `cardboard_filters`, with the model class, the main field to search (has to be a text or string field), and options.\n\n```ruby\n= cardboard_filters User, :name\n```\n\nProperty | Description\n--- | ---\n`:title` | change the page's title (optional)\n`:new_button` | Options for the button used to create a new resource element. Can be `false` to remove it, or `'label'` and `'url'` can be modified (optional).\n`:predicate`|  defaults to `'cont'` (contains). Note: On non text fields, this field is required\n\nExample:\n```ruby\n= cardboard_filters User, :name, title: 'Employees', new_button: {label: 'Add an employee'}\n```\n\n#### Pagination Helper\nWe use **kaminari**, so all you need to do is add to your index view:\n```ruby\n= paginate @users\n```\n\n#### Column sorting helper\nThe `@q` variable gives access to the **Ransack** gem.\n```\n= sort_link @q, :name, 'Product Name'\n```\n\n#### Custom resource helpers\nTo add custom helpers for your resource simply create a helper with the same name.\nExample:\n```ruby\nmodule Cardboard\n  module PianosHelper\n  end\nend\n```\nMake sure this file is located under 'app/helpers/cardboard'\n\n#### Custom CSS/JS\nThe css/js for the resources is the same as the cardboard admin interface. If you'd like to extend or overwrite some of these, simply edit the _cardboard.css.scss_ or _cardboard.js_ files located in your _assets/_ folder. These files were generated during the cardboard installation.\n\nNote: Make sure to remove `*= require_tree .` from your _application.css_, you don't want your cardboard css and js to leak into your main app!\n\n## Create Settings\nYou can create new settings that will be editable from the admin panel.\n\nIn your _config/cardboard.yml_\n```yml\nsettings:\n  my_custom_setting:\n    type: boolean\n    default: true\n```\n\nAll options/types from fields are available\n\nThen you can use this setting in your views or controllers like so:\n\n```ruby\nCardboard::Setting.my_custom_setting\n```\n\n## View Helpers\n### Access Pages\n```ruby\ncurrent_page\n```\n\nyou can put your controller instance variables at the top of your view or in a decorator\n```\napp\n|- decorators\n  |- controllers\n    |- pages_decorator\n```\n\n```ruby\nPagesController.class_eval do\n  def page_identifier\n    @example = 'cool'\n  end\nend\n```\n\n### Page Path\nIn your controllers you may want to redirect to a specific page. You can do so with the following:\n```ruby\npage_path 'identifier_for_this_page'\npage_url 'identifier_for_this_page'\ncardboard.edit_page_path @page #link to let your admins edit the page they see\n```\n\n### Meta tags (SEO)\nTo add SEO meta tags simply add a yield as follows to your layout file:\n```slim\nhead\n  = yield :seo\n```\n\n### Show edit link\nFeel free to make it fit as you want in your site design\n```slim\n- if current_admin_user \u0026\u0026 current_page\n  div style=\"float:right\"\n    = link_to 'Edit this page', cardboard.edit_page_path(current_page)\n```\n\n### Page navigation\n```slim\n= nested_pages do |page, subpages|\n  .indent\n    = link_to(page.title, page.url) if page.in_menu?\n    = subpages\n```\nor similarly with UL and LI tags\n\n```slim\nul\n  = nested_pages do |page, subpages|\n    li\n      = link_to(page.title, page.url) if page.in_menu?\n      - if subpages\n        ul = subpages\n```\n\n### Link to a page\nUse the page identifier defined in the _cardboard.yml_ file\n```ruby\n= link_to_page 'page_identifier', class: 'btn' do |page|\n  \"hello #{page.title}\"\nend\n\n# or, to simply use the page title\n\n= link_to_page 'page_identifier', class: 'btn'\n```\n\n## Abilities\nYou can (and should) add a `can_manage_cardboard?` method to your user model. By default users can manage all areas of the admin panel.\n```ruby\ndef can_manage_cardboard?(area)\n  case area\n  when :pages\n    self.admin?\n  when :settings\n    self.admin?\n  when :resource_identifier #should be plural\n    true\n  else\n    true\n  end\nend\n```\n\n## Dashboard\nYou can add whatever you want on the dashboard by simply adding\n```\nviews\n|- cardboard\n   |- dashboard\n       |- index.html.slim\n```\n\n## Customizing Cardboard\n\n### Overwrite views\nYou can easily change the default behavior of the app by overwriting the views. For example say you'd like to change the my account page. Simply add a _views/cardboard/my_account/edit.html.slim_ and edit it at will.\n\n## Deploy with Capistrano\n```ruby\nnamespace :cardboard do\n  desc 'Seed the cardboard'\n  task :seed do\n    run \"cd #{current_path}; bundle exec rake cardboard:seed RAILS_ENV=#{rails_env}\"\n  end\nend\nafter 'deploy', 'cardboard:seed'\n```\n\n## License\nCopyright (c) 2013-2015 by Smashing Boxes\n\nSee [LICENSE.txt](https://github.com/smashingboxes/cardboard/blob/master/LICENSE.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashingboxes%2Fcardboard-admin-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmashingboxes%2Fcardboard-admin-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmashingboxes%2Fcardboard-admin-archive/lists"}