Этот коммит содержится в:
Mattia Roccoberton
2020-09-01 11:12:40 +02:00
родитель 80b5b3d3f3
Коммит b89fc0f939
82 изменённых файлов: 1707 добавлений и 4 удалений

49
spec/dummy/app/admin/authors.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,49 @@
# frozen_string_literal: true
ActiveAdmin.register Author do
menu priority: 1
permit_params :name, :email, :age, :avatar, profile_attributes: %i[id description _destroy]
index do
selectable_column
id_column
column :name
column :email
column :created_at
actions
end
filter :name
filter :created_at
show do
attributes_table do
row :name
row :email
row :age
row :avatar do |record|
image_tag url_for(record.avatar), style: 'max-width:800px;max-height:500px' if record.avatar.attached?
end
row :created_at
row :updated_at
row :profile
end
active_admin_comments
end
form do |f|
f.inputs do
f.input :name
f.input :email
f.input :age
f.input :avatar,
as: :file,
hint: (object.avatar.attached? ? "Current: #{object.avatar.filename}" : nil)
end
f.has_many :profile, allow_destroy: true do |ff|
ff.input :description
end
f.actions
end
end

32
spec/dummy/app/admin/dashboard.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,32 @@
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
content title: proc { I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end
# Here is an example of a simple dashboard with columns and panels.
#
# columns do
# column do
# panel "Recent Posts" do
# ul do
# Post.recent(5).map do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end
# end
# column do
# panel "Info" do
# para "Welcome to ActiveAdmin."
# end
# end
# end
end # content
end

4
spec/dummy/app/admin/posts.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,4 @@
# frozen_string_literal: true
ActiveAdmin.register Post do
end

4
spec/dummy/app/admin/tags.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,4 @@
# frozen_string_literal: true
ActiveAdmin.register Tag do
end

3
spec/dummy/app/assets/config/manifest.js Обычный файл
Просмотреть файл

@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
// OFF link active_storage_db_manifest.js

0
spec/dummy/app/assets/images/.keep Обычный файл
Просмотреть файл

Просмотреть файл

@@ -0,0 +1 @@
//= require active_admin/base

Просмотреть файл

@@ -0,0 +1,17 @@
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// .status_tag { background: #6090DB; }

Просмотреть файл

@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/

Просмотреть файл

@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end

Просмотреть файл

@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end

Просмотреть файл

@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end

0
spec/dummy/app/controllers/concerns/.keep Обычный файл
Просмотреть файл

Просмотреть файл

@@ -0,0 +1,2 @@
module ApplicationHelper
end

Просмотреть файл

@@ -0,0 +1,15 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require_tree .

7
spec/dummy/app/jobs/application_job.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end

Просмотреть файл

@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end

Просмотреть файл

@@ -0,0 +1,7 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
scope :published, -> {}
end

25
spec/dummy/app/models/author.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,25 @@
# frozen_string_literal: true
class Author < ApplicationRecord
has_many :posts
has_many :published_posts, -> { published }, class_name: 'Post'
has_many :recent_posts, -> { recents }, class_name: 'Post'
has_many :tags, through: :posts
has_one :profile, inverse_of: :author, dependent: :destroy
has_one_attached :avatar
accepts_nested_attributes_for :profile, allow_destroy: true
validates :email, format: { with: /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\z/i, message: 'Invalid email' }
validate -> {
errors.add( :base, 'Invalid age' ) if !age || age.to_i % 3 == 1
}
def to_s
"#{name} (#{age})"
end
end

0
spec/dummy/app/models/concerns/.keep Обычный файл
Просмотреть файл

25
spec/dummy/app/models/post.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,25 @@
# frozen_string_literal: true
class Post < ApplicationRecord
enum state: %i[available unavailable arriving]
belongs_to :author, inverse_of: :posts, autosave: true
has_one :author_profile, through: :author, source: :profile
has_many :post_tags, inverse_of: :post, dependent: :destroy
has_many :tags, through: :post_tags
validates :title, allow_blank: false, presence: true
scope :published, -> { where(published: true) }
scope :recents, -> { where('created_at > ?', Date.today - 8.month) }
def short_title
title.truncate 10
end
def upper_title
title.upcase
end
end

9
spec/dummy/app/models/post_tag.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,9 @@
# frozen_string_literal: true
class PostTag < ApplicationRecord
belongs_to :post, inverse_of: :post_tags
belongs_to :tag, inverse_of: :post_tags
validates :post, presence: true
validates :tag, presence: true
end

9
spec/dummy/app/models/profile.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,9 @@
# frozen_string_literal: true
class Profile < ApplicationRecord
belongs_to :author, inverse_of: :profile, touch: true
def to_s
description
end
end

6
spec/dummy/app/models/tag.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,6 @@
# frozen_string_literal: true
class Tag < ApplicationRecord
has_many :post_tags, inverse_of: :tag, dependent: :destroy
has_many :posts, through: :post_tags
end

Просмотреть файл

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all' %>
</head>
<body>
<%= yield %>
</body>
</html>

Просмотреть файл

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<%= yield %>
</body>
</html>

Просмотреть файл

@@ -0,0 +1 @@
<%= yield %>