8 Commits

Author SHA1 Message Date
Râu Cao
6739b38f4c 0.8.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-01 12:18:26 +02:00
7e1272c936 Merge pull request 'Service pages for Chat and Social' (#143) from feature/service_pages into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #143
Reviewed-by: galfert <garret.alfert@gmail.com>
2023-09-01 08:36:09 +00:00
Râu Cao
ecdeb4c122 Fix copypasta
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Release Drafter / Update release notes draft (pull_request) Successful in 3s
2023-09-01 10:32:11 +02:00
Râu Cao
8614e2f12b Use service configs on dashboard
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Only show enabled services, and use the URLs from the various configs.
2023-08-13 17:24:10 +02:00
Râu Cao
a038a857d9 Make Drone CI configurable 2023-08-13 17:23:57 +02:00
Râu Cao
eee81d0cf1 Small link improvement
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-08-13 15:41:57 +02:00
Râu Cao
b7fa4b012a Allow Mastodon address domain to be different from primary domain
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-08-13 12:27:05 +02:00
Râu Cao
10bcd5c32b Ignore .env.development 2023-08-13 12:26:56 +02:00
12 changed files with 177 additions and 82 deletions

View File

@@ -22,6 +22,8 @@ WEBHOOKS_ALLOWED_IPS='10.1.1.163'
DISCOURSE_PUBLIC_URL='https://community.kosmos.org' DISCOURSE_PUBLIC_URL='https://community.kosmos.org'
DISCOURSE_CONNECT_SECRET='discourse_connect_ftw' DISCOURSE_CONNECT_SECRET='discourse_connect_ftw'
DRONECI_PUBLIC_URL='https://drone.kosmos.org'
GITEA_PUBLIC_URL='https://gitea.kosmos.org' GITEA_PUBLIC_URL='https://gitea.kosmos.org'
MASTODON_PUBLIC_URL='https://kosmos.social' MASTODON_PUBLIC_URL='https://kosmos.social'
MEDIAWIKI_PUBLIC_URL='https://wiki.kosmos.org' MEDIAWIKI_PUBLIC_URL='https://wiki.kosmos.org'

1
.gitignore vendored
View File

@@ -39,6 +39,7 @@ yarn-debug.log*
# Ignore local dotenv config file # Ignore local dotenv config file
.env .env
.env.development
# Ignore redis dumps from sidekiq # Ignore redis dumps from sidekiq
dump.rdb dump.rdb

View File

@@ -9,6 +9,6 @@ class Services::MastodonController < Services::BaseController
private private
def require_service_available def require_service_available
http_status :not_found unless Setting.ejabberd_enabled? http_status :not_found unless Setting.mastodon_enabled?
end end
end end

View File

@@ -51,6 +51,16 @@ class Setting < RailsSettings::Base
field :discourse_connect_secret, type: :string, field :discourse_connect_secret, type: :string,
default: ENV["DISCOURSE_CONNECT_SECRET"].presence default: ENV["DISCOURSE_CONNECT_SECRET"].presence
#
# Drone CI
#
field :droneci_public_url, type: :string,
default: ENV["DRONECI_PUBLIC_URL"].presence
field :droneci_enabled, type: :boolean,
default: (ENV["DRONECI_PUBLIC_URL"].present?.to_s || false)
# #
# ejabberd # ejabberd
# #
@@ -106,6 +116,9 @@ class Setting < RailsSettings::Base
field :mastodon_enabled, type: :boolean, field :mastodon_enabled, type: :boolean,
default: (ENV["MASTODON_PUBLIC_URL"].present?.to_s || false) default: (ENV["MASTODON_PUBLIC_URL"].present?.to_s || false)
field :mastodon_address_domain, type: :string,
default: ENV["MASTODON_ADDRESS_DOMAIN"].presence || self.primary_domain
# #
# MediaWiki # MediaWiki
# #

View File

@@ -110,6 +110,11 @@ class User < ApplicationRecord
"#{self.cn}@#{self.ou}" "#{self.cn}@#{self.ou}"
end end
def mastodon_address
return nil unless Setting.mastodon_enabled?
"#{self.cn}@#{Setting.mastodon_address_domain}"
end
def valid_attribute?(attribute_name) def valid_attribute?(attribute_name)
self.valid? self.valid?
self.errors[attribute_name].blank? self.errors[attribute_name].blank?

View File

@@ -0,0 +1,16 @@
<h3>Drone CI</h3>
<ul role="list">
<%= render FormElements::FieldsetToggleComponent.new(
form: f,
attribute: :droneci_enabled,
enabled: Setting.droneci_enabled?,
title: "Enable Drone CI integration",
description: "Drone CI configuration present and features enabled"
) %>
<% if Setting.droneci_enabled? %>
<%= render FormElements::FieldsetResettableSettingComponent.new(
key: :droneci_public_url,
title: "Public URL"
) %>
<% end %>
</ul>

View File

@@ -12,5 +12,9 @@
key: :mastodon_public_url, key: :mastodon_public_url,
title: "Public URL" title: "Public URL"
) %> ) %>
<%= render FormElements::FieldsetResettableSettingComponent.new(
key: :mastodon_address_domain,
title: "User address domain"
) %>
<% end %> <% end %>
</ul> </ul>

View File

@@ -7,6 +7,7 @@
services: services:
</p> </p>
<div class="services grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6"> <div class="services grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6">
<% if Setting.ejabberd_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400 <div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-[center_top_-50px] bg-no-repeat bg-cover bg-[center_top_-50px] bg-no-repeat
bg-[url(/img/logos/icon_xmpp.svg)]"> bg-[url(/img/logos/icon_xmpp.svg)]">
@@ -18,6 +19,20 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<% end %>
<% if Setting.mastodon_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400
bg-[length:80%] bg-[right_top_-30px] bg-no-repeat
bg-[url(/img/logos/icon_mastodon.svg)]">
<%= link_to services_mastodon_path, class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Mastodon</h3>
<p class="text-gray-600">
Your account on the Open Social Web
</p>
<% end %>
</div>
<% end %>
<% if Setting.discourse_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400 <div class="border border-gray-300 rounded-md hover:border-gray-400
bg-[length:95%] bg-center bg-no-repeat bg-[length:95%] bg-center bg-no-repeat
bg-[url(/img/logos/icon_discourse.svg)]"> bg-[url(/img/logos/icon_discourse.svg)]">
@@ -29,17 +44,8 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-[center_top_-20px] bg-no-repeat
bg-[url(/img/logos/icon_mediawiki.svg)]">
<%= link_to "https://wiki.kosmos.org",
class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Wiki</h3>
<p class="text-gray-600">
Kosmos documentation and knowledge base
</p>
<% end %> <% end %>
</div> <% if Setting.lndhub_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400 <div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-center sm:bg-[center_top_-140px] bg-no-repeat bg-cover bg-center sm:bg-[center_top_-140px] bg-no-repeat
bg-[url(/img/logos/icon_lightning.svg)]"> bg-[url(/img/logos/icon_lightning.svg)]">
@@ -51,10 +57,12 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<% end %>
<% if Setting.gitea_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400 <div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-center bg-no-repeat bg-cover bg-center bg-no-repeat
bg-[url(/img/logos/icon_gitea.png)]"> bg-[url(/img/logos/icon_gitea.png)]">
<%= link_to "https://gitea.kosmos.org", <%= link_to Setting.gitea_public_url,
class: "block h-full px-6 py-6 rounded-md" do %> class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Gitea</h3> <h3 class="mb-3.5">Gitea</h3>
<p class="text-gray-600"> <p class="text-gray-600">
@@ -62,10 +70,12 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<% end %>
<% if Setting.droneci_enabled? %>
<div class="border border-gray-300 rounded-md hover:border-gray-400 <div class="border border-gray-300 rounded-md hover:border-gray-400
bg-cover bg-[center_top_-70px] bg-no-repeat bg-cover bg-[center_top_-70px] bg-no-repeat
bg-[url(/img/logos/icon_droneci.svg)]"> bg-[url(/img/logos/icon_droneci.svg)]">
<%= link_to "https://drone.kosmos.org", <%= link_to Setting.droneci_public_url,
class: "block h-full px-6 py-6 rounded-md" do %> class: "block h-full px-6 py-6 rounded-md" do %>
<h3 class="mb-3.5">Drone CI</h3> <h3 class="mb-3.5">Drone CI</h3>
<p class="text-gray-600"> <p class="text-gray-600">
@@ -73,7 +83,9 @@
</p> </p>
<% end %> <% end %>
</div> </div>
<% if Setting.remotestorage_enabled? && Flipper.enabled?(:remotestorage, current_user) %> <% end %>
<% if Setting.remotestorage_enabled? &&
Flipper.enabled?(:remotestorage, current_user) %>
<div class="border border-gray-300 rounded-md hover:border-gray-400"> <div class="border border-gray-300 rounded-md hover:border-gray-400">
<%= link_to services_storage_path, <%= link_to services_storage_path,
class: "block h-full px-6 py-6 rounded-md" do %> class: "block h-full px-6 py-6 rounded-md" do %>
@@ -84,16 +96,19 @@
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<!-- <div class="border border&#45;gray&#45;300 rounded&#45;md hover:border&#45;gray&#45;400 --> <% if Setting.mediawiki_enabled? %>
<!-- bg&#45;[length:80%] bg&#45;[right_top_&#45;30px] bg&#45;no&#45;repeat --> <div class="border border-gray-300 rounded-md hover:border-gray-400
<!-- bg&#45;[url(/img/logos/icon_mastodon.svg)]"> --> bg-cover bg-[center_top_-20px] bg-no-repeat
<!-- <%= link_to "https://kosmos.social", class: "block h&#45;full px&#45;6 py&#45;6 rounded&#45;md" do %> --> bg-[url(/img/logos/icon_mediawiki.svg)]">
<!-- <h3 class="mb&#45;3.5">Mastodon</h3> --> <%= link_to Setting.mediawiki_public_url,
<!-- <p class="text&#45;gray&#45;400"> --> class: "block h-full px-6 py-6 rounded-md" do %>
<!-- Your account on the Open Social Web --> <h3 class="mb-3.5">Wiki</h3>
<!-- </p> --> <p class="text-gray-600">
<!-- <% end %> --> Kosmos documentation and knowledge base
<!-- </div> --> </p>
<% end %>
</div>
<% end %>
</div> </div>
</section> </section>
<% end %> <% end %>

View File

@@ -13,7 +13,7 @@
</p> </p>
<p data-controller="clipboard" class="flex gap-1 sm:w-2/5"> <p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
<input type="text" id="user_address" class="grow" <input type="text" id="user_address" class="grow"
value=<%= current_user.address %> disabled="disabled" value=<%= current_user.mastodon_address %> disabled="disabled"
data-clipboard-target="source" /> data-clipboard-target="source" />
<button id="copy-user-address" class="btn-md btn-icon btn-outline shrink-0" <button id="copy-user-address" class="btn-md btn-icon btn-outline shrink-0"
data-clipboard-target="trigger" data-action="clipboard#copy" data-clipboard-target="trigger" data-action="clipboard#copy"
@@ -36,8 +36,8 @@
<h3>Social Apps</h3> <h3>Social Apps</h3>
<p> <p>
Use your Mastodon account with many different apps, and on any devices Use your Mastodon account with many different apps, and on any devices
you wish! When adding your account to an app, you will log in via <a you wish! When adding your account to an app, you will log in via
href="https://kosmos.social">kosmos.social</a>. <a href="https://kosmos.social" target="_blank" class="ks-text-link">kosmos.social</a>.
</p> </p>
</section> </section>
<section> <section>

View File

@@ -5,6 +5,13 @@
icon: Setting.discourse_enabled? ? "check" : "x", icon: Setting.discourse_enabled? ? "check" : "x",
active: current_page?(admin_settings_services_path(params: { s: "discourse" })), active: current_page?(admin_settings_services_path(params: { s: "discourse" })),
) %> ) %>
<%= render SidenavLinkComponent.new(
level: 2,
name: "Drone CI",
path: admin_settings_services_path(params: { s: "droneci" }),
icon: Setting.droneci_enabled? ? "check" : "x",
active: current_page?(admin_settings_services_path(params: { s: "droneci" })),
) %>
<%= render SidenavLinkComponent.new( <%= render SidenavLinkComponent.new(
level: 2, level: 2,
name: "ejabberd", name: "ejabberd",

View File

@@ -11,7 +11,7 @@
"postcss-preset-env": "^7.8.3", "postcss-preset-env": "^7.8.3",
"tailwindcss": "^3.2.4" "tailwindcss": "^3.2.4"
}, },
"version": "0.7.0", "version": "0.8.0",
"scripts": { "scripts": {
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css", "build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
"build:css": "yarn run build:css:tailwind" "build:css": "yarn run build:css:tailwind"

View File

@@ -12,6 +12,38 @@ RSpec.describe User, type: :model do
end end
end end
describe "#mastodon_address" do
let(:user) { build :user, cn: "jimmy", ou: "kosmos.org" }
context "Mastodon service not configured" do
it "returns nil" do
expect(user.mastodon_address).to be_nil
end
end
context "Mastodon service configured" do
before do
Setting.mastodon_enabled = true
end
describe "domain is the same as primary domain" do
it "returns the user address" do
expect(user.mastodon_address).to eq("jimmy@kosmos.org")
end
end
describe "domain is different from primary domain" do
before do
Setting.mastodon_address_domain = "kosmos.social"
end
it "returns the user address" do
expect(user.mastodon_address).to eq("jimmy@kosmos.social")
end
end
end
end
describe "#is_admin?" do describe "#is_admin?" do
it "returns true when admin flag is set in LDAP" do it "returns true when admin flag is set in LDAP" do
expect(Devise::LDAP::Adapter).to receive(:get_ldap_param) expect(Devise::LDAP::Adapter).to receive(:get_ldap_param)