Browse Source

Add extended about page stub

closed-social-glitch-2
Eugen Rochko 7 years ago
parent
commit
e25170f960
10 changed files with 44 additions and 15 deletions
  1. +6
    -0
      app/controllers/about_controller.rb
  2. +4
    -2
      app/lib/settings/extend.rb
  3. +3
    -1
      app/lib/settings/scoped_settings.rb
  4. +1
    -0
      app/models/account.rb
  5. +2
    -3
      app/models/setting.rb
  6. +2
    -0
      app/models/web.rb
  7. +8
    -0
      app/views/about/more.html.haml
  8. +13
    -5
      app/views/admin/settings/index.html.haml
  9. +4
    -3
      config/routes.rb
  10. +1
    -1
      config/settings.yml

+ 6
- 0
app/controllers/about_controller.rb View File

@ -7,6 +7,12 @@ class AboutController < ApplicationController
@description = Setting.site_description
end
def more
@extended_description = Setting.site_extended_description
@contact_account = Account.find_local(Setting.site_contact_username)
@contact_email = Setting.site_contact_email
end
def terms; end
private

+ 4
- 2
app/lib/settings/extend.rb View File

@ -1,9 +1,11 @@
# frozen_string_literal: true
module Settings
module Extend
extend ActiveSupport::Concern
extend ActiveSupport::Concern
def settings
ScopedSettings.for_thing(self)
end
end
end
end

+ 3
- 1
app/lib/settings/scoped_settings.rb View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Settings
class ScopedSettings < ::Setting
def self.for_thing(object)
@ -9,4 +11,4 @@ module Settings
unscoped.where(thing_type: @object.class.base_class.to_s, thing_id: @object.id)
end
end
end
end

+ 1
- 0
app/models/account.rb View File

@ -159,6 +159,7 @@ class Account < ApplicationRecord
end
def find_remote!(username, domain)
return if username.blank?
where(arel_table[:username].matches(username.gsub(/[%_]/, '\\\\\0'))).where(domain.nil? ? { domain: nil } : arel_table[:domain].matches(domain.gsub(/[%_]/, '\\\\\0'))).take!
end

+ 2
- 3
app/models/setting.rb View File

@ -9,10 +9,9 @@ class Setting < RailsSettings::Base
end
class << self
def [](key)
return super(key) unless rails_initialized?
val = Rails.cache.fetch(cache_key(key, @object)) do
db_val = object(key)
@ -25,7 +24,7 @@ class Setting < RailsSettings::Base
default_settings[key]
end
end
val
end

+ 2
- 0
app/models/web.rb View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Web
def self.table_name_prefix
'web_'

+ 8
- 0
app/views/about/more.html.haml View File

@ -0,0 +1,8 @@
- content_for :page_title do
#{Rails.configuration.x.local_domain}
.wrapper
= @extended_description.html_safe
- if @contact_account
= render partial: 'authorize_follow/card', locals: { account: @contact_account }

+ 13
- 5
app/views/admin/settings/index.html.haml View File

@ -9,6 +9,12 @@
%th Setting
%th Click to edit
%tbody
%tr
%td{ rowspan: 2 }
%strong Contact information
%td= best_in_place @settings['site_contact_username'], :value, url: admin_setting_path(@settings['site_contact_username']), place_holder: 'Enter a username'
%tr
%td= best_in_place @settings['site_contact_email'], :value, url: admin_setting_path(@settings['site_contact_email']), place_holder: 'Enter a public e-mail address'
%tr
%td
%strong Site description
@ -21,8 +27,10 @@
%code= '<em>'
%td= best_in_place @settings['site_description'], :value, as: :textarea, url: admin_setting_path(@settings['site_description'])
%tr
%td{ rowspan: 2 }
%strong Contact information
%td= best_in_place @settings['site_contact_username'], :value, url: admin_setting_path(@settings['site_contact_username']), place_holder: 'Enter a username'
%tr
%td= best_in_place @settings['site_contact_email'], :value, url: admin_setting_path(@settings['site_contact_email']), place_holder: 'Enter a public e-mail address'
%td
%strong Extended site description
%br/
Displayed on extended information page
%br/
You can use HTML tags
%td= best_in_place @settings['site_extended_description'], :value, as: :textarea, url: admin_setting_path(@settings['site_extended_description'])

+ 4
- 3
config/routes.rb View File

@ -143,9 +143,10 @@ Rails.application.routes.draw do
get '/web/(*any)', to: 'home#index', as: :web
get :about, to: 'about#index'
get :terms, to: 'about#terms'
get '/about', to: 'about#index'
get '/about/more', to: 'about#more'
get '/terms', to: 'about#terms'
root 'home#index'
match '*unmatched_route', via: :all, to: 'application#raise_not_found'

+ 1
- 1
config/settings.yml View File

@ -1,6 +1,7 @@
# config/app.yml for rails-settings-cached
defaults: &defaults
site_description: ''
site_extended_description: ''
site_contact_username: ''
site_contact_email: ''
notification_emails:
@ -12,7 +13,6 @@ defaults: &defaults
interactions:
must_be_follower: false
must_be_following: false
development:
<<: *defaults

Loading…
Cancel
Save