diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-07-30 16:35:53 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-07-30 16:36:24 -0500 |
commit | ccb84572d6300c0ed69a59653b98ced89582452a (patch) | |
tree | 23609bf14d544836f7ef5177f70a52719ae53592 | |
parent | 3f327a3ea75e0c635b88418e5b92454873815f9d (diff) |
add a domain policy viewer at `/policies`
-rw-r--r-- | app/controllers/domain_policy_controller.rb | 30 | ||||
-rw-r--r-- | app/helpers/domain_policy_helper.rb | 2 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/styles/monsterpit.about.scss | 15 | ||||
-rw-r--r-- | app/views/domain_blocks/_domain_block.html.haml | 14 | ||||
-rw-r--r-- | app/views/domain_policy/show.html.haml | 58 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | spec/controllers/domain_policy_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/helpers/domain_policy_helper_spec.rb | 15 | ||||
-rw-r--r-- | spec/views/domain_policy/show.html.haml_spec.rb | 5 |
9 files changed, 153 insertions, 0 deletions
diff --git a/app/controllers/domain_policy_controller.rb b/app/controllers/domain_policy_controller.rb new file mode 100644 index 000000000..28e676f5e --- /dev/null +++ b/app/controllers/domain_policy_controller.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class DomainPolicyController < ApplicationController + before_action :authenticate_user! + + before_action :set_pack + layout 'public' + + before_action :set_instance_presenter, only: [:show] + + def show + @hide_navbar = true + @domain_policies = DomainBlock.all + end + + private + + def set_pack + use_pack 'common' + end + + def set_instance_presenter + @instance_presenter = InstancePresenter.new + end + + def authenticate_user! + return if user_signed_in? + not_found + end +end diff --git a/app/helpers/domain_policy_helper.rb b/app/helpers/domain_policy_helper.rb new file mode 100644 index 000000000..27ebe7c2a --- /dev/null +++ b/app/helpers/domain_policy_helper.rb @@ -0,0 +1,2 @@ +module DomainPolicyHelper +end diff --git a/app/javascript/flavours/glitch/styles/monsterpit.about.scss b/app/javascript/flavours/glitch/styles/monsterpit.about.scss index ddbaab9b3..e6c108d03 100644 --- a/app/javascript/flavours/glitch/styles/monsterpit.about.scss +++ b/app/javascript/flavours/glitch/styles/monsterpit.about.scss @@ -1 +1,16 @@ .landing .box-widget { text-align: center; } +.rich-formatting td { + ul { + list-style: none; + margin: 0; + + li { + margin: 0; + padding: 0; + line-height: 18px; + } + + li:after { content: "," } + li:last-child:after { content: "" } + } +} diff --git a/app/views/domain_blocks/_domain_block.html.haml b/app/views/domain_blocks/_domain_block.html.haml new file mode 100644 index 000000000..fae707c82 --- /dev/null +++ b/app/views/domain_blocks/_domain_block.html.haml @@ -0,0 +1,14 @@ +%tr + %td + %samp= domain_block.domain + %td= domain_block.severity.gsub('_', ' ').capitalize + %td + %ul + -if domain_block.reject_media? + %li= "Rejecting media" + -if domain_block.force_sensitive? + %li= "Media marked sensitive" + -if domain_block.reject_reports? + %li= "Rejecting reports" + %td= "None" + diff --git a/app/views/domain_policy/show.html.haml b/app/views/domain_policy/show.html.haml new file mode 100644 index 000000000..4b4b121fd --- /dev/null +++ b/app/views/domain_policy/show.html.haml @@ -0,0 +1,58 @@ +- content_for :page_title do + = "#{site_hostname} Domain Policies" + +- content_for :header_tags do + = render partial: 'shared/og' + +.grid-3 + .column-0 + .public-account-header.public-account-header--no-bar + .public-account-header__image + = image_tag @instance_presenter.hero&.file&.url || @instance_presenter.thumbnail&.file&.url || asset_pack_path('media/images/preview.jpg'), alt: @instance_presenter.site_title, class: 'parallax' + + .column-1 + .landing-page__call-to-action{ dir: 'ltr' } + .row + .row__information-board + .information-board__section + %span= t 'about.user_count_before' + %strong= number_with_delimiter @instance_presenter.user_count + %span= t 'about.user_count_after', count: @instance_presenter.user_count + .information-board__section + %span= t 'about.status_count_before' + %strong= number_with_delimiter @instance_presenter.status_count + %span= t 'about.status_count_after', count: @instance_presenter.status_count + .row__mascot + .landing-page__mascot + = image_tag @instance_presenter.mascot&.file&.url || asset_pack_path('media/images/elephant_ui_plane.svg'), alt: '' + + .column-2 + .landing-page__information.contact-widget + %p + %strong= t 'about.administered_by' + + = account_link_to(@instance_presenter.contact_account) + + - if @instance_presenter.site_contact_email.present? + %p.contact-widget__mail + %strong + = succeed ':' do + = t 'about.contact' + %br/ + = mail_to @instance_presenter.site_contact_email, nil, title: @instance_presenter.site_contact_email + + .column-3 + .box-widget + .rich-formatting + %h1= "#{@instance_presenter.site_title} Domain Policies" + + .table-wrapper + %table.table + %thead + %tr + %th= "Domain" + %th= "Policy" + %th= "Additional" + %th= "Reason" + %tbody + = render @domain_policies diff --git a/config/routes.rb b/config/routes.rb index 08236a5a6..5f4e5e7f8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -419,6 +419,8 @@ Rails.application.routes.draw do get '/about/more', to: 'about#more' get '/terms', to: 'about#terms' + get '/policies', to: 'domain_policy#show' + root 'home#index' match '*unmatched_route', diff --git a/spec/controllers/domain_policy_controller_spec.rb b/spec/controllers/domain_policy_controller_spec.rb new file mode 100644 index 000000000..8214f4fac --- /dev/null +++ b/spec/controllers/domain_policy_controller_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +RSpec.describe DomainPolicyController, type: :controller do + + describe "GET #show" do + it "returns http success" do + get :show + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/helpers/domain_policy_helper_spec.rb b/spec/helpers/domain_policy_helper_spec.rb new file mode 100644 index 000000000..45ade9a3b --- /dev/null +++ b/spec/helpers/domain_policy_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the DomainPolicyHelper. For example: +# +# describe DomainPolicyHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe DomainPolicyHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/domain_policy/show.html.haml_spec.rb b/spec/views/domain_policy/show.html.haml_spec.rb new file mode 100644 index 000000000..67b21486f --- /dev/null +++ b/spec/views/domain_policy/show.html.haml_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "domain_policy/show.html.haml", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end |