poder customizar el sitio
This commit is contained in:
parent
4ad1339a60
commit
abc02aef8b
11 changed files with 109 additions and 1 deletions
2
Gemfile
2
Gemfile
|
@ -29,7 +29,9 @@ gem 'ssh_data'
|
|||
|
||||
gem 'anomaly_detection'
|
||||
|
||||
gem 'bootstrap'
|
||||
gem 'rails-i18n'
|
||||
gem 'hamlit'
|
||||
|
||||
group :development, :test do
|
||||
gem 'pry'
|
||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -63,6 +63,8 @@ GEM
|
|||
anomaly_detection (0.1.4-x86_64-linux-musl)
|
||||
rice (>= 4.0.2)
|
||||
ast (2.4.2)
|
||||
autoprefixer-rails (10.4.2.0)
|
||||
execjs (~> 2)
|
||||
bcrypt (3.1.17-x86_64-linux-musl)
|
||||
bindex (0.8.1-x86_64-linux-musl)
|
||||
blazer (2.6.3)
|
||||
|
@ -72,6 +74,10 @@ GEM
|
|||
safely_block (>= 0.1.1)
|
||||
bootsnap (1.11.1-x86_64-linux-musl)
|
||||
msgpack (~> 1.2)
|
||||
bootstrap (5.1.3)
|
||||
autoprefixer-rails (>= 9.1.0)
|
||||
popper_js (>= 2.9.3, < 3)
|
||||
sassc-rails (>= 2.0.0)
|
||||
brakeman (5.2.3)
|
||||
builder (3.2.4)
|
||||
chartkick (4.1.3)
|
||||
|
@ -97,11 +103,16 @@ GEM
|
|||
exception_notification (4.5.0)
|
||||
actionmailer (>= 5.2, < 8)
|
||||
activesupport (>= 5.2, < 8)
|
||||
execjs (2.8.1)
|
||||
factory_bot (6.2.1)
|
||||
activesupport (>= 5.0.0)
|
||||
ffi (1.15.5-x86_64-linux-musl)
|
||||
globalid (1.0.0)
|
||||
activesupport (>= 5.0)
|
||||
hamlit (2.16.0-x86_64-linux-musl)
|
||||
temple (>= 0.8.2)
|
||||
thor
|
||||
tilt
|
||||
i18n (1.10.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.11.5)
|
||||
|
@ -135,6 +146,7 @@ GEM
|
|||
parser (3.1.2.0)
|
||||
ast (~> 2.4.1)
|
||||
pg (1.3.5-x86_64-linux-musl)
|
||||
popper_js (2.9.3)
|
||||
pry (0.14.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
|
@ -224,6 +236,7 @@ GEM
|
|||
activesupport (>= 5.2)
|
||||
sprockets (>= 3.0.0)
|
||||
ssh_data (1.3.0)
|
||||
temple (0.8.2)
|
||||
thor (1.2.1)
|
||||
tilt (2.0.10)
|
||||
turbolinks (5.2.1)
|
||||
|
@ -257,12 +270,14 @@ DEPENDENCIES
|
|||
anomaly_detection
|
||||
blazer
|
||||
bootsnap (>= 1.4.4)
|
||||
bootstrap
|
||||
brakeman
|
||||
database_cleaner
|
||||
devise
|
||||
devise-i18n
|
||||
exception_notification
|
||||
factory_bot
|
||||
hamlit
|
||||
jbuilder (~> 2.7)
|
||||
listen (~> 3.3)
|
||||
lograge
|
||||
|
|
1
app/assets/stylesheets/main.scss
Normal file
1
app/assets/stylesheets/main.scss
Normal file
|
@ -0,0 +1 @@
|
|||
@import "bootstrap";
|
30
app/controllers/sites_controller.rb
Normal file
30
app/controllers/sites_controller.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Gestionar el sitio
|
||||
class SitesController < ApplicationController
|
||||
def show
|
||||
site
|
||||
end
|
||||
|
||||
def create
|
||||
site.update(site_params)
|
||||
|
||||
redirect_to site_path(site)
|
||||
end
|
||||
|
||||
def update
|
||||
site.update(site_params)
|
||||
|
||||
redirect_to site_path(site)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def site
|
||||
@site ||= Site.first || Site.new
|
||||
end
|
||||
|
||||
def site_params
|
||||
@site_params ||= params.require(:site).permit(:title, :logo)
|
||||
end
|
||||
end
|
6
app/models/site.rb
Normal file
6
app/models/site.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Site < ApplicationRecord
|
||||
has_one_attached :logo
|
||||
validates_presence_of :title
|
||||
end
|
|
@ -25,6 +25,7 @@
|
|||
<li role="separator" class="divider"></li>
|
||||
<li><%= link_to t('.new_dashboard'), new_dashboard_path %></li>
|
||||
<li><%= link_to t('.new_check'), new_check_path %></li>
|
||||
<li><%= link_to t('.site'), Rails.application.routes.url_helpers.site_path(Site.first || Site.new) %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@ require "rails"
|
|||
require "active_model/railtie"
|
||||
require "active_job/railtie"
|
||||
require "active_record/railtie"
|
||||
# require "active_storage/engine"
|
||||
require "active_storage/engine"
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
# require "action_mailbox/engine"
|
||||
|
@ -31,5 +31,6 @@ module Ectomobile
|
|||
#
|
||||
# config.time_zone = "Central Time (US & Canada)"
|
||||
# config.eager_load_paths << Rails.root.join("extras")
|
||||
config.active_storage.service = :local
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,4 +6,5 @@ Rails.application.routes.draw do
|
|||
mount Blazer::Engine, at: 'blazer'
|
||||
|
||||
resources :readings, only: %i[create]
|
||||
resources :sites, only: %i[show create update]
|
||||
end
|
||||
|
|
4
config/storage.yml
Normal file
4
config/storage.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
local:
|
||||
service: Disk
|
||||
public: true
|
||||
root: <%= Rails.root.join('storage') %>
|
11
db/migrate/20220514222253_create_site.rb
Normal file
11
db/migrate/20220514222253_create_site.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Configuración del sitio
|
||||
class CreateSite < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :sites do |t|
|
||||
t.timestamps
|
||||
t.string :title, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
# This migration comes from active_storage (originally 20170806125915)
|
||||
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :active_storage_blobs do |t|
|
||||
t.string :key, null: false
|
||||
t.string :filename, null: false
|
||||
t.string :content_type
|
||||
t.text :metadata
|
||||
t.string :service_name, null: false
|
||||
t.bigint :byte_size, null: false
|
||||
t.string :checksum, null: false
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :key ], unique: true
|
||||
end
|
||||
|
||||
create_table :active_storage_attachments do |t|
|
||||
t.string :name, null: false
|
||||
t.references :record, null: false, polymorphic: true, index: false
|
||||
t.references :blob, null: false
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
|
||||
t.foreign_key :active_storage_blobs, column: :blob_id
|
||||
end
|
||||
|
||||
create_table :active_storage_variant_records do |t|
|
||||
t.belongs_to :blob, null: false, index: false
|
||||
t.string :variation_digest, null: false
|
||||
|
||||
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
t.foreign_key :active_storage_blobs, column: :blob_id
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue