poder customizar el sitio

This commit is contained in:
f 2022-06-08 11:49:54 -03:00
parent 4ad1339a60
commit abc02aef8b
11 changed files with 109 additions and 1 deletions

View file

@ -29,7 +29,9 @@ gem 'ssh_data'
gem 'anomaly_detection' gem 'anomaly_detection'
gem 'bootstrap'
gem 'rails-i18n' gem 'rails-i18n'
gem 'hamlit'
group :development, :test do group :development, :test do
gem 'pry' gem 'pry'

View file

@ -63,6 +63,8 @@ GEM
anomaly_detection (0.1.4-x86_64-linux-musl) anomaly_detection (0.1.4-x86_64-linux-musl)
rice (>= 4.0.2) rice (>= 4.0.2)
ast (2.4.2) ast (2.4.2)
autoprefixer-rails (10.4.2.0)
execjs (~> 2)
bcrypt (3.1.17-x86_64-linux-musl) bcrypt (3.1.17-x86_64-linux-musl)
bindex (0.8.1-x86_64-linux-musl) bindex (0.8.1-x86_64-linux-musl)
blazer (2.6.3) blazer (2.6.3)
@ -72,6 +74,10 @@ GEM
safely_block (>= 0.1.1) safely_block (>= 0.1.1)
bootsnap (1.11.1-x86_64-linux-musl) bootsnap (1.11.1-x86_64-linux-musl)
msgpack (~> 1.2) 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) brakeman (5.2.3)
builder (3.2.4) builder (3.2.4)
chartkick (4.1.3) chartkick (4.1.3)
@ -97,11 +103,16 @@ GEM
exception_notification (4.5.0) exception_notification (4.5.0)
actionmailer (>= 5.2, < 8) actionmailer (>= 5.2, < 8)
activesupport (>= 5.2, < 8) activesupport (>= 5.2, < 8)
execjs (2.8.1)
factory_bot (6.2.1) factory_bot (6.2.1)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
ffi (1.15.5-x86_64-linux-musl) ffi (1.15.5-x86_64-linux-musl)
globalid (1.0.0) globalid (1.0.0)
activesupport (>= 5.0) activesupport (>= 5.0)
hamlit (2.16.0-x86_64-linux-musl)
temple (>= 0.8.2)
thor
tilt
i18n (1.10.0) i18n (1.10.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jbuilder (2.11.5) jbuilder (2.11.5)
@ -135,6 +146,7 @@ GEM
parser (3.1.2.0) parser (3.1.2.0)
ast (~> 2.4.1) ast (~> 2.4.1)
pg (1.3.5-x86_64-linux-musl) pg (1.3.5-x86_64-linux-musl)
popper_js (2.9.3)
pry (0.14.1) pry (0.14.1)
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
@ -224,6 +236,7 @@ GEM
activesupport (>= 5.2) activesupport (>= 5.2)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
ssh_data (1.3.0) ssh_data (1.3.0)
temple (0.8.2)
thor (1.2.1) thor (1.2.1)
tilt (2.0.10) tilt (2.0.10)
turbolinks (5.2.1) turbolinks (5.2.1)
@ -257,12 +270,14 @@ DEPENDENCIES
anomaly_detection anomaly_detection
blazer blazer
bootsnap (>= 1.4.4) bootsnap (>= 1.4.4)
bootstrap
brakeman brakeman
database_cleaner database_cleaner
devise devise
devise-i18n devise-i18n
exception_notification exception_notification
factory_bot factory_bot
hamlit
jbuilder (~> 2.7) jbuilder (~> 2.7)
listen (~> 3.3) listen (~> 3.3)
lograge lograge

View file

@ -0,0 +1 @@
@import "bootstrap";

View 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
View file

@ -0,0 +1,6 @@
# frozen_string_literal: true
class Site < ApplicationRecord
has_one_attached :logo
validates_presence_of :title
end

View file

@ -25,6 +25,7 @@
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li><%= link_to t('.new_dashboard'), new_dashboard_path %></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('.new_check'), new_check_path %></li>
<li><%= link_to t('.site'), Rails.application.routes.url_helpers.site_path(Site.first || Site.new) %></li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -5,7 +5,7 @@ require "rails"
require "active_model/railtie" require "active_model/railtie"
require "active_job/railtie" require "active_job/railtie"
require "active_record/railtie" require "active_record/railtie"
# require "active_storage/engine" require "active_storage/engine"
require "action_controller/railtie" require "action_controller/railtie"
require "action_mailer/railtie" require "action_mailer/railtie"
# require "action_mailbox/engine" # require "action_mailbox/engine"
@ -31,5 +31,6 @@ module Ectomobile
# #
# config.time_zone = "Central Time (US & Canada)" # config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras") # config.eager_load_paths << Rails.root.join("extras")
config.active_storage.service = :local
end end
end end

View file

@ -6,4 +6,5 @@ Rails.application.routes.draw do
mount Blazer::Engine, at: 'blazer' mount Blazer::Engine, at: 'blazer'
resources :readings, only: %i[create] resources :readings, only: %i[create]
resources :sites, only: %i[show create update]
end end

4
config/storage.yml Normal file
View file

@ -0,0 +1,4 @@
local:
service: Disk
public: true
root: <%= Rails.root.join('storage') %>

View 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

View file

@ -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