Skip to content

Commit

Permalink
Roughed in admin area
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpigford committed May 14, 2024
1 parent 062782d commit a998080
Show file tree
Hide file tree
Showing 27 changed files with 513 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ gem "faraday"
gem "jbuilder"
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem "redcarpet"
gem "avo", ">= 3.2"
gem "revise_auth"


group :development, :test do
gem "debug", platforms: %i[ mri windows ]
Expand All @@ -45,4 +48,4 @@ group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
end
end
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,30 @@ GIT
GEM
remote: https://rubygems.org/
specs:
active_link_to (1.0.5)
actionpack
addressable
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
avo (3.7.4)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
activesupport (>= 6.1)
addressable
docile
dry-initializer
httparty
inline_svg
meta-tags
pagy (>= 7.0.0)
turbo-rails (>= 2.0.0)
turbo_power (>= 0.6.0)
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
base64 (0.2.0)
bcrypt (3.1.20)
better_html (2.1.1)
actionview (>= 6.0)
activesupport (>= 6.0)
Expand All @@ -134,15 +154,18 @@ GEM
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
csv (3.3.0)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
docile (1.4.0)
dotenv (3.1.0)
dotenv-rails (3.1.0)
dotenv (= 3.1.0)
railties (>= 6.1)
drb (2.2.1)
dry-initializer (3.1.1)
erb_lint (0.5.0)
activesupport
better_html (>= 2.0.1)
Expand All @@ -162,12 +185,19 @@ GEM
actioncable (>= 6.0.0)
listen (>= 3.0.0)
railties (>= 6.0.0)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
inline_svg (1.9.0)
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.7.2)
irb (1.13.0)
rdoc (>= 4.0.0)
Expand All @@ -190,9 +220,14 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
meta-tags (2.21.0)
actionpack (>= 6.0.0, < 7.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.21.2)
msgpack (1.7.2)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
net-http (0.4.1)
uri
net-imap (0.4.10)
Expand All @@ -217,6 +252,7 @@ GEM
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
pagy (8.4.0)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
Expand Down Expand Up @@ -264,6 +300,9 @@ GEM
regexp_parser (2.9.0)
reline (0.5.5)
io-console (~> 0.5)
revise_auth (0.6.0)
bcrypt (~> 3.1)
rails (>= 7.1.0.beta1)
rexml (3.2.6)
rubocop (1.63.3)
json (~> 2.3)
Expand Down Expand Up @@ -331,11 +370,17 @@ GEM
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.1)
turbo-rails (>= 1.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
useragent (0.16.10)
view_component (3.12.1)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -359,6 +404,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
avo (>= 3.2)
bootsnap
brakeman
capybara
Expand All @@ -376,6 +422,7 @@ DEPENDENCIES
rails!
redcarpet
redis (>= 4.0.1)
revise_auth
rubocop-rails-omakase
ruby-lsp-rails
selenium-webdriver
Expand Down
15 changes: 15 additions & 0 deletions app/avo/resources/article.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Avo::Resources::Article < Avo::BaseResource
self.includes = []
# self.search = {
# query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) }
# }

def fields
field :id, as: :id
field :title, as: :text
field :slug, as: :text
field :content, as: :textarea
field :publish_at, as: :date_time
field :author_name, as: :text
end
end
20 changes: 20 additions & 0 deletions app/avo/resources/term.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Avo::Resources::Term < Avo::BaseResource
self.includes = []
# self.search = {
# query: -> { query.ransack(id_eq: params[:q], m: "or").result(distinct: false) }
# }

def fields
field :id, as: :id
field :name, as: :text
field :title, as: :text
field :content, as: :textarea
field :slug, as: :text
field :video_id, as: :text
field :video_title, as: :text
field :video_description, as: :textarea
field :video_thumbnail_url, as: :text
field :video_upload_date, as: :date
field :video_duration, as: :text
end
end
4 changes: 4 additions & 0 deletions app/controllers/avo/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This controller has been generated to enable Rails' resource routes.
# More information on https://docs.avohq.io/3.0/controllers.html
class Avo::ArticlesController < Avo::ResourcesController
end
4 changes: 4 additions & 0 deletions app/controllers/avo/terms_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This controller has been generated to enable Rails' resource routes.
# More information on https://docs.avohq.io/3.0/controllers.html
class Avo::TermsController < Avo::ResourcesController
end
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class User < ApplicationRecord
include ReviseAuth::Model
end
7 changes: 7 additions & 0 deletions app/views/revise_auth/mailer/confirm_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p><%=t ".welcome", email: @user.unconfirmed_email %></p>

<p><%=t ".confirm_below" %></p>

<p><%= link_to t(".confirm"), profile_email_url(confirmation_token: @token) %></p>

<p><%=t ".expiration_notice" %></p>
5 changes: 5 additions & 0 deletions app/views/revise_auth/mailer/password_reset.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p><%=t ".reset_password_below" %></p>

<p><%= link_to t(".reset_password"), edit_password_reset_url(token: @token) %></p>

<p><%=t ".expiration_notice" %></p>
25 changes: 25 additions & 0 deletions app/views/revise_auth/password_resets/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h1><%=t ".reset_password" %></h1>

<%= form_with model: @user, url: password_reset_path do |form| %>
<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>

<div>
<%= form.label :password %>
<%= form.password_field :password, required: true %>
</div>

<div>
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, required: true %>
</div>

<div>
<%= form.button t(".reset_password") %>
</div>
<% end %>
22 changes: 22 additions & 0 deletions app/views/revise_auth/password_resets/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h1><%=t ".send_password_reset_instructions" %></h1>

<%= form_with model: @user, url: password_resets_path do |form| %>
<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>

<div>
<%= form.label :email %>
<%= form.email_field :email, required: true, autofocus: true %>
</div>

<div>
<%= form.button t(".send_password_reset_instructions") %>
</div>
<% end %>

<%= render "revise_auth/shared/links" %>
71 changes: 71 additions & 0 deletions app/views/revise_auth/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<h1><%=t ".profile" %></h1>

<%= form_with model: current_user, url: profile_email_path do |form| %>
<fieldset>
<legend><%=t ".change_email_address" %></legend>

<% if current_user.unconfirmed_email? %>
<p><%=t ".waiting_confirmation", email: current_user.unconfirmed_email %></p>
<% end %>

<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>

<p><%=t ".current_email_address", email: current_user.email %></p>
<p><%=t ".confirmation_instructions" %></p>

<div>
<%= form.label :unconfirmed_email, t(".new_email") %>
<%= form.email_field :unconfirmed_email, required: true %>
</div>

<div>
<%= form.button t(".save") %>
</div>
</fieldset>
<% end %>

<%= form_with model: current_user, url: profile_password_path do |form| %>
<fieldset>
<legend><%=t ".change_password" %></legend>

<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<% end %>

<div>
<%= form.label :password_challenge %>
<%= form.password_field :password_challenge, required: true %>
</div>

<div>
<%= form.label :password, t(".new_password") %>
<%= form.password_field :password, required: true %>
</div>

<div>
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, required: true %>
</div>

<div>
<%= form.button t(".save") %>
</div>
</fieldset>
<% end %>

<%= form_with url: profile_path, method: :delete do |form| %>
<fieldset>
<legend><%=t ".delete_account" %></legend>
<%= form.button t(".delete_account"), data: { turbo_confirm: t(".confirm") } %>
</fieldset>
<% end %>
32 changes: 32 additions & 0 deletions app/views/revise_auth/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<h1><%=t ".sign_up" %></h1>

<%= form_with model: @user, url: sign_up_path do |form| %>
<% if form.object.errors.any? %>
<ul>
<% form.object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
<% end %>

</ul>
<div>
<%= form.label :email %>
<%= form.email_field :email, required: true, autofocus: true %>
</div>

<div>
<%= form.label :password %>
<%= form.password_field :password, required: true %>
</div>

<div>
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, required: true %>
</div>

<div>
<%= form.button t(".sign_up") %>
</div>
<% end %>

<%= render "revise_auth/shared/links" %>
19 changes: 19 additions & 0 deletions app/views/revise_auth/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1><%=t ".log_in" %></h1>

<%= form_with url: login_path do |form| %>
<div>
<%= form.label :email %>
<%= form.email_field :email, required: true, autofocus: true %>
</div>

<div>
<%= form.label :password %>
<%= form.password_field :password, required: true %>
</div>

<div>
<%= form.button t(".log_in") %>
</div>
<% end %>

<%= render "revise_auth/shared/links" %>
Loading

0 comments on commit a998080

Please sign in to comment.