Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ GITHUB_REPO_AGE_LIMIT = 30

URL_HOST = '0.0.0.0:3000'

MAILER_SENDER =
SUPPORT_EMAIL =
EMAIL_DOMAIN =
FEEDBACK_ALLOWED_ORIGIN =
NGINX_SERVER_NAME =
NGINX_STAGING_SERVER_NAME =
OPENHUB_BLOG_URL =
OPENHUB_OAUTH_BLOG_URL =
ANONYMOUS_ACCOUNT_EMAIL =
CRAWLER_ACCOUNT_EMAIL =
FORGE_USER_AGENT =

AIRBRAKE_API_KEY =
AIRBRAKE_HOST = "http://oh-utility02.dc1.lan"
AIRBRAKE_PORT = "4545"
Expand Down
12 changes: 11 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ AWS_SQS_BAD_EMAIL_QUEUE = "ses-bad-email-queue"
AWS_REGION = 'us-east-1'

URL_HOST = "localhost:3000"
MAILER_SENDER = 'mailer@openhub.example.com'
SUPPORT_EMAIL = 'info@openhub.example.com'
EMAIL_DOMAIN = 'openhub.example.com'
FEEDBACK_ALLOWED_ORIGIN = 'http://localhost:3000'
NGINX_SERVER_NAME = 'www.openhub.example.com'
NGINX_STAGING_SERVER_NAME = 'staging.openhub.example.com'
OPENHUB_BLOG_URL = 'http://blog.openhub.net/'
OPENHUB_OAUTH_BLOG_URL = 'http://blog.openhub.net/oauth/'
ANONYMOUS_ACCOUNT_EMAIL = 'anon@openhub.example.com'
CRAWLER_ACCOUNT_EMAIL = 'uber_data_crawler@openhub.example.com'
FORGE_USER_AGENT = 'openhub.example.com client'
KB_PROJECT_SEARCH_URL = 'https://www.vcrlocalhost.org/kb?'
KB_AUTH_KEY = 'dummy_test_key'

Expand All @@ -42,7 +53,6 @@ NVD_LINK = "https://nvd.nist.gov/nvd.cfm?cvename="
# Configure AWS SDK for test environment before requiring other gems
AWS_SES_ACCESS_KEY = 'test_access_key_id'
AWS_SES_SECRET_ACCESS_KEY = 'test_secret_access_key'
AWS_REGION = 'us-east-1'

TRAVIS_API_BASE_URL = 'https://api.travis-ci.org/'
CII_API_BASE_URL = 'https://www.bestpractices.dev/en/'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FeedbacksController < ApplicationController
before_action :set_access_control_header

def set_access_control_header
headers['Access-Control-Allow-Origin'] = 'https://security.openhub.net'
headers['Access-Control-Allow-Origin'] = ENV.fetch('FEEDBACK_ALLOWED_ORIGIN')
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/exceptions/param_record_not_found.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This exception is used in the app to distiguish between user generated ActiveRecord::RecordNotFound
# exceptions and ones generated internally. We do not want to jump on malformed URLs typed in by users
# (e.g. https://www.openhub.net/p/i_am_not_a_project), but do wish to alert and fix AR::RNF exceptions
# (e.g. https://www.openhub.blackduck.com/p/i_am_not_a_project), but do wish to alert and fix AR::RNF exceptions
# thrown by our internal code.
#
# To prevent Airbrake exceptions from bad URLs, in controllers, catch AR::RNF exceptions that come from
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/avatar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def avatar_default_size(size)

def gravatar_url(md5, size)
default_url = if ActionController::Base.asset_host.blank?
'https%3a%2f%2fopenhub.net'
"https%3a%2f%2f#{ENV.fetch('URL_HOST')}"
else
"http#{'s' if request&.ssl?}%3a%2f%2f#{ActionController::Base.asset_host}"
end
Expand Down
6 changes: 4 additions & 2 deletions app/helpers/site_features_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
module SiteFeaturesHelper
# rubocop:disable Metrics/MethodLength

BLOG_URL = ENV.fetch('OPENHUB_BLOG_URL').freeze

def features_hash
{
'OpenHub' => [
"you can subscribe to e-mail newsletters to receive update from the <a href='http://blog.openhub.net/'
"you can subscribe to e-mail newsletters to receive update from the <a href='#{BLOG_URL}'
target='_blank'>Open Hub blog</a>",
"data presented on the Open Hub is available through our
<a href='https://github.com/blackducksoftware/ohloh_api#ohloh-api-documentation' target='_blank'>API</a>",
Expand All @@ -18,7 +20,7 @@ def features_hash
"<a href=#{compare_projects_path} target='_self'>compare</a> projects before you chose one to use",
"check out <a href=#{projects_explores_path} target='_self'>hot projects</a> on the Open Hub",
"anyone with an Open Hub account can update a project's tags",
"learn about Open Hub updates and features on the <a href='http://blog.openhub.net/' target='_blank'>
"learn about Open Hub updates and features on the <a href='#{BLOG_URL}' target='_blank'>
Open Hub blog</a>"
],

Expand Down
10 changes: 5 additions & 5 deletions app/mailers/account_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# frozen_string_literal: true

class AccountMailer < ApplicationMailer
default from: 'mailer@openhub.net'
default from: ENV.fetch('MAILER_SENDER')

def signup_notification(account)
@account = account
@url = activate_account_accesses_url(account_id: account.to_param, code: account.activation_code,
host: ENV.fetch('URL_HOST', nil), protocol: 'https')
mail to: account.email, subject: t('.subject'), bcc: 'info@openhub.net'
host: ENV.fetch('URL_HOST'), protocol: 'https')
mail to: account.email, subject: t('.subject'), bcc: ENV.fetch('SUPPORT_EMAIL')
end

def activation(account)
@url = root_url(host: ENV.fetch('URL_HOST', nil))
@url = root_url(host: ENV.fetch('URL_HOST'))
@account = account
mail to: account.email, subject: t('.subject')
end
Expand Down Expand Up @@ -40,6 +40,6 @@ def reset_password(account_id)

def review_account_data_for_spam(account)
@account = account
mail to: 'info@openhub.net', subject: I18n.t('mailers.account_mailer.review_account_spam')
mail to: ENV.fetch('SUPPORT_EMAIL'), subject: I18n.t('mailers.account_mailer.review_account_spam')
end
end
2 changes: 1 addition & 1 deletion app/mailers/deleted_account_notifier_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def deletion(account)
mail(
to: recipient,
subject: I18n.t('mailers.deleted_account_notifier_mailer.account_deleted'),
from: 'mailer@openhub.net',
from: ENV.fetch('MAILER_SENDER'),
template_path: 'mailers', template_name: 'account_deletion_notification'
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/invite_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class InviteMailer < ApplicationMailer
default from: 'mailer@openhub.net'
default from: ENV.fetch('MAILER_SENDER')
default template_path: 'mailers'

def send_invite(invite)
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/manage_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ManageMailer < ApplicationMailer
default to: proc { (@manager || @manage.account).email },
from: 'mailer@openhub.net'
from: ENV.fetch('MAILER_SENDER')

def rejection(manage)
@manage = manage
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/project_badge_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ProjectBadgeMailer < ApplicationMailer
default from: 'mailer@openhub.net'
default from: ENV.fetch('MAILER_SENDER')

def check_cii_projects(projects)
@projects = projects
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/project_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

class ProjectMailer < ApplicationMailer
default from: 'mailer@openhub.net'
default from: ENV.fetch('MAILER_SENDER')

def report_outdated(account, project)
@account = account
@project = project
mail to: 'info@openhub.net', subject: "#{@project.name} is outdated"
mail to: ENV.fetch('SUPPORT_EMAIL'), subject: "#{@project.name} is outdated"
end
end
2 changes: 1 addition & 1 deletion app/models/anonymous_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module AnonymousAccount
class << self
def create!
anonymous_account = Account.new(name: 'Anonymous Coward', login: LOGIN,
email: 'anon@openhub.net', password: 'mailpass')
email: ENV.fetch('ANONYMOUS_ACCOUNT_EMAIL'), password: 'mailpass')
anonymous_account.save!
anonymous_account.access.activate!(nil)

Expand Down
3 changes: 2 additions & 1 deletion app/models/concerns/account_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module AccountScopes
ANONYMOUS_ACCOUNTS = %w[anonymous_coward ohloh_slave uber_data_crawler].freeze
ANONYMOUS_ACCOUNTS_EMAILS = %w[anon@openhub.net info@openhub.net uber_data_crawler@openhub.net].freeze
ANONYMOUS_ACCOUNTS_EMAILS = [ENV.fetch('ANONYMOUS_ACCOUNT_EMAIL'), ENV.fetch('SUPPORT_EMAIL'),
ENV.fetch('CRAWLER_ACCOUNT_EMAIL')].freeze

extend ActiveSupport::Concern

Expand Down
2 changes: 1 addition & 1 deletion app/models/forge/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_result(uri, request)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request['Content-Type'] = 'application/json'
request['User-Agent'] = 'openhub.net client'
request['User-Agent'] = ENV.fetch('FORGE_USER_AGENT')
response = http.request(request)
JSON.parse(response.body)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/knowledge_base_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def json_message
message_hash = {
ohloh_id: project_id,
deleted: project.deleted?,
ohloh_url: "https://www.openhub.net/p/#{project_id}",
ohloh_url: "https://#{ENV.fetch('URL_HOST')}/p/#{project_id}",
name: project.name,
created_at: project.created_at.iso8601,
updated_at: project.updated_at.iso8601,
Expand Down Expand Up @@ -199,7 +199,7 @@ def get_organization

org_hash = {}
Organization::KB_SYNC_ATTRS.map { |attr| org_hash[attr] = project.organization.send(attr) }
org_hash['url'] = "https://www.openhub.net/orgs/#{project.organization.id}"
org_hash['url'] = "https://#{ENV.fetch('URL_HOST')}/orgs/#{project.organization.id}"
org_hash
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
%meta{ content: h(@account.name).to_s, name: 'twitter:title' }
%meta{ content: @twitter_detail.description.to_s, name: 'twitter:description' }
%meta{ content: avatar_img_path(@account, 80).to_s, name: 'twitter:image' }
%meta{ content: 'https://www.openhub.net', name: 'twitter:domain' }
%meta{ content: "https://#{ENV.fetch('URL_HOST')}", name: 'twitter:domain' }

= render partial: 'accounts/show/summary'
.clearfix
Expand Down
2 changes: 1 addition & 1 deletion app/views/codeopenhub/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
way we can continue to support the Open Source Software community.
%p We apologize for any inconvenience that this has caused and thank you for your continued support.
%div{ style: 'margin-bottom: 30px' }
%a{ href: 'https://www.openhub.net' } Return to the Open Hub
%a{ href: "https://#{ENV.fetch('URL_HOST')}" } Return to the Open Hub
6 changes: 4 additions & 2 deletions app/views/forums/_notice.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- blog_link = 'https://community.blackduck.com/s/black-duck-open-hub'
- email = 'info@openhub.net'
- email = ENV.fetch('SUPPORT_EMAIL')
.alert.alert-warning.margin_top_20
%p
Dear Open Hub Users,
Expand All @@ -13,5 +13,7 @@

%p
%br
On May 1, 2020, we will be freezing https://www.openhub.net/forums and users will not be able to create new discussions. If you have any questions and concerns, please email us at
On May 1, 2020, we will be freezing
= "https://#{ENV.fetch('URL_HOST')}/forums"
and users will not be able to create new discussions. If you have any questions and concerns, please email us at
%a{ href: "mailto:#{email}"} #{email}
2 changes: 1 addition & 1 deletion app/views/layouts/partials/_mast.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.navbar
%span{ itemscope: '', itemtype: 'http://schema.org/CreativeWork' }
%span.hidden{ itemprop: 'author' } openhub.net
%span.hidden{ itemprop: 'author' }= ENV.fetch('URL_HOST')
%span.hidden{ itemprop: 'publisher' } Black Duck Software, Inc.
%span
%div.logo-div
Expand Down
2 changes: 1 addition & 1 deletion app/views/licenses/_fields.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
%label.control-label.required= t('.url_name')
.controls
.input-prepend.pull-left
%span.add-on= 'http://www.openhub.net/licenses/'
%span.add-on= "https://#{ENV.fetch('URL_HOST')}/licenses/"
- read_only = @license.persisted? ? true : false
= f.text_field :vanity_url, readonly: read_only, :class => 'check-availability col-md-6',
autocomplete: 'off',
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailers/login_changed_notification.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The old name violated new system rules about allowed characters.
Your new login name is "#{@account.login}" (without the quotation marks).
You may edit your login name at Open Hub's
%a{ href: 'https://www.openhub.net/accounts/me/edit' }
%a{ href: "https://#{ENV.fetch('URL_HOST')}/accounts/me/edit" }
Edit Account Page
to any other legal value.

Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%label.control-label.required= t('.url')
.controls
.input-prepend
%span.add-on= 'http://www.openhub.net/orgs/'
%span.add-on= "https://#{ENV.fetch('URL_HOST')}/orgs/"
= f.text_field :vanity_url, class: 'check-availability',
'data-original-value' => Organization.find_by(id: @organization).try(:vanity_url),
'data-ajax-path' => organization_check_availabilities_path,
Expand Down
6 changes: 4 additions & 2 deletions app/views/organizations/claim_projects_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
.clearfix
= render partial: 'shared/search_dingus', locals: { collection: @projects, sort_context: :claim_projects_list }

- support_email = ENV.fetch('SUPPORT_EMAIL')

- if @projects.any? && @projects.detect { |p| !p.organization_id.blank? && p.organization_id != @organization.id }
.alert.alert-block.margin_top_10
%h4.nomargin
%i.icon-warning-sign
= t('.already_claimed')
= t('.report')
%a{ href: 'mailto:info@openhub.net' }
info@openhub.net
%a{ href: "mailto:#{support_email}" }
= support_email
\.

- unless @projects.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/views/privacy/_privacy_text.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.col-md-5
%ul.margin_left_40
%li= t('.opting_out')
%li= t('.openhub_oauth_html', href: link_to(t('.oauth_api'), 'http://blog.openhub.net/oauth/'))
%li= t('.openhub_oauth_html', href: link_to(t('.oauth_api'), ENV.fetch('OPENHUB_OAUTH_BLOG_URL')))
2 changes: 1 addition & 1 deletion app/views/project_widgets/_ohloh_code_footer.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%h2.footer.ohloh_widget_code_footer
= link_to 'http://code.openhub.net', target: '_blank', style: 'margin-right:11px' do
= link_to "https://#{ENV.fetch('URL_HOST')}", target: '_blank', style: 'margin-right:11px' do
= t('.with')
= image_tag widget_ohloh_logo_url, border: 0
= t('.code')
2 changes: 1 addition & 1 deletion app/views/projects/check_forge.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
%label.control-label.required= t('.url')
.controls
.input-prepend
%span.add-on= 'http://www.openhub.net/p/'
%span.add-on= "https://#{ENV.fetch('URL_HOST')}/p/"
= f.text_field :vanity_url, class: 'check-availability', autocomplete: 'off',
style: 'width: 188px;',
'data-original-value' => Project.find_by(id: @project).try(:vanity_url),
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
%label.control-label.required= t('.oh_project_url')
.controls
.input-prepend
%span.add-on http://www.openhub.net/p/
%span.add-on= "https://#{ENV.fetch('URL_HOST')}/p/"
= f.text_field :vanity_url, class: 'check-availability', autocomplete: 'off',
style: 'width:514px;',
'data-original-value' => Project.find_by(id: @project).try(:vanity_url),
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%meta{ content: project_twitter_description(@project, @analysis), name: 'twitter:description' }
- if @project.logo
%meta{ content: @project.logo.attachment.url(:med), name: 'twitter:image' }
%meta{ content: 'https://www.openhub.net', name: 'twitter:domain' }
%meta{ content: "https://#{ENV.fetch('URL_HOST')}", name: 'twitter:domain' }

%div.separator-div
= project_analysis_timestamp(@project)
Expand Down
2 changes: 1 addition & 1 deletion app/views/topics/show.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ atom_feed do |feed|
xml.rss do
xml.channel do
feed.title "Recent Posts in '#{@topic.title}' | Open Hub"
feed.link "https://www.openhub.net#{topic_path(@topic)}"
feed.link "https://#{ENV.fetch('URL_HOST')}#{topic_path(@topic)}"
feed.language 'en-us'
feed.ttl 60
feed.description @topic.title
Expand Down
2 changes: 1 addition & 1 deletion app/views/widgets/metadata.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ prefs = {}
prefs[:title] = @widget.title
prefs[:title_url] = root_url
prefs[:author] = 'Open Hub'
prefs[:author_email] = 'info@openhub.net'
prefs[:author_email] = ENV.fetch('SUPPORT_EMAIL')
prefs[:author_link] = root_url
prefs[:description] = @widget.description
prefs[:width] = @widget.width + 10
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Application < Rails::Application
config.generators.helper = false
config.action_controller.include_all_helpers = false
config.active_record.schema_format = :sql
config.action_mailer.default_url_options = { host: ENV.fetch('URL_HOST', nil) }
config.action_mailer.default_url_options = { host: ENV.fetch('URL_HOST') }
config.active_job.queue_adapter = :sidekiq

config.google_maps_api_key = ENV.fetch('GOOGLE_MAPS_API', nil)
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
user_name: 'apikey', # This is the string literal 'apikey', NOT the ID of your API key
password: ENV.fetch('SENDGRID_API_KEY', nil),
# This is the secret sendgrid API key which was issued during API key creation
domain: 'openhub.net',
domain: ENV.fetch('EMAIL_DOMAIN'),
address: 'smtp.sendgrid.net',
port: 587,
authentication: :plain,
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/clearance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Clearance.configure do |config|
config.routes = false
config.mailer_sender = 'mailer@openhub.net'
config.mailer_sender = ENV.fetch('MAILER_SENDER')
config.password_strategy = PasswordStrategy
config.secure_cookie = Rails.env.staging? || Rails.env.production?
config.redirect_url = '/accounts/me'
Expand Down
Loading
Loading