docbrown/lib/data_update_scripts/20201001173841_add_navigation_links.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

26 lines
1.7 KiB
Ruby

module DataUpdateScripts
class AddNavigationLinks
PROTOCOL = ApplicationConfig["APP_PROTOCOL"].freeze
DOMAIN = Rails.application&.initialized? ? Settings::General.app_domain : ApplicationConfig["APP_DOMAIN"]
BASE_URL = "#{PROTOCOL}#{DOMAIN}".freeze
READING_ICON = File.read(Rails.root.join("app/assets/images/twemoji/drawer.svg")).freeze
THUMB_UP_ICON = File.read(Rails.root.join("app/assets/images/twemoji/thumb-up.svg")).freeze
SMART_ICON = File.read(Rails.root.join("app/assets/images/twemoji/smart.svg")).freeze
LOOK_ICON = File.read(Rails.root.join("app/assets/images/twemoji/look.svg")).freeze
CONTACT_ICON = File.read(Rails.root.join("app/assets/images/twemoji/contact.svg")).freeze
def run
NavigationLink.where(name: "Reading List", url: "#{BASE_URL}/readinglist", icon: READING_ICON,
display_only_when_signed_in: true, position: 0).first_or_create
NavigationLink.where(name: "Code of Conduct", url: "#{BASE_URL}/code-of-conduct", icon: THUMB_UP_ICON,
display_only_when_signed_in: false, position: 1).first_or_create
NavigationLink.where(name: "Privacy Policy", url: "#{BASE_URL}/privacy", icon: SMART_ICON,
display_only_when_signed_in: false, position: 2).first_or_create
NavigationLink.where(name: "Terms of Use", url: "#{BASE_URL}/terms", icon: LOOK_ICON,
display_only_when_signed_in: false, position: 3).first_or_create
NavigationLink.where(name: "Contact", url: "#{BASE_URL}/contact", icon: CONTACT_ICON,
display_only_when_signed_in: false, position: 4).first_or_create
end
end
end