moduler 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/builds/moduler/tailwind.css +852 -2
- data/app/assets/javascripts/moduler/controllers/wysiwyg_controller.js +126 -0
- data/app/assets/javascripts/moduler/vendor/marked.esm.js +77 -0
- data/app/components/moduler/form/file_component.html.erb +14 -0
- data/app/components/moduler/form/file_component.rb +11 -0
- data/app/components/moduler/form/select_component.html.erb +1 -1
- data/app/components/moduler/form/textarea_component.html.erb +14 -0
- data/app/components/moduler/form/textarea_component.rb +11 -0
- data/app/components/moduler/form/wysiwyg_component.html.erb +30 -0
- data/app/components/moduler/form/wysiwyg_component.rb +62 -0
- data/app/controllers/concerns/moduler/authentication.rb +1 -1
- data/app/controllers/concerns/moduler/require_document_acceptance.rb +31 -0
- data/app/controllers/moduler/administration/application_controller.rb +2 -0
- data/app/controllers/moduler/administration/articles_controller.rb +57 -0
- data/app/controllers/moduler/administration/documents_controller.rb +56 -0
- data/app/controllers/moduler/administration/users_controller.rb +2 -2
- data/app/controllers/moduler/application_controller.rb +1 -0
- data/app/controllers/moduler/articles_controller.rb +16 -0
- data/app/controllers/moduler/document_acceptances_controller.rb +25 -0
- data/app/controllers/moduler/profile/sessions/revocation_controller.rb +2 -0
- data/app/controllers/moduler/profile/sessions_controller.rb +2 -0
- data/app/controllers/moduler/profile_controller.rb +2 -0
- data/app/controllers/moduler/sessions_controller.rb +15 -6
- data/app/controllers/moduler/users_controller.rb +1 -0
- data/app/models/moduler/article.rb +25 -0
- data/app/models/moduler/document.rb +17 -0
- data/app/models/moduler/user.rb +8 -0
- data/app/models/moduler/user_document.rb +8 -0
- data/app/policies/moduler/administration/article_policy.rb +29 -0
- data/app/policies/moduler/administration/document_policy.rb +25 -0
- data/app/services/moduler/document_acceptance.rb +43 -0
- data/app/views/layouts/moduler/articles.html.erb +18 -0
- data/app/views/moduler/administration/articles/_article.html.erb +13 -0
- data/app/views/moduler/administration/articles/_form.html.erb +18 -0
- data/app/views/moduler/administration/articles/edit.html.erb +1 -0
- data/app/views/moduler/administration/articles/index.html.erb +13 -0
- data/app/views/moduler/administration/articles/new.html.erb +1 -0
- data/app/views/moduler/administration/documents/_document.html.erb +19 -0
- data/app/views/moduler/administration/documents/_form.html.erb +23 -0
- data/app/views/moduler/administration/documents/edit.html.erb +1 -0
- data/app/views/moduler/administration/documents/index.html.erb +13 -0
- data/app/views/moduler/administration/documents/new.html.erb +1 -0
- data/app/views/moduler/administration/users/edit.html.erb +1 -0
- data/app/views/moduler/administration/users/new.html.erb +1 -0
- data/app/views/moduler/articles/_article.html.erb +16 -0
- data/app/views/moduler/articles/index.html.erb +15 -0
- data/app/views/moduler/articles/show.html.erb +21 -0
- data/app/views/moduler/common/_sidebar.html.erb +3 -2
- data/app/views/moduler/common/administration/_sidebar.html.erb +7 -0
- data/app/views/moduler/common/profile/_sidebar.html.erb +6 -0
- data/app/views/moduler/document_acceptances/new.html.erb +36 -0
- data/app/views/moduler/home/index.html.erb +6 -0
- data/app/views/moduler/profile/edit.html.erb +1 -1
- data/app/views/moduler/profile/sessions/index.html.erb +1 -1
- data/config/importmap.rb +2 -0
- data/config/locales/moduler/administration/articles/en.yml +37 -0
- data/config/locales/moduler/administration/documents/en.yml +35 -0
- data/config/locales/moduler/administration/users/en.yml +6 -0
- data/config/locales/moduler/articles/en.yml +13 -0
- data/config/locales/moduler/common/en.yml +12 -4
- data/config/locales/moduler/components/en.yml +16 -0
- data/config/locales/moduler/document_acceptances/en.yml +17 -0
- data/config/locales/moduler/sessions/en.yml +1 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20261026203827_create_moduler_articles.rb +15 -0
- data/db/migrate/20261104120000_add_status_to_moduler_users.rb +6 -0
- data/db/migrate/20261104205837_create_moduler_documents.rb +10 -0
- data/db/migrate/20261104205950_create_moduler_user_documents.rb +12 -0
- data/lib/moduler/version.rb +1 -1
- data/lib/moduler.rb +3 -0
- metadata +73 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
class ArticlesController < ApplicationController
|
|
3
|
+
layout "moduler/articles"
|
|
4
|
+
|
|
5
|
+
allow_unauthenticated_access
|
|
6
|
+
skip_document_acceptance
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@articles = Article.order(created_at: :desc).page(params[:page])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def show
|
|
13
|
+
@article = Article.find_by!(path: params[:path])
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
class DocumentAcceptancesController < ApplicationController
|
|
3
|
+
skip_document_acceptance
|
|
4
|
+
|
|
5
|
+
before_action :set_document_acceptance
|
|
6
|
+
|
|
7
|
+
def new; end
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
if @document_acceptance.call
|
|
11
|
+
redirect_to moduler.root_path, notice: t(".notice")
|
|
12
|
+
else
|
|
13
|
+
flash.now[:alert] = @document_acceptance.errors.full_messages.to_sentence
|
|
14
|
+
|
|
15
|
+
render :new, status: :unprocessable_entity
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def set_document_acceptance
|
|
22
|
+
@document_acceptance = DocumentAcceptance.new(Current.user, params.dig(:document_acceptance, :document_ids))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module Moduler
|
|
2
2
|
class SessionsController < ApplicationController
|
|
3
3
|
allow_unauthenticated_access only: %i[ new create ]
|
|
4
|
+
skip_document_acceptance
|
|
4
5
|
|
|
5
6
|
rate_limit to: 10, within: 3.minutes, only: :create,
|
|
6
7
|
with: -> { redirect_to moduler.new_session_path, alert: t("moduler.sessions.create.rate_limited") }
|
|
@@ -18,16 +19,14 @@ module Moduler
|
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def create
|
|
21
|
-
|
|
22
|
+
user = User.authenticate_by(params.require(:user).permit(:email_address, :password))
|
|
23
|
+
|
|
24
|
+
if user&.active?
|
|
22
25
|
start_new_session_for user
|
|
23
26
|
|
|
24
27
|
redirect_to after_authentication_url
|
|
25
28
|
else
|
|
26
|
-
|
|
27
|
-
user.errors.add(:base, t("moduler.sessions.create.invalid_credentials"))
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
render :new
|
|
29
|
+
render_sign_in_error(user ? "inactive_account" : "invalid_credentials")
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
|
|
@@ -35,5 +34,15 @@ module Moduler
|
|
|
35
34
|
terminate_session
|
|
36
35
|
redirect_to moduler.new_session_path, status: :see_other
|
|
37
36
|
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def render_sign_in_error(key)
|
|
41
|
+
@user = User.new.tap do |user|
|
|
42
|
+
user.errors.add(:base, t("moduler.sessions.create.#{key}"))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
render :new
|
|
46
|
+
end
|
|
38
47
|
end
|
|
39
48
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module Moduler
|
|
2
2
|
class UsersController < ApplicationController
|
|
3
3
|
allow_unauthenticated_access only: %i[ new create ]
|
|
4
|
+
skip_document_acceptance
|
|
4
5
|
|
|
5
6
|
rate_limit to: 10, within: 3.minutes, only: :create,
|
|
6
7
|
with: -> { redirect_to moduler.new_user_path, alert: t("moduler.users.create.rate_limited") }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
class Article < ApplicationRecord
|
|
3
|
+
include PgSearch::Model
|
|
4
|
+
|
|
5
|
+
PATH_FORMAT = /\A[a-z0-9]+(-[a-z0-9]+)*\z/
|
|
6
|
+
ALLOWED_TAGS = Rails::HTML5::SafeListSanitizer.allowed_tags + %w[ table thead tbody tr th td ]
|
|
7
|
+
|
|
8
|
+
has_many_attached :images
|
|
9
|
+
|
|
10
|
+
validates :path, presence: true, uniqueness: true, format: { with: PATH_FORMAT }
|
|
11
|
+
validates :title, presence: true
|
|
12
|
+
validates :description, presence: true
|
|
13
|
+
validates :keywords, presence: true
|
|
14
|
+
validates :content, presence: true
|
|
15
|
+
validates :images, content_type: %w[ image/png image/jpeg image/gif image/webp ], size: { less_than: 10.megabytes }
|
|
16
|
+
|
|
17
|
+
pg_search_scope :search_by_query, against: %i[ title keywords ], using: { trigram: { word_similarity: true } }
|
|
18
|
+
|
|
19
|
+
def to_html
|
|
20
|
+
html = Redcarpet::Markdown.new(Redcarpet::Render::HTML, tables: true, fenced_code_blocks: true).render(content.to_s)
|
|
21
|
+
|
|
22
|
+
ActionController::Base.helpers.sanitize(html, tags: ALLOWED_TAGS)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
class Document < ApplicationRecord
|
|
3
|
+
include PgSearch::Model
|
|
4
|
+
|
|
5
|
+
KINDS = %w[ privacy_policy terms_and_conditions data_processing_agreement ].freeze
|
|
6
|
+
|
|
7
|
+
has_many :user_documents, class_name: "Moduler::UserDocument", foreign_key: "moduler_document_id", dependent: :delete_all
|
|
8
|
+
|
|
9
|
+
has_one_attached :file
|
|
10
|
+
|
|
11
|
+
validates :name, presence: true
|
|
12
|
+
validates :kind, presence: true, inclusion: { in: KINDS }
|
|
13
|
+
validates :file, presence: true, content_type: %w[ application/pdf ], size: { less_than: 10.megabytes }
|
|
14
|
+
|
|
15
|
+
pg_search_scope :search_by_query, against: %i[ name kind ], using: { trigram: { word_similarity: true } }
|
|
16
|
+
end
|
|
17
|
+
end
|
data/app/models/moduler/user.rb
CHANGED
|
@@ -3,6 +3,8 @@ module Moduler
|
|
|
3
3
|
include PgSearch::Model
|
|
4
4
|
|
|
5
5
|
has_many :sessions, class_name: "Moduler::Session", foreign_key: "moduler_user_id", dependent: :destroy
|
|
6
|
+
has_many :user_documents, class_name: "Moduler::UserDocument", foreign_key: "moduler_user_id", dependent: :destroy
|
|
7
|
+
has_many :documents, class_name: "Moduler::Document", through: :user_documents
|
|
6
8
|
|
|
7
9
|
has_secure_password
|
|
8
10
|
|
|
@@ -12,7 +14,13 @@ module Moduler
|
|
|
12
14
|
validates :password, length: { minimum: 8 }, allow_nil: true
|
|
13
15
|
|
|
14
16
|
enum :role, { member: 0, administrator: 1 }
|
|
17
|
+
enum :status, { waitlisted: 0, active: 1, inactive: 2 }, default: :active
|
|
15
18
|
|
|
16
19
|
pg_search_scope :search_by_query, against: %i[ email_address ], using: { trigram: { word_similarity: true } }
|
|
20
|
+
|
|
21
|
+
# Documents the user has not accepted yet.
|
|
22
|
+
def pending_documents
|
|
23
|
+
Moduler::Document.where.not(id: user_documents.select(:moduler_document_id))
|
|
24
|
+
end
|
|
17
25
|
end
|
|
18
26
|
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
class UserDocument < ApplicationRecord
|
|
3
|
+
belongs_to :user, class_name: "Moduler::User", foreign_key: "moduler_user_id"
|
|
4
|
+
belongs_to :document, class_name: "Moduler::Document", foreign_key: "moduler_document_id"
|
|
5
|
+
|
|
6
|
+
validates :user, presence: true, uniqueness: { scope: :moduler_document_id }
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
module Administration
|
|
3
|
+
class ArticlePolicy < BasePolicy
|
|
4
|
+
def index?
|
|
5
|
+
administrator?
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create?
|
|
9
|
+
administrator?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def update?
|
|
13
|
+
administrator?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def new?
|
|
17
|
+
create?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def edit?
|
|
21
|
+
update?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def destroy?
|
|
25
|
+
administrator?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
module Administration
|
|
3
|
+
class DocumentPolicy < BasePolicy
|
|
4
|
+
def index?
|
|
5
|
+
administrator?
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create?
|
|
9
|
+
administrator?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def update?
|
|
13
|
+
administrator?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def new?
|
|
17
|
+
create?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def edit?
|
|
21
|
+
update?
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
# Accepts the documents a user has not accepted yet. Every pending document
|
|
3
|
+
# must be among the accepted ids; otherwise nothing is accepted. Ids of
|
|
4
|
+
# unknown or already accepted documents are ignored.
|
|
5
|
+
class DocumentAcceptance
|
|
6
|
+
include ActiveModel::Validations
|
|
7
|
+
|
|
8
|
+
attr_reader :user, :document_ids
|
|
9
|
+
|
|
10
|
+
validate :all_pending_documents_accepted
|
|
11
|
+
|
|
12
|
+
def initialize(user, document_ids = [])
|
|
13
|
+
@user = user
|
|
14
|
+
@document_ids = Array(document_ids).compact_blank.map(&:to_i)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def pending_documents
|
|
18
|
+
@pending_documents ||= user.pending_documents.with_attached_file.order(:created_at).to_a
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def accepted?(document)
|
|
22
|
+
document_ids.include?(document.id)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def call
|
|
26
|
+
return false if invalid?
|
|
27
|
+
|
|
28
|
+
UserDocument.insert_all(rows, unique_by: %i[ moduler_document_id moduler_user_id ])
|
|
29
|
+
|
|
30
|
+
true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def all_pending_documents_accepted
|
|
36
|
+
errors.add(:base, :not_all_accepted) if pending_documents.any? { |document| !accepted?(document) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def rows
|
|
40
|
+
pending_documents.map { |document| { moduler_user_id: user.id, moduler_document_id: document.id } }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= content_for(:title) %></title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<%= csrf_meta_tags %>
|
|
7
|
+
<%= csp_meta_tag %>
|
|
8
|
+
|
|
9
|
+
<%= yield :head %>
|
|
10
|
+
|
|
11
|
+
<%= stylesheet_link_tags_if_exist "moduler/tailwind", "moduler/application", media: "all" %>
|
|
12
|
+
</head>
|
|
13
|
+
<body class="flex min-h-screen flex-col">
|
|
14
|
+
<div class="flex flex-1 flex-col">
|
|
15
|
+
<%= yield %>
|
|
16
|
+
</div>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%= render(Moduler::ListItemComponent.new(article.title, id: dom_id(article))) do |item| %>
|
|
2
|
+
<% item.with_meta do %>
|
|
3
|
+
<%= time_tag article.created_at, t(".created", time: time_ago_in_words(article.created_at)), title: l(article.created_at, format: :long) %>
|
|
4
|
+
<% end %>
|
|
5
|
+
|
|
6
|
+
<% if Moduler::Administration::ArticlePolicy.new(current_user, article).edit? %>
|
|
7
|
+
<% item.with_action do %>
|
|
8
|
+
<%= render(Moduler::ButtonLinkComponent.new(t(".action.edit"), moduler.edit_administration_article_path(article), size: :sm)) %>
|
|
9
|
+
<%= render(Moduler::ButtonComponent.new(t(".action.destroy"), moduler.administration_article_path(article), method: :delete, size: :sm,
|
|
10
|
+
confirm: t(".confirmation.destroy"))) %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%= render(Moduler::Administration::PageComponent.new) do %>
|
|
2
|
+
<%= render(Moduler::PageHeaderComponent.new(t(".title"))) %>
|
|
3
|
+
|
|
4
|
+
<%= form_with model: @article, url: @article.persisted? ? moduler.administration_article_path(@article) : moduler.administration_articles_path, data: { turbo: false }, class: "w-full space-y-6" do |form| %>
|
|
5
|
+
<%= render(::Moduler::Form::BaseErrorComponent.new(form)) %>
|
|
6
|
+
|
|
7
|
+
<div class="max-w-lg space-y-6">
|
|
8
|
+
<%= render(::Moduler::Form::TextComponent.new(form, :title, label: t(".label.title"))) %>
|
|
9
|
+
<%= render(::Moduler::Form::TextComponent.new(form, :path, label: t(".label.path"), description: t(".description.path"))) %>
|
|
10
|
+
<%= render(::Moduler::Form::TextareaComponent.new(form, :description, label: t(".label.description"), description: t(".description.description"))) %>
|
|
11
|
+
<%= render(::Moduler::Form::TextComponent.new(form, :keywords, label: t(".label.keywords"), description: t(".description.keywords"))) %>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<%= render(::Moduler::Form::WysiwygComponent.new(form, :content, label: t(".label.content"))) %>
|
|
15
|
+
|
|
16
|
+
<%= render(::Moduler::Form::SubmitComponent.new(form, text: t(".action.save"))) %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render "form" %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%= render(Moduler::Administration::PageComponent.new) do %>
|
|
2
|
+
<%= render(Moduler::PageHeaderComponent.new(t(".title"), description: t(".description"))) do |header| %>
|
|
3
|
+
<% header.with_action do %>
|
|
4
|
+
<%= render(Moduler::ButtonLinkComponent.new(t(".action.new"), moduler.new_administration_article_path)) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<%= render(Moduler::FilterComponent.new(@filter, moduler.administration_articles_path)) %>
|
|
9
|
+
|
|
10
|
+
<%= render(Moduler::ListComponent.new(@articles, id: "articles", empty: t(".empty"))) do %>
|
|
11
|
+
<%= render partial: "moduler/administration/articles/article", collection: @articles %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render "form" %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%= render(Moduler::ListItemComponent.new(document.name, id: dom_id(document))) do |item| %>
|
|
2
|
+
<% item.with_badge(t("moduler.administration.documents.kinds.#{document.kind}")) %>
|
|
3
|
+
|
|
4
|
+
<% item.with_meta do %>
|
|
5
|
+
<%= time_tag document.created_at, t(".created", time: time_ago_in_words(document.created_at)), title: l(document.created_at, format: :long) %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<% if document.file.attached? %>
|
|
9
|
+
<% item.with_action do %>
|
|
10
|
+
<%= render(Moduler::ButtonLinkComponent.new(t(".action.download"), main_app.rails_blob_path(document.file, disposition: "attachment"), size: :sm)) %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<% if Moduler::Administration::DocumentPolicy.new(current_user, document).edit? %>
|
|
15
|
+
<% item.with_action do %>
|
|
16
|
+
<%= render(Moduler::ButtonLinkComponent.new(t(".action.edit"), moduler.edit_administration_document_path(document), size: :sm)) %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%= render(Moduler::Administration::PageComponent.new) do %>
|
|
2
|
+
<%= render(Moduler::PageHeaderComponent.new(t(".title"))) %>
|
|
3
|
+
|
|
4
|
+
<%= form_with model: @document, url: @document.persisted? ? moduler.administration_document_path(@document) : moduler.administration_documents_path, data: { turbo: false }, class: "w-full space-y-6" do |form| %>
|
|
5
|
+
<%= render(::Moduler::Form::BaseErrorComponent.new(form)) %>
|
|
6
|
+
|
|
7
|
+
<div class="max-w-lg space-y-6">
|
|
8
|
+
<%= render(::Moduler::Form::TextComponent.new(form, :name, label: t(".label.name"))) %>
|
|
9
|
+
<%= render(::Moduler::Form::SelectComponent.new(form, :kind, Moduler::Document::KINDS.map { |kind| [ t("moduler.administration.documents.kinds.#{kind}"), kind ] }, label: t(".label.kind"))) %>
|
|
10
|
+
<% if @document.persisted? %>
|
|
11
|
+
<div class="mt-2">
|
|
12
|
+
<p class="block text-sm text-slate-500"><%= t(".label.file") %></p>
|
|
13
|
+
<p id="document_file" class="mt-2 text-sm text-gray-900"><%= @document.file.attached? ? @document.file.filename : t(".description.no_file") %></p>
|
|
14
|
+
<p class="mt-1 text-xs text-gray-400"><%= t(".description.file_locked") %></p>
|
|
15
|
+
</div>
|
|
16
|
+
<% else %>
|
|
17
|
+
<%= render(::Moduler::Form::FileComponent.new(form, :file, label: t(".label.file"), accept: "application/pdf", description: t(".description.file"))) %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<%= render(::Moduler::Form::SubmitComponent.new(form, text: t(".action.save"))) %>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render "form" %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%= render(Moduler::Administration::PageComponent.new) do %>
|
|
2
|
+
<%= render(Moduler::PageHeaderComponent.new(t(".title"), description: t(".description"))) do |header| %>
|
|
3
|
+
<% header.with_action do %>
|
|
4
|
+
<%= render(Moduler::ButtonLinkComponent.new(t(".action.new"), moduler.new_administration_document_path)) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<%= render(Moduler::FilterComponent.new(@filter, moduler.administration_documents_path)) %>
|
|
9
|
+
|
|
10
|
+
<%= render(Moduler::ListComponent.new(@documents, id: "documents", empty: t(".empty"))) do %>
|
|
11
|
+
<%= render partial: "moduler/administration/documents/document", collection: @documents %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render "form" %>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<%= render(::Moduler::Form::SectionComponent.new(t(".section.data"))) do %>
|
|
8
8
|
<%= render(::Moduler::Form::EmailComponent.new(form, :email_address, label: t(".label.email_address"))) %>
|
|
9
9
|
<%= render(::Moduler::Form::SelectComponent.new(form, :role, Moduler::User.roles.keys.map { |role| [ t("moduler.administration.users.roles.#{role}"), role ] }, label: t(".label.role"))) %>
|
|
10
|
+
<%= render(::Moduler::Form::SelectComponent.new(form, :status, Moduler::User.statuses.keys.map { |status| [ t("moduler.administration.users.statuses.#{status}"), status ] }, label: t(".label.status"))) %>
|
|
10
11
|
<% end %>
|
|
11
12
|
|
|
12
13
|
<%= render(::Moduler::Form::SubmitComponent.new(form, text: t(".action.save"))) %>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<%= render(::Moduler::Form::SectionComponent.new(t(".section.data"))) do %>
|
|
8
8
|
<%= render(::Moduler::Form::EmailComponent.new(form, :email_address, label: t(".label.email_address"))) %>
|
|
9
9
|
<%= render(::Moduler::Form::SelectComponent.new(form, :role, Moduler::User.roles.keys.map { |role| [ t("moduler.administration.users.roles.#{role}"), role ] }, label: t(".label.role"))) %>
|
|
10
|
+
<%= render(::Moduler::Form::SelectComponent.new(form, :status, Moduler::User.statuses.keys.map { |status| [ t("moduler.administration.users.statuses.#{status}"), status ] }, label: t(".label.status"))) %>
|
|
10
11
|
<% end %>
|
|
11
12
|
|
|
12
13
|
<%= render(::Moduler::Form::SectionComponent.new(t(".section.password"), divider: true)) do %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<li id="<%= dom_id(article) %>">
|
|
2
|
+
<article class="group relative">
|
|
3
|
+
<%= time_tag article.created_at, l(article.created_at.to_date, format: :long), class: "text-xs text-slate-400" %>
|
|
4
|
+
|
|
5
|
+
<h2 class="mt-2 text-xl font-semibold tracking-tight text-gray-900 group-hover:text-custom">
|
|
6
|
+
<%= link_to moduler.article_path(article.path) do %>
|
|
7
|
+
<span class="absolute inset-0"></span>
|
|
8
|
+
<%= article.title %>
|
|
9
|
+
<% end %>
|
|
10
|
+
</h2>
|
|
11
|
+
|
|
12
|
+
<p class="mt-2 text-sm/6 text-slate-600"><%= article.description %></p>
|
|
13
|
+
|
|
14
|
+
<p class="mt-3 text-sm font-semibold text-gray-900 group-hover:text-custom"><%= t(".action.show") %> <span aria-hidden="true">→</span></p>
|
|
15
|
+
</article>
|
|
16
|
+
</li>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<main class="mx-auto w-full max-w-3xl flex-1 px-4 pb-4 md:mt-8">
|
|
2
|
+
<%= render(Moduler::PageHeaderComponent.new(t(".title"), description: t(".description"))) %>
|
|
3
|
+
|
|
4
|
+
<% if @articles.any? %>
|
|
5
|
+
<ul id="articles" role="list" class="mt-10 space-y-12">
|
|
6
|
+
<%= render partial: "moduler/articles/article", collection: @articles %>
|
|
7
|
+
</ul>
|
|
8
|
+
|
|
9
|
+
<div class="mt-12 flex justify-end">
|
|
10
|
+
<%= paginate @articles %>
|
|
11
|
+
</div>
|
|
12
|
+
<% else %>
|
|
13
|
+
<p class="mt-10 text-sm text-slate-500"><%= t(".empty") %></p>
|
|
14
|
+
<% end %>
|
|
15
|
+
</main>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% content_for :title, @article.title %>
|
|
2
|
+
<% content_for :head do %>
|
|
3
|
+
<meta name="description" content="<%= @article.description %>">
|
|
4
|
+
<meta name="keywords" content="<%= @article.keywords %>">
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<main class="mx-auto w-full max-w-3xl flex-1 px-4 pb-4 md:mt-8">
|
|
8
|
+
<%= link_to t(".action.index"), moduler.articles_path, class: "text-sm text-slate-500 hover:text-custom" %>
|
|
9
|
+
|
|
10
|
+
<article id="<%= dom_id(@article) %>" class="mt-6">
|
|
11
|
+
<header class="mb-8 border-b border-slate-200 pb-6">
|
|
12
|
+
<h1 class="text-2xl/9 font-bold tracking-tight text-gray-900"><%= @article.title %></h1>
|
|
13
|
+
<p class="mt-2 text-sm text-slate-500"><%= @article.description %></p>
|
|
14
|
+
<p class="mt-2 text-xs text-slate-400"><%= time_tag @article.created_at, l(@article.created_at.to_date, format: :long) %></p>
|
|
15
|
+
</header>
|
|
16
|
+
|
|
17
|
+
<div class="prose prose-slate prose-100 prose-img:w-full prose-img:max-w-5xl">
|
|
18
|
+
<%= @article.to_html %>
|
|
19
|
+
</div>
|
|
20
|
+
</article>
|
|
21
|
+
</main>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<aside class="-mx-4 border-b border-gray-200 px-2 md:mx-0 md:w-1/8 md:shrink-0 md:border-b-0 md:border-r md:px-0">
|
|
2
2
|
<nav class="flex gap-1 overflow-x-auto md:flex-col text-sm p-2">
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
<% Array(Moduler.configuration.dig(:resources)).each do |resource| %>
|
|
4
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.#{resource}"), moduler.url_for([resource.to_sym]), "moduler/#{resource}")) %>
|
|
5
|
+
<% end %>
|
|
5
6
|
</nav>
|
|
6
7
|
</aside>
|
|
@@ -2,5 +2,12 @@
|
|
|
2
2
|
<nav class="flex gap-1 overflow-x-auto md:flex-col text-sm p-2">
|
|
3
3
|
<%= render(Moduler::SidebarActionComponent.new(t(".action.users"), moduler.administration_users_path, "moduler/administration/users")) %>
|
|
4
4
|
<%= render(Moduler::SidebarActionComponent.new(t(".action.sessions"), moduler.administration_sessions_path, "moduler/administration/sessions")) %>
|
|
5
|
+
|
|
6
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.articles"), moduler.administration_articles_path, "moduler/administration/articles")) %>
|
|
7
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.documents"), moduler.administration_documents_path, "moduler/administration/documents")) %>
|
|
8
|
+
|
|
9
|
+
<% Array(Moduler.configuration.dig(:administration, :resources)).each do |resource| %>
|
|
10
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.#{resource}"), moduler.url_for([:administration, resource.to_sym]), "moduler/administration/#{resource}")) %>
|
|
11
|
+
<% end %>
|
|
5
12
|
</nav>
|
|
6
13
|
</aside>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<aside class="-mx-4 border-b border-gray-200 px-2 md:mx-0 md:w-1/8 md:shrink-0 md:border-b-0 md:border-r md:px-0">
|
|
2
|
+
<nav class="flex gap-1 overflow-x-auto md:flex-col text-sm p-2">
|
|
3
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.profile"), moduler.edit_profile_path, "moduler/profile")) %>
|
|
4
|
+
<%= render(Moduler::SidebarActionComponent.new(t(".action.sessions"), moduler.profile_sessions_path, "moduler/profile/sessions")) %>
|
|
5
|
+
</nav>
|
|
6
|
+
</aside>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<main class="mx-auto flex w-full max-w-2xl flex-1 flex-col px-4 py-8">
|
|
2
|
+
<div class="mb-6">
|
|
3
|
+
<h1 class="text-base font-semibold text-gray-900"><%= t(".title") %></h1>
|
|
4
|
+
<p class="mt-1 text-sm text-slate-500"><%= t(".description") %></p>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<%= form_with url: moduler.document_acceptance_path, scope: :document_acceptance, data: { turbo: false }, class: "space-y-6" do |form| %>
|
|
8
|
+
<ul id="documents" class="divide-y divide-gray-200 rounded-md border border-gray-200 bg-white">
|
|
9
|
+
<% @document_acceptance.pending_documents.each do |document| %>
|
|
10
|
+
<li id="<%= dom_id(document) %>" class="flex items-start gap-3 px-4 py-4 sm:px-5">
|
|
11
|
+
<%= check_box_tag "document_acceptance[document_ids][]", document.id, @document_acceptance.accepted?(document),
|
|
12
|
+
id: "document_acceptance_document_#{document.id}", class: "mt-0.5 h-4 w-4 shrink-0 cursor-pointer rounded border-gray-300 accent-custom" %>
|
|
13
|
+
|
|
14
|
+
<div class="min-w-0 flex-1">
|
|
15
|
+
<label for="document_acceptance_document_<%= document.id %>" class="cursor-pointer text-sm text-gray-900">
|
|
16
|
+
<%= t(".accept", name: document.name) %>
|
|
17
|
+
</label>
|
|
18
|
+
<p class="mt-1 text-xs text-slate-400">
|
|
19
|
+
<%= t("moduler.administration.documents.kinds.#{document.kind}") %>
|
|
20
|
+
<% if document.file.attached? %>
|
|
21
|
+
·
|
|
22
|
+
<%= link_to t(".action.read"), main_app.rails_blob_path(document.file, disposition: "inline"), target: "_blank", rel: "noopener", class: "font-semibold text-custom hover:underline" %>
|
|
23
|
+
<% end %>
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
26
|
+
</li>
|
|
27
|
+
<% end %>
|
|
28
|
+
</ul>
|
|
29
|
+
|
|
30
|
+
<% @document_acceptance.errors.full_messages.each do |message| %>
|
|
31
|
+
<p class="text-sm text-red-500"><%= message %></p>
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
34
|
+
<%= render(::Moduler::Form::SubmitComponent.new(form, text: t(".action.submit"))) %>
|
|
35
|
+
<% end %>
|
|
36
|
+
</main>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<main class="mx-auto flex w-full flex-1 max-w-[120rem] flex-col gap-4 px-4 md:flex-row md:gap-8 md:pl-0 md:pr-6">
|
|
2
|
-
<%= render "moduler/common/sidebar" %>
|
|
2
|
+
<%= render "moduler/common/profile/sidebar" %>
|
|
3
3
|
|
|
4
4
|
<div class="flex min-w-0 flex-1 flex-col pb-4 md:mt-8">
|
|
5
5
|
<div class="mb-4 flex min-h-9 items-center justify-between gap-4">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<main class="mx-auto flex w-full flex-1 max-w-[120rem] flex-col gap-4 px-4 md:flex-row md:gap-8 md:pl-0 md:pr-6">
|
|
2
|
-
<%= render "moduler/common/sidebar" %>
|
|
2
|
+
<%= render "moduler/common/profile/sidebar" %>
|
|
3
3
|
|
|
4
4
|
<div class="flex min-w-0 flex-1 flex-col pb-4 md:mt-8">
|
|
5
5
|
<div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
data/config/importmap.rb
CHANGED
|
@@ -3,3 +3,5 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
|
|
3
3
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
|
4
4
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
|
5
5
|
pin_all_from File.expand_path("../app/assets/javascripts/moduler/controllers", __dir__), under: "moduler/controllers"
|
|
6
|
+
pin "marked", to: "moduler/vendor/marked.esm.js"
|
|
7
|
+
pin "@rails/activestorage", to: "activestorage.esm.js"
|