module Shipit module ShipitHelper def subscribe(url, *selectors) content_for(:update_subscription) do [ tag('meta', name: 'subscription-channel', content: url), *selectors.map { |s| tag('meta', name: 'subscription-selector', content: s) }, ].join("\n").html_safe end end def emojify(content) h(content).to_str.gsub(/:([\w+-]+):/) do |match| if emoji = Emoji.find_by_alias($1) %( ##{$1} ) else match end end.html_safe if content.present? end def include_plugins(stack) safe_join(stack.plugins.flat_map { |plugin, config| plugin_tags(plugin, config) }) end def plugin_tags(plugin, config) tags = [] tags << tag('meta', name: "#{plugin}-config", content: config.to_json) if config tags << javascript_include_tag("plugins/#{plugin}") tags << stylesheet_link_tag("plugins/#{plugin}") tags end def missing_github_oauth_message <<-MESSAGE.html_safe Shipit requires a GitHub application to authenticate users. If you haven't created an application on GitHub yet, you can do so in the #{link_to 'Settings', Shipit.github_url('/settings/applications/new'), target: '_blank'} section of your profile. You can also create applications for organizations. When setting up your application in Github, set the Homepage URL to your domain and the Authorization callback URL to '/github/auth/github/callback'. MESSAGE end def missing_github_oauth_id_message <<-MESSAGE.html_safe Copy the Client ID from your GitHub application, and paste it into the secrets.yml file under github_oauth.id. MESSAGE end def missing_github_oauth_secret_message <<-MESSAGE.html_safe Copy the Client Secret from your GitHub application, and paste it into the secrets.yml file under github_oauth.secret. MESSAGE end def missing_github_api_credentials_message <<-MESSAGE.html_safe Shipit needs API access to GitHub. You can #{link_to 'create an access token', Shipit.github_url('/settings/tokens'), target: '_blank'} with the following permissions: admin:repo_hook, admin:org_hook and repo and add it to the secrets.yml file under the key github_api.access_token. MESSAGE end def missing_redis_url_message <<-MESSAGE.html_safe Shipit needs a Redis server. Please configure the Redis URL in the secrets.yml file of your app, under the key redis_url. MESSAGE end def missing_host_message <<-MESSAGE.html_safe Shipit needs the host of the application before generating links in background jobs. Add the host name to the secrets.yml file, under the host key. MESSAGE end end end