{"id":13778860,"url":"https://github.com/refinery/refinerycms-settings","last_synced_at":"2025-04-12T15:43:47.465Z","repository":{"id":847215,"uuid":"3524395","full_name":"refinery/refinerycms-settings","owner":"refinery","description":"Extracted from Refinery CMS","archived":false,"fork":false,"pushed_at":"2022-03-04T04:40:18.000Z","size":144,"stargazers_count":26,"open_issues_count":6,"forks_count":48,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-26T10:11:30.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://refinerycms.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/refinery.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-23T10:31:14.000Z","updated_at":"2023-12-03T01:17:01.000Z","dependencies_parsed_at":"2022-08-06T10:01:08.546Z","dependency_job_id":null,"html_url":"https://github.com/refinery/refinerycms-settings","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refinery%2Frefinerycms-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refinery%2Frefinerycms-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refinery%2Frefinerycms-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refinery%2Frefinerycms-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refinery","download_url":"https://codeload.github.com/refinery/refinerycms-settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590971,"owners_count":21129924,"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","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-08-03T18:00:58.267Z","updated_at":"2025-04-12T15:43:47.435Z","avatar_url":"https://github.com/refinery.png","language":"Ruby","funding_links":[],"categories":["Refinery team extensions"],"sub_categories":["Backoffice extensions"],"readme":"# Refinery CMS Settings\n\n[![Build Status](https://travis-ci.org/refinery/refinerycms-settings.svg?branch=master)](https://travis-ci.org/refinery/refinerycms-settings)\n\n## About\n\nRefinery Settings was extracted from Refinery CMS just before 2.0.0 was released\nand can now be used separately.\n\n## Installation\nAdd the gem to you Gemfile:\n\n    gem 'refinerycms-settings'\n\nGenerate and install the necessary migrations:\n\n    rails generate refinery:settings\n    rake db:migrate\n\n## Upgrading from 2.0.x\nWhen you upgrade from version 2.0.x make sure you run:\n\n    rails generate refinery:settings\n    rake db:migrate\n\nIt will copy the new migration and migrate the database.\n\n## How do I Make my Own Settings?\n\n### In view\n\nSettings can be really useful, especially when you have custom display logic or\nnew plugins that need to behave in different ways.\n\nTo best explain how settings work, let's use an example. Say you have a client\nwho has a display in a local trade show every year and 2 months before the trade\nshow, they want to display a little banner in the header of all pages.\n\nOnce the trade show is finished, the client needs to be able to hide it again\nuntil next year. This is what your ``application.html.erb`` file might look like:\n\n    ...\n    \u003cdiv id='header'\u003e\n      \u003ch1\u003eMy Company\u003c/h1\u003e\n\n      \u003c% if ::Refinery::Setting.find_or_set(:show_trade_show_banner, false) %\u003e\n        \u003c%= image_tag ('trade-show-banner.jpg') %\u003e\n      \u003c% end %\u003e\n    \u003c/div\u003e\n    ...\n\nThe following will automatically create a new Refinery setting called\n\"show_trade_show_banner\" and set its default to ``false``.\nIf that setting already exists, it just reads in what the current value is.\n\nSo as you can see, this is quite clever because you can quickly define new settings\n and their defaults right from the view as you need them.\n\nThis setting would then show up in the backend in the 'Settings' area where the\nclient could change the value as their trade show approaches. Easy as pie!\n\n### In Controller\n\n    limit = Refinery::Setting.find_or_set(:list_limit, 20)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefinery%2Frefinerycms-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefinery%2Frefinerycms-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefinery%2Frefinerycms-settings/lists"}