Skip to content

Commit

Permalink
Merge 852574b into 9df2e95
Browse files Browse the repository at this point in the history
  • Loading branch information
jhass committed Sep 3, 2020
2 parents 9df2e95 + 852574b commit 7cfd461
Show file tree
Hide file tree
Showing 15 changed files with 764 additions and 696 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ app/views/terms/terms.*
app/assets/images/custom/

# Configuration files
config/diaspora.toml
config/diaspora.yml
config/initializers/secret_token.rb
.bundle
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ gem "uglifier", "4.2.0"

# Configuration

gem "configurate", "0.3.1"
gem "configurate", "0.4.0"
gem "tomlrb", "1.3.0"

# Cross-origin resource sharing

Expand Down
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ GEM
sass-rails (< 5.1)
sprockets (< 4.0)
concurrent-ruby (1.1.6)
configurate (0.3.1)
configurate (0.4.0)
connection_pool (2.2.2)
coveralls (0.8.23)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -730,6 +730,7 @@ GEM
tins (1.24.1)
sync
to_regexp (0.2.1)
tomlrb (1.3.0)
turbo_dev_assets (0.0.2)
twitter (7.0.0)
addressable (~> 2.3)
Expand Down Expand Up @@ -808,7 +809,7 @@ DEPENDENCIES
capybara (= 3.15.0)
carrierwave (= 1.3.1)
compass-rails (= 3.1.0)
configurate (= 0.3.1)
configurate (= 0.4.0)
coveralls (= 0.8.23)
cucumber-api-steps (= 0.14)
cucumber-rails (= 2.0.0)
Expand Down Expand Up @@ -928,6 +929,7 @@ DEPENDENCIES
sprockets-rails (= 3.2.1)
string-direction (= 1.2.2)
timecop (= 0.9.1)
tomlrb (= 1.3.0)
turbo_dev_assets (= 0.0.2)
twitter (= 7.0.0)
twitter-text (= 3.0.0)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/helpers/locations.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
app.helpers.locations = {
getTiles: function() {
// If the mapbox option is enabled in the diaspora.yml, the mapbox tiles with the podmin's credentials are used.
// If the mapbox option is enabled in the diaspora.toml, the mapbox tiles with the podmin's credentials are used.
if (gon.appConfig.map.mapbox.enabled) {
return L.tileLayer("https://api.mapbox.com/styles/v1/{style}/tiles/256/{z}/{x}/{y}?access_token={accessToken}", {
accessToken: gon.appConfig.map.mapbox.access_token,
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/podmin.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
= t(".configure_your_pod")
!= t(".configuration_info",
database_path: content_tag(:code, "config/database.yml"),
diaspora_path: content_tag(:code, "config/diaspora.yml"))
diaspora_path: content_tag(:code, "config/diaspora.toml"))

.col-md-4
.landing-info-card
Expand Down
18 changes: 12 additions & 6 deletions config/bundler_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@
module BundlerHelper
def self.rails_env
@rails_env ||= ENV["RAILS_ENV"] ||
parse_value_from_file("diaspora.yml", "configuration", "server", "rails_environment") ||
parse_value_from_file("defaults.yml", "defaults", "server", "rails_environment")
parse_value_from_toml_file("diaspora.toml", "rails_environment") ||
parse_value_from_yaml_file("diaspora.yml", "configuration", "server", "rails_environment") ||
parse_value_from_yaml_file("defaults.yml", "defaults", "server", "rails_environment")
end

def self.database
@adapter ||= parse_value_from_file("database.yml", rails_env, "adapter")
@adapter ||= parse_value_from_yaml_file("database.yml", rails_env, "adapter")

raise "No database adapter found, please fix your config/database.yml!" unless @adapter

@adapter.sub("mysql2", "mysql")
end

private_class_method def self.parse_value_from_file(file, *keys)
private_class_method def self.parse_value_from_yaml_file(file, *keys)
path = File.join(__dir__, file)
return YAML.load_file(path).dig(*keys) if File.file?(path)
YAML.load_file(path).dig(*keys) if File.file?(path)
end

private_class_method def self.parse_value_from_toml_file(file, key)
path = File.join(__dir__, file)
return File.read(path)[/^\s*#{Regexp.escape(key)}\s*=\s*["']([^"']+)["']\s*$/, 1] if File.file?(path)

puts "Configuration file #{path} not found, ensure it's present" # rubocop:disable Rails/Output
puts "WARNING: Configuration file #{path} not found, ensure it's present" # rubocop:disable Rails/Output
end
end

0 comments on commit 7cfd461

Please sign in to comment.