From 73893c08232707ec5283ed77abfb3494f2526c33 Mon Sep 17 00:00:00 2001 From: Min Khant Kyaw Date: Thu, 11 Sep 2025 00:41:04 +0630 Subject: [PATCH 1/6] Move is_channel_dashboard? to ApplicationHelper The is_channel_dashboard? method was removed from ApplicationController and added to ApplicationHelper. ServerSettingsController now includes ApplicationHelper to access this method. This refactor improves separation of concerns by placing view-related logic in the helper. --- app/controllers/application_controller.rb | 24 +------------------ app/controllers/server_settings_controller.rb | 3 ++- app/helpers/application_helper.rb | 18 ++++++++++++++ 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b3e53f99..b573defb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,6 @@ class ApplicationController < ActionController::Base helper_method :current_account - helper_method :is_channel_dashboard? - rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized require 'httparty' @@ -79,26 +77,6 @@ def truthy_param?(key) end def current_account - return @current_account if defined?(@current_account) - - @current_account = current_user&.account - end - - def is_channel_dashboard? - if Rails.env.development? - return true - end - - mastodon_url = ENV['MASTODON_INSTANCE_URL'] - return false if mastodon_url.nil? - - case mastodon_url - when /channel/ - true - when /staging\.patchwork\.online/ - true - else - false - end + @current_account ||= current_user&.account end end diff --git a/app/controllers/server_settings_controller.rb b/app/controllers/server_settings_controller.rb index c77cc6cf..26aa7a5b 100644 --- a/app/controllers/server_settings_controller.rb +++ b/app/controllers/server_settings_controller.rb @@ -1,7 +1,8 @@ class ServerSettingsController < ApplicationController + include ApplicationHelper + before_action :authorize_master_admin! before_action :set_keyword_filter_group, only: [:index] - def index @server_settings = prepare_server_setting end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d1acbe58..37383805 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -113,4 +113,22 @@ def render_custom_emojis(text) end end.html_safe end + + def is_channel_dashboard? + if Rails.env.development? + return false + end + + mastodon_url = ENV['MASTODON_INSTANCE_URL'] + return false if mastodon_url.nil? + + case mastodon_url + when /channel/ + true + when /staging\.patchwork\.online/ + true + else + false + end + end end From 04ee3a3748a1fe7b63c814bbcd190a6aee1b1e59 Mon Sep 17 00:00:00 2001 From: Min Khant Kyaw Date: Thu, 11 Sep 2025 01:07:58 +0630 Subject: [PATCH 2/6] Simplify domain environment handling in Bluesky bridge services Refactored both ChannelBlueskyBridgeService and NonChannelBlueskyBridgeService to remove redundant environment checks when determining hosted zones and domain names. The logic now consistently appends a period to the LOCAL_DOMAIN environment variable and eliminates unnecessary RAILS_ENV branching, improving maintainability. --- .../channel_bluesky_bridge_service.rb | 27 ++++--------------- .../non_channel_bluesky_bridge_service.rb | 10 +------ 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/app/services/channel_bluesky_bridge_service.rb b/app/services/channel_bluesky_bridge_service.rb index 7186b2a4..6b1e9d87 100644 --- a/app/services/channel_bluesky_bridge_service.rb +++ b/app/services/channel_bluesky_bridge_service.rb @@ -94,16 +94,7 @@ def process_did_value(community, token, account) def create_dns_record(did_value, community) route53 = Aws::Route53::Client.new hosted_zones = route53.list_hosted_zones - - env = ENV.fetch('RAILS_ENV', nil) - channel_zone = case env - when 'staging' - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - when 'production' - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - else - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - end + channel_zone = hosted_zones.hosted_zones.find { |zone| zone.name == "#{ENV['LOCAL_DOMAIN']}." } if channel_zone name = if community&.is_custom_domain? @@ -113,7 +104,7 @@ def create_dns_record(did_value, community) end # Determine the correct domain based on environment and custom domain - domain_name = determine_domain_name(community, env) + domain_name = determine_domain_name(community) name = "_atproto.#{domain_name}" route53.change_resource_record_sets({ @@ -140,8 +131,7 @@ def create_dns_record(did_value, community) end def create_direct_message(token, community) - env = ENV.fetch('RAILS_ENV', nil) - domain_name = determine_domain_name(community, env) + domain_name = determine_domain_name(community) status_params = { "in_reply_to_id": nil, @@ -161,18 +151,11 @@ def handle_relationship(account, target_account_id) AccountRelationshipsService.new.call(account, target_account_id) end - def determine_domain_name(community, env) + def determine_domain_name(community) if community&.is_custom_domain? community&.slug else - case env - when 'staging' - "#{community&.slug}.#{ENV['LOCAL_DOMAIN']}" - when 'production' - "#{community&.slug}.#{ENV['LOCAL_DOMAIN']}" - else - "#{community&.slug}.#{ENV['LOCAL_DOMAIN']}" - end + "#{community&.slug}.#{ENV['LOCAL_DOMAIN']}" end end end diff --git a/app/services/non_channel_bluesky_bridge_service.rb b/app/services/non_channel_bluesky_bridge_service.rb index a2f2d9f9..14bcc436 100644 --- a/app/services/non_channel_bluesky_bridge_service.rb +++ b/app/services/non_channel_bluesky_bridge_service.rb @@ -90,15 +90,7 @@ def create_dns_record(did_value, account) route53 = Aws::Route53::Client.new hosted_zones = route53.list_hosted_zones - env = ENV.fetch('RAILS_ENV', nil) - channel_zone = case env - when 'staging' - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - when 'production' - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - else - hosted_zones.hosted_zones.find { |zone| zone.name == ENV['LOCAL_DOMAIN'] } - end + channel_zone = hosted_zones.hosted_zones.find { |zone| zone.name == "#{ENV['LOCAL_DOMAIN']}." } if channel_zone name = "_atproto.#{account&.username}.#{ENV['LOCAL_DOMAIN']}" From 340ea6e344ba34d26c23447a7fb9db077f91b77d Mon Sep 17 00:00:00 2001 From: NangKhatMang Date: Thu, 11 Sep 2025 12:21:22 +0630 Subject: [PATCH 3/6] edit: homepage mvp --- app/assets/images/icons/folder-open.svg | 4 + app/views/homepage/index.html.haml | 177 ++++++++++++------------ 2 files changed, 93 insertions(+), 88 deletions(-) create mode 100644 app/assets/images/icons/folder-open.svg diff --git a/app/assets/images/icons/folder-open.svg b/app/assets/images/icons/folder-open.svg new file mode 100644 index 00000000..4d713236 --- /dev/null +++ b/app/assets/images/icons/folder-open.svg @@ -0,0 +1,4 @@ + + + + diff --git a/app/views/homepage/index.html.haml b/app/views/homepage/index.html.haml index 35c167c0..063fc687 100644 --- a/app/views/homepage/index.html.haml +++ b/app/views/homepage/index.html.haml @@ -1,5 +1,6 @@ - content_for :title do = 'Homepage' +- title = application_name(0) .row .col-12 @@ -8,7 +9,7 @@ .row.d-flex.align-items-center .col-9 %h2 - Welcome to the Patchwork dashboard + Welcome to the #{title} dashboard %p.text-light Here, you can oversee your server settings enhanced by Patchwork %br @@ -20,91 +21,91 @@ .col-3.position-relative .logo = image_tag("patchwork-logo.svg", class: "large-logo") +- if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + .row.ml-1.d-flex.justify-content-between + .col-4 + .row + .card.small-card + .card-header + %div.d-flex.justify-content-between + %div + %h5.card-title Total server users + %div + = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") + .card-body.mb-1.d-flex.align-items-center.justify-content-between + .col-5.ml-4.d-flex.flex-column.justify-content-center + %h3 18,928 + %p Since 23 July, 2024 + .col-2.d-flex.justify-content-center.align-items-center + = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") + .col-5.d-flex.align-items-center + %h3 31.24% -.row.ml-1.d-flex.justify-content-between - .col-4 - .row + .row + .card.small-card + .card-header + %div.d-flex.justify-content-between + %div + %h5.card-title Visits + %div + = image_tag("icons/eye.svg", class: "mr-2", width: "16", height: "16") + .card-body.d-flex.align-items-center.justify-content-between + .col-5.ml-4 + %h3 201 + %p Every 24 hours + .col-2.d-flex.align-items-center.justify-content-center + = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") + .col-5 + %h3 31.24% + + .col-4 .card.small-card .card-header %div.d-flex.justify-content-between - %div - %h5.card-title Total server users - %div - = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") - .card-body.mb-1.d-flex.align-items-center.justify-content-between - .col-5.ml-4.d-flex.flex-column.justify-content-center - %h3 18,928 - %p Since 23 July, 2024 - .col-2.d-flex.justify-content-center.align-items-center - = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") - .col-5.d-flex.align-items-center - %h3 31.24% + %h5.card-title Most popular channels on this server + = image_tag("icons/chart-line-up.svg", class: "mr-2", width: "16", height: "16") + .card-body.mb-3 + - channels = [["Local channel 1", "10K"], ["Local channel 2", "1.2K"], ["Local channel 3", "1.3K"], ["Local channel 4", "1.4K"], ["Local channel 5", "1.5K"]] + - channels.each do |community, followers| + .d-flex.align-items-center.mb-1 + %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 35px; height: 35px; border: 2px solid white;" } + %div.ml-3 + %div= community + %div.text-muted= "#{followers} Followers" + %div.ml-auto + = image_tag("icons/chevron-right.svg", width: "16", height: "16") - .row + .col-4 .card.small-card .card-header %div.d-flex.justify-content-between %div - %h5.card-title Visits + %h5.card-title Most active contributors %div - = image_tag("icons/eye.svg", class: "mr-2", width: "16", height: "16") - .card-body.d-flex.align-items-center.justify-content-between - .col-5.ml-4 - %h3 201 - %p Every 24 hours - .col-2.d-flex.align-items-center.justify-content-center - = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") - .col-5 - %h3 31.24% - - .col-4 - .card.small-card - .card-header - %div.d-flex.justify-content-between - %h5.card-title Most popular channels on this server - = image_tag("icons/chart-line-up.svg", class: "mr-2", width: "16", height: "16") - .card-body.mb-3 - - channels = [["Local channel 1", "10K"], ["Local channel 2", "1.2K"], ["Local channel 3", "1.3K"], ["Local channel 4", "1.4K"], ["Local channel 5", "1.5K"]] - - channels.each do |community, followers| - .d-flex.align-items-center.mb-1 - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 35px; height: 35px; border: 2px solid white;" } - %div.ml-3 - %div= community - %div.text-muted= "#{followers} Followers" - %div.ml-auto - = image_tag("icons/chevron-right.svg", width: "16", height: "16") - - .col-4 - .card.small-card - .card-header - %div.d-flex.justify-content-between - %div - %h5.card-title Most active contributors - %div - = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") - .card-body - .row.d-flex.justify-content-between.my-2 - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .row.d-flex.justify-content-between.my-4 - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename + = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") + .card-body + .row.d-flex.justify-content-between.my-2 + .col-6 + .d-flex.flex-column.align-items-center + %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } + %div Profile Name + %div.text-muted @profilename + .col-6 + .d-flex.flex-column.align-items-center + %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } + %div Profile Name + %div.text-muted @profilename + .row.d-flex.justify-content-between.my-4 + .col-6 + .d-flex.flex-column.align-items-center + %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } + %div Profile Name + %div.text-muted @profilename + .col-6 + .d-flex.flex-column.align-items-center + %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } + %div Profile Name + %div.text-muted @profilename %div.text-center.my-3 Use our quick actions to get started: @@ -113,32 +114,32 @@ .card.small-card .card-body.d-flex{style: 'flex-direction: column;'} %div.d-flex.justify-content-center.my-2 - = image_tag("icons/setting.svg", width: "20", height: "20") + = image_tag("icons/tool.svg", width: "20", height: "20") %div.d-flex.justify-content-center.my-2 - %h5 Server settings + %h5 Installation %p.text-muted.small.my-2 - Update the settings for your server to ensure content is being moderated correctly and spam filters are in place. + Install Patchwork patches to enable new features and controls. %div.d-grid.gap-2.mt-auto.my-2 - %a.btn.btn-danger.btn-block{ href: server_settings_path } View server settings + %a.btn.btn-danger.btn-block{ href: '/installation' } View installation panel .col-4.d-flex.justify-content-between .card.small-card .card-body.d-flex{style: 'flex-direction: column;'} %div.d-flex.justify-content-center.my-2 - = image_tag("icons/chat.svg", width: "20", height: "20") + = image_tag("icons/setting.svg", width: "20", height: "20") %div.d-flex.justify-content-center.my-2 - %h5 Local channels + %h5 Server settings %p.text-muted.small.my-2 - See a list of all your local channels and easily import, manage or create new channels in one place. + Update the settings for your server to ensure content is being moderated correctly and spam filters are in place. %div.d-grid.gap-2.mt-auto.my-2 - %a.btn.btn-danger.btn-block{ href: communities_path } View all local channels + %a.btn.btn-danger.btn-block{ href: server_settings_path } View server settings .col-4.d-flex.justify-content-between .card.small-card .card-body.d-flex{style: 'flex-direction: column;'} %div.d-flex.justify-content-center.my-2 - = image_tag("icons/tool.svg", width: "20", height: "20") + = image_tag("icons/folder-open.svg", width: "20", height: "20") %div.d-flex.justify-content-center.my-2 - %h5 Installation + %h5 Resources %p.text-muted.small.my-2 - Install Patchwork patches to enable new features and controls. + Documentation, specifications and source code for Patchwork. %div.d-grid.gap-2.mt-auto.my-2 - %a.btn.btn-danger.btn-block{ href: '/installation' } View installation panel + %a.btn.btn-danger.btn-block{ href: resources_path } View resources From 767e01b0709388fd2099aab17db05774fdc2b1d3 Mon Sep 17 00:00:00 2001 From: NangKhatMang Date: Thu, 11 Sep 2025 12:25:52 +0630 Subject: [PATCH 4/6] code refactor: sidebar menu --- app/helpers/application_helper.rb | 54 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d1acbe58..150f96a7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,30 +14,44 @@ def sidebar_menu_items newsmast_active = params[:channel_type] == 'newsmast' || @community&.newsmast? ? 'communities' : nil if master_admin? - [ + links = [ { path: '/homepage', id: 'homepage-link', header: 'Homepage', icon: 'home.svg', text: 'Home', active_if: 'homepage' }, { path: server_settings_path, id: 'server-settings-link', header: 'Server settings', icon: 'sliders.svg', text: 'Server settings', active_if: ['server_settings', 'keyword_filter_groups', 'keyword_filters'] }, - { path: '/installation', id: 'installation-link', header: 'Installation', icon: 'screwdriver-wrench.svg', text: 'Installation', active_if: 'installation' }, - { path: communities_path(channel_type: 'channel'), id: 'communities-link', header: 'Communities', icon: 'speech.svg', text: 'Communities', active_if: channel_active }, - { path: communities_path(channel_type: 'channel_feed'), id: 'communities-link', header: 'Channels', icon: 'channel-feed.svg', text: 'Channels', active_if: channel_feed_active }, - { path: communities_path(channel_type: 'hub'), id: 'communities-link', header: 'Hubs', icon: 'hub.svg', text: 'Hubs', active_if: hub_active }, - { path: communities_path(channel_type: 'newsmast'), id: 'communities-link', header: 'Newsmast channels', icon: 'newsmast.svg', text: 'Newsmast channels', active_if: newsmast_active }, - { path: collections_path, id: 'collections-link', header: 'Collections', icon: 'collection.svg', text: 'Collections', active_if: 'collections' }, - { path: master_admins_path, id: 'master_admins-link', header: 'Master admin', icon: 'administrator.svg', text: 'Master admins', active_if: 'master_admins' }, - { path: community_filter_keywords_path(community_id: nil), id: 'global_filters-link', header: 'Global filters', icon: 'globe-white.svg', text: 'Global filters', active_if: 'global_filters' }, + { path: '/installation', id: 'installation-link', header: 'Installation', icon: 'screwdriver-wrench.svg', text: 'Installation', active_if: 'installation' } + ] + + if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + links += [ + { path: communities_path(channel_type: 'channel'), id: 'communities-link', header: 'Communities', icon: 'speech.svg', text: 'Communities', active_if: channel_active }, + { path: communities_path(channel_type: 'channel_feed'), id: 'communities-link', header: 'Channels', icon: 'channel-feed.svg', text: 'Channels', active_if: channel_feed_active }, + { path: communities_path(channel_type: 'hub'), id: 'communities-link', header: 'Hubs', icon: 'hub.svg', text: 'Hubs', active_if: hub_active }, + { path: communities_path(channel_type: 'newsmast'), id: 'communities-link', header: 'Newsmast channels', icon: 'newsmast.svg', text: 'Newsmast channels', active_if: newsmast_active }, + { path: collections_path, id: 'collections-link', header: 'Collections', icon: 'collection.svg', text: 'Collections', active_if: 'collections' } + ] + end + links << { path: master_admins_path, id: 'master_admins-link', header: 'Master admin', icon: 'administrator.svg', text: 'Master admins', active_if: 'master_admins' } + + if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + links << { path: community_filter_keywords_path(community_id: nil), id: 'global_filters-link', header: 'Global filters', icon: 'globe-white.svg', text: 'Global filters', active_if: 'global_filters' } + end + links += [ # { path: accounts_path, id: 'accounts-link', header: 'Users', icon: 'users.svg', text: 'Users', active_if: 'accounts' }, { path: resources_path, id: 'resources-link', header: 'Resources', icon: 'folder.svg', text: 'Resources', active_if: 'resources' }, - { path: api_keys_path, id: 'resources-link', header: 'API Key', icon: 'key.svg', text: 'API Key', active_if: 'api_keys' }, - { path: wait_lists_path, id: 'invitation-codes-link', header: 'Invitation codes', icon: 'invitation_code.svg', text: 'Invitation codes', active_if: 'wait_lists' }, - { path: app_versions_path(app_name: AppVersion.app_names['patchwork']), id: 'app-versions-link', header: 'App versions', icon: 'sliders.svg', text: 'App versions', active_if: 'app_versions' }, - *( - if ["patchwork.io", "mo-me.social", "newsmast.social"].any? { |domain| ENV['MASTODON_INSTANCE_URL']&.include?(domain) } - [ - { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/dashboard", id: 'administration-link', header: 'Administration', icon: 'administrator.svg', text: 'Administration', target: '_blank' }, - { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/reports", id: 'moderation-link', header: 'Moderation', icon: 'users.svg', text: 'Moderation', target: '_blank' }, - ] - end - ), + { path: api_keys_path, id: 'resources-link', header: 'API Key', icon: 'key.svg', text: 'API Key', active_if: 'api_keys' } + ] + + if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + links << { path: wait_lists_path, id: 'invitation-codes-link', header: 'Invitation codes', icon: 'invitation_code.svg', text: 'Invitation codes', active_if: 'wait_lists' } + end + links << { path: app_versions_path(app_name: AppVersion.app_names['patchwork']), id: 'app-versions-link', header: 'App versions', icon: 'sliders.svg', text: 'App versions', active_if: 'app_versions' } + + unless ENV['MASTODON_INSTANCE_URL']&.include?('channel') + links += [ + { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/dashboard", id: 'administration-link', header: 'Administration', icon: 'administrator.svg', text: 'Administration', target: '_blank' }, + { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/reports", id: 'moderation-link', header: 'Moderation', icon: 'users.svg', text: 'Moderation', target: '_blank' } + ] + end + links += [ { path: "/sidekiq", id: 'sidekiq-link', header: 'Sidekiq', icon: 'smile-1.svg', text: 'Sidekiq', target: '_blank' }, { path: '#', id: 'help-support-link', header: 'Help & Support', icon: 'question.svg', text: 'Help & Support', active_if: 'help_support' } ] From 239fa117bd1baf32870bce12ee7623bbf593523a Mon Sep 17 00:00:00 2001 From: NangKhatMang Date: Thu, 11 Sep 2025 15:08:22 +0630 Subject: [PATCH 5/6] remove block (Total server users, Visits...) --- app/views/homepage/index.html.haml | 85 ------------------------------ 1 file changed, 85 deletions(-) diff --git a/app/views/homepage/index.html.haml b/app/views/homepage/index.html.haml index 063fc687..bd182051 100644 --- a/app/views/homepage/index.html.haml +++ b/app/views/homepage/index.html.haml @@ -21,91 +21,6 @@ .col-3.position-relative .logo = image_tag("patchwork-logo.svg", class: "large-logo") -- if ENV['MASTODON_INSTANCE_URL']&.include?('channel') - .row.ml-1.d-flex.justify-content-between - .col-4 - .row - .card.small-card - .card-header - %div.d-flex.justify-content-between - %div - %h5.card-title Total server users - %div - = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") - .card-body.mb-1.d-flex.align-items-center.justify-content-between - .col-5.ml-4.d-flex.flex-column.justify-content-center - %h3 18,928 - %p Since 23 July, 2024 - .col-2.d-flex.justify-content-center.align-items-center - = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") - .col-5.d-flex.align-items-center - %h3 31.24% - - .row - .card.small-card - .card-header - %div.d-flex.justify-content-between - %div - %h5.card-title Visits - %div - = image_tag("icons/eye.svg", class: "mr-2", width: "16", height: "16") - .card-body.d-flex.align-items-center.justify-content-between - .col-5.ml-4 - %h3 201 - %p Every 24 hours - .col-2.d-flex.align-items-center.justify-content-center - = image_tag("icons/circle-up.svg", class: "mr-2", width: "16", height: "16") - .col-5 - %h3 31.24% - - .col-4 - .card.small-card - .card-header - %div.d-flex.justify-content-between - %h5.card-title Most popular channels on this server - = image_tag("icons/chart-line-up.svg", class: "mr-2", width: "16", height: "16") - .card-body.mb-3 - - channels = [["Local channel 1", "10K"], ["Local channel 2", "1.2K"], ["Local channel 3", "1.3K"], ["Local channel 4", "1.4K"], ["Local channel 5", "1.5K"]] - - channels.each do |community, followers| - .d-flex.align-items-center.mb-1 - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 35px; height: 35px; border: 2px solid white;" } - %div.ml-3 - %div= community - %div.text-muted= "#{followers} Followers" - %div.ml-auto - = image_tag("icons/chevron-right.svg", width: "16", height: "16") - - .col-4 - .card.small-card - .card-header - %div.d-flex.justify-content-between - %div - %h5.card-title Most active contributors - %div - = image_tag("icons/users-black.svg", class: "mr-2", width: "16", height: "16") - .card-body - .row.d-flex.justify-content-between.my-2 - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .row.d-flex.justify-content-between.my-4 - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename - .col-6 - .d-flex.flex-column.align-items-center - %img{ alt: "profile picture", src: asset_path('patchwork-logo.svg'), class: "rounded-circle", style: "width: 60px; height: 60px; border: 2px solid white;" } - %div Profile Name - %div.text-muted @profilename %div.text-center.my-3 Use our quick actions to get started: From d2ec0a0a5828dd096b791e899ca4531702239d39 Mon Sep 17 00:00:00 2001 From: NangKhatMang Date: Thu, 11 Sep 2025 15:48:58 +0630 Subject: [PATCH 6/6] edit: use is_channel_dashboard --- app/helpers/application_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 07fb30df..c48dfce0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -20,7 +20,7 @@ def sidebar_menu_items { path: '/installation', id: 'installation-link', header: 'Installation', icon: 'screwdriver-wrench.svg', text: 'Installation', active_if: 'installation' } ] - if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + if is_channel_dashboard? links += [ { path: communities_path(channel_type: 'channel'), id: 'communities-link', header: 'Communities', icon: 'speech.svg', text: 'Communities', active_if: channel_active }, { path: communities_path(channel_type: 'channel_feed'), id: 'communities-link', header: 'Channels', icon: 'channel-feed.svg', text: 'Channels', active_if: channel_feed_active }, @@ -31,7 +31,7 @@ def sidebar_menu_items end links << { path: master_admins_path, id: 'master_admins-link', header: 'Master admin', icon: 'administrator.svg', text: 'Master admins', active_if: 'master_admins' } - if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + if is_channel_dashboard? links << { path: community_filter_keywords_path(community_id: nil), id: 'global_filters-link', header: 'Global filters', icon: 'globe-white.svg', text: 'Global filters', active_if: 'global_filters' } end links += [ @@ -40,12 +40,12 @@ def sidebar_menu_items { path: api_keys_path, id: 'resources-link', header: 'API Key', icon: 'key.svg', text: 'API Key', active_if: 'api_keys' } ] - if ENV['MASTODON_INSTANCE_URL']&.include?('channel') + if is_channel_dashboard? links << { path: wait_lists_path, id: 'invitation-codes-link', header: 'Invitation codes', icon: 'invitation_code.svg', text: 'Invitation codes', active_if: 'wait_lists' } end links << { path: app_versions_path(app_name: AppVersion.app_names['patchwork']), id: 'app-versions-link', header: 'App versions', icon: 'sliders.svg', text: 'App versions', active_if: 'app_versions' } - unless ENV['MASTODON_INSTANCE_URL']&.include?('channel') + unless is_channel_dashboard? links += [ { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/dashboard", id: 'administration-link', header: 'Administration', icon: 'administrator.svg', text: 'Administration', target: '_blank' }, { path: "#{ENV['MASTODON_INSTANCE_URL']}/admin/reports", id: 'moderation-link', header: 'Moderation', icon: 'users.svg', text: 'Moderation', target: '_blank' }