chore: reorganize para current/, rails 8.1, testes e readme

- move app para current/ (estrutura capistrano)
- rails 7.2 → 8.1, ruby 3.2, sqlite3 2.x
- adiciona primary_key Idinformativo no model
- schema.rb completo com todas as tabelas
- testes minitest: models (Tag, Informativo, Tema) e controllers
- readme atualizado em pt-br com stack e instruções de desenvolvimento
- gitignore exclui dump.sql, *.duckdb e sqlite3
This commit is contained in:
2026-06-18 18:58:01 +02:00
parent 691ed8e7e5
commit 25832564f9
132 changed files with 2067 additions and 1253 deletions

12
current/.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
/.bundle
/vendor
/log/*
/tmp/*
/config/database.yml
/config/master.key
/public/assets
.byebug_history
.DS_Store
/db/*.sqlite3
/db/*.sqlite3-shm
/db/*.sqlite3-wal

1
current/.ruby-version Normal file
View File

@@ -0,0 +1 @@
3.2.5

30
current/Gemfile Normal file
View File

@@ -0,0 +1,30 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# core
gem 'rails', '~> 8.0'
gem 'puma', '~> 6.0'
gem 'sqlite3', '>= 2.0'
#assets
gem 'sprockets-rails'
gem 'sassc-rails'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'redcarpet'
gem 'trix-rails', require: 'trix'
gem 'haml-rails'
gem 'will_paginate'
#admin
gem 'devise'
gem 'activeadmin'
gem 'activeadmin_addons'
group :development do
gem 'listen', '>= 3.0.5'
gem 'byebug'
gem 'awesome_print'
gem 'web-console', '>= 3.3.0'
gem 'spring'
gem 'spring-watcher-listen'
end

383
current/Gemfile.lock Normal file
View File

@@ -0,0 +1,383 @@
GEM
remote: https://rubygems.org/
specs:
action_text-trix (2.1.19)
railties
actioncable (8.1.3)
actionpack (= 8.1.3)
activesupport (= 8.1.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.1.3)
actionpack (= 8.1.3)
activejob (= 8.1.3)
activerecord (= 8.1.3)
activestorage (= 8.1.3)
activesupport (= 8.1.3)
mail (>= 2.8.0)
actionmailer (8.1.3)
actionpack (= 8.1.3)
actionview (= 8.1.3)
activejob (= 8.1.3)
activesupport (= 8.1.3)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.3)
actionview (= 8.1.3)
activesupport (= 8.1.3)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.3)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.3)
activerecord (= 8.1.3)
activestorage (= 8.1.3)
activesupport (= 8.1.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.3)
activesupport (= 8.1.3)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_material (1.5.2)
activeadmin (3.5.1)
arbre (~> 1.2, >= 1.2.1)
csv
formtastic (>= 3.1)
formtastic_i18n (>= 0.4)
inherited_resources (~> 1.7)
jquery-rails (>= 4.2)
kaminari (>= 1.2.1)
railties (>= 6.1)
ransack (>= 4.0)
activeadmin_addons (1.10.2)
active_material (~> 1.5)
railties
redcarpet
require_all
sassc
sassc-rails
xdan-datetimepicker-rails (~> 2.5.1)
activejob (8.1.3)
activesupport (= 8.1.3)
globalid (>= 0.3.6)
activemodel (8.1.3)
activesupport (= 8.1.3)
activerecord (8.1.3)
activemodel (= 8.1.3)
activesupport (= 8.1.3)
timeout (>= 0.4.0)
activestorage (8.1.3)
actionpack (= 8.1.3)
activejob (= 8.1.3)
activerecord (= 8.1.3)
activesupport (= 8.1.3)
marcel (~> 1.0)
activesupport (8.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
arbre (1.7.0)
activesupport (>= 3.0.0)
ruby2_keywords (>= 0.0.2)
awesome_print (1.9.2)
base64 (0.3.0)
bcrypt (3.1.22)
bigdecimal (4.1.2)
bindex (0.8.1)
bootsnap (1.24.6)
msgpack (~> 1.2)
builder (3.3.0)
byebug (13.0.0)
reline (>= 0.6.0)
concurrent-ruby (1.3.7)
connection_pool (3.0.2)
crass (1.0.6)
csv (3.3.5)
date (3.5.1)
devise (5.0.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 7.0)
responders
warden (~> 1.2.3)
drb (2.2.3)
erb (6.0.4)
erubi (1.13.1)
ffi (1.17.4-aarch64-linux-gnu)
ffi (1.17.4-aarch64-linux-musl)
ffi (1.17.4-arm-linux-gnu)
ffi (1.17.4-arm-linux-musl)
ffi (1.17.4-arm64-darwin)
ffi (1.17.4-x86_64-darwin)
ffi (1.17.4-x86_64-linux-gnu)
ffi (1.17.4-x86_64-linux-musl)
formtastic (6.0.0)
actionpack (>= 7.2.0)
formtastic_i18n (0.7.0)
globalid (1.3.0)
activesupport (>= 6.1)
haml (7.2.0)
temple (>= 0.8.2)
thor
tilt
haml-rails (3.0.0)
actionpack (>= 5.1)
activesupport (>= 5.1)
haml (>= 4.0.6)
railties (>= 5.1)
has_scope (0.9.0)
actionpack (>= 7.0)
activesupport (>= 7.0)
i18n (1.15.1)
concurrent-ruby (~> 1.0)
inherited_resources (1.14.0)
actionpack (>= 6.0)
has_scope (>= 0.6)
railties (>= 6.0)
responders (>= 2)
io-console (0.8.2)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jquery-rails (4.6.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.19.9)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
kaminari-activerecord (= 1.2.2)
kaminari-core (= 1.2.2)
kaminari-actionview (1.2.2)
actionview
kaminari-core (= 1.2.2)
kaminari-activerecord (1.2.2)
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
listen (3.10.0)
logger
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.7.0)
loofah (2.25.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.9.0)
logger
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.2.1)
mini_mime (1.1.5)
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
msgpack (1.8.3)
net-imap (0.6.4.1)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.5)
nokogiri (1.19.4-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.4-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.19.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-musl)
racc (~> 1.4)
orm_adapter (0.5.0)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
psych (5.4.0)
date
stringio
puma (6.6.1)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.2.6)
rack-session (2.1.2)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (8.1.3)
actioncable (= 8.1.3)
actionmailbox (= 8.1.3)
actionmailer (= 8.1.3)
actionpack (= 8.1.3)
actiontext (= 8.1.3)
actionview (= 8.1.3)
activejob (= 8.1.3)
activemodel (= 8.1.3)
activerecord (= 8.1.3)
activestorage (= 8.1.3)
activesupport (= 8.1.3)
bundler (>= 1.15.0)
railties (= 8.1.3)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.7.0)
loofah (~> 2.25)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.3)
actionpack (= 8.1.3)
activesupport (= 8.1.3)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rake (13.4.2)
ransack (4.4.1)
activerecord (>= 7.2)
activesupport (>= 7.2)
i18n
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rdoc (7.2.0)
erb
psych (>= 4.0.0)
tsort
redcarpet (3.6.1)
reline (0.6.3)
io-console (~> 0.5)
require_all (3.0.0)
responders (3.2.0)
actionpack (>= 7.0)
railties (>= 7.0)
ruby2_keywords (0.0.5)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
securerandom (0.4.1)
spring (4.6.0)
spring-watcher-listen (2.1.0)
listen (>= 2.7, < 4.0)
spring (>= 4)
sprockets (4.2.2)
concurrent-ruby (~> 1.0)
logger
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (2.9.5-aarch64-linux-gnu)
sqlite3 (2.9.5-aarch64-linux-musl)
sqlite3 (2.9.5-arm-linux-gnu)
sqlite3 (2.9.5-arm-linux-musl)
sqlite3 (2.9.5-arm64-darwin)
sqlite3 (2.9.5-x86_64-darwin)
sqlite3 (2.9.5-x86_64-linux-gnu)
sqlite3 (2.9.5-x86_64-linux-musl)
stringio (3.2.0)
temple (0.10.4)
thor (1.5.0)
tilt (2.7.0)
timeout (0.6.1)
trix-rails (2.4.0)
rails (> 4.1)
tsort (0.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.1.1)
useragent (0.16.11)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.3.0)
actionview (>= 8.0.0)
bindex (>= 0.4.0)
railties (>= 8.0.0)
websocket-driver (0.8.1)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (4.0.1)
xdan-datetimepicker-rails (2.5.4)
jquery-rails
rails (>= 3.2.16)
zeitwerk (2.8.2)
PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86_64-darwin
x86_64-linux-gnu
x86_64-linux-musl
DEPENDENCIES
activeadmin
activeadmin_addons
awesome_print
bootsnap (>= 1.1.0)
byebug
devise
haml-rails
listen (>= 3.0.5)
puma (~> 6.0)
rails (~> 8.0)
redcarpet
sassc-rails
spring
spring-watcher-listen
sprockets-rails
sqlite3 (>= 2.0)
trix-rails
web-console (>= 3.3.0)
will_paginate
BUNDLED WITH
2.5.23

105
current/README.md Normal file
View File

@@ -0,0 +1,105 @@
# Ambiente JA
Portal de notícias ambientais que operou de 2001 a 2015, reunindo **170.273 artigos** em português brasileiro sobre meio ambiente, sustentabilidade e políticas públicas.
---
## O que é
O Ambiente JA foi um agregador de notícias ambientais com curadoria editorial. O acervo cobre 14,8 anos de cobertura jornalística nacional, estadual e internacional — da Rio+10 às vésperas do Acordo de Paris, passando por toda a era de ouro da blogosfera ambiental brasileira dos anos 2000.
Cada artigo possui:
- **Título e corpo completo** (HTML e Markdown)
- **Classificação por tema** (30 temas como Legislação, Mudanças Climáticas, Fauna e Flora, Energia, Poluição, etc.)
- **Abrangência** — Nacional (46%), Estadual (30%), Internacional (24%)
- **Data de publicação**
- **Tags semânticas** para navegação e busca
Os artigos foram coletados de fontes como agências de notícias, jornais, sites especializados, ONGs, universidades e órgãos públicos.
---
## O acervo em números
| Métrica | Valor |
|---|---|
| Total de artigos | 170.273 |
| Período | jan/2001 — out/2015 |
| Pico de cobertura | 20072008 (~25 mil artigos/ano) |
| Temas principais | 30 |
| Artigos com tema atribuído | 143.411 (84,2%) |
### Temas com mais artigos
| # | Tema | Artigos |
|---|---|---|
| 1 | Legislação e Governo | 27.835 |
| 2 | Fauna e Flora | 14.086 |
| 3 | Mudanças Climáticas | 8.645 |
| 4 | Energia Renovável | 8.544 |
| 5 | Água | 6.435 |
| 6 | Ciência e Tecnologia | 6.277 |
| 7 | Resíduos/Lixo | 6.141 |
| 8 | Saúde e Meio Ambiente | 6.088 |
| 9 | Agropecuária | 4.973 |
| 10 | Crimes Ambientais | 4.823 |
Resumos detalhados de cada tema estão disponíveis em [`resumo/`](../resumo/).
---
## Stack
- **Ruby 3.2 / Rails 8.1** — aplicação web com ActiveAdmin
- **SQLite3** — banco de dados principal (migrado do MySQL original)
- **MySQL** (original) — dump disponível como `dump.sql` (775 MB)
- **DuckDB** — conversão parcial para análise local ([`ambienteja.duckdb`](../ambienteja.duckdb))
- **HAML + SASS + jQuery** — frontend minimalista
- **Puma** — servidor web
## Desenvolvimento
```bash
bundle install
rails db:schema:load
rails server
```
### Testes
```bash
rails test
```
Cobertura: models (`Informativo`, `Tema`, `Tag`) e rotas públicas (`home`, `busca`, `tag`, `tema`, `informativo`).
---
## Estrutura do projeto
```
ambienteja/
├── current/ # Aplicação Rails
│ ├── app/ # Models, controllers, views, assets
│ ├── db/ # Schema e migrations
│ └── config/ # Rotas, deploy, Puma
├── dump.sql # Dump MySQL completo (774,5 MB)
├── ambienteja.duckdb # Banco DuckDB com tabelas auxiliares
├── mysql_to_duckdb.py # Script de conversão MySQL → DuckDB
└── resumo/ # Resumos textuais por tema (Markdown)
```
---
## Contexto histórico
O site foi ao ar em 2001, no início da internet comercial brasileira, quando a cobertura ambiental ainda era fragmentada. Durante seus 15 anos de operação, testemunhou e registrou:
- A ascensão do tema mudanças climáticas (Protocolo de Kyoto, COPs, IPCC)
- O debate sobre transgênicos e a expansão do agronegócio
- A criação e implementação da Política Nacional de Resíduos Sólidos
- O boom dos biocombustíveis e a controvérsia food vs fuel
- Grandes desastres (tsunami de 2004, Katrina, Fukushima, Mariana)
- A política ambiental durante os governos FHC, Lula e Dilma
O acervo é um registro histórico da consciência ambiental brasileira nas primeiras décadas do século XXI.

6
current/Rakefile Normal file
View File

@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tasks

View File

@@ -0,0 +1,28 @@
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end

View File

@@ -0,0 +1,33 @@
ActiveAdmin.register_page "Dashboard" do
menu false
# 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

View File

@@ -0,0 +1,37 @@
ActiveAdmin.register Informativo do
permit_params :Idinformativo, :titulo, :Descricao, :Idtipo, :Abrangencia, :Datainc, :tema1, :subtema1, :tema2, :subtema2, :tema3, :subtema3, :tema4, :subtema4, :operador_inc, :operador_alt, :markdown, tag_ids: []
index do
selectable_column
column :Idinformativo
column :titulo
column :Abrangencia
column :Datainc
column :operador_inc
actions
end
filter :titulo
filter :operador_inc
form do |f|
f.inputs 'Informativo' do
f.input :Datainc, as: :date_time_picker
f.input :titulo
f.input :operador_inc
f.input :tag_ids, as: :tags, collection: Tag.all, display_name: :nome
f.trix_editor :Descricao
end
actions
end
show do
attributes_table do
row :titulo
# row :image do |ad|
# image_tag ad.image.url
# end
end
end
end

18
current/app/admin/tags.rb Normal file
View File

@@ -0,0 +1,18 @@
ActiveAdmin.register Tag do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# Uncomment all parameters which should be permitted for assignment
#
# permit_params :nome, :param, :count
#
# or
#
# permit_params do
# permitted = [:nome, :param, :count]
# permitted << :other if params[:action] == 'create' && current_user.admin?
# permitted
# end
end

View File

@@ -0,0 +1,18 @@
ActiveAdmin.register Tema do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# Uncomment all parameters which should be permitted for assignment
#
# permit_params :reg, :cod_tema, :cod_tema_sub, :tema, :ativo, :padrao, :count, :param
#
# or
#
# permit_params do
# permitted = [:reg, :cod_tema, :cod_tema_sub, :tema, :ativo, :padrao, :count, :param]
# permitted << :other if params[:action] == 'create' && current_user.admin?
# permitted
# end
end

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,3 @@
//= require trix
//= require active_admin/base
//= require activeadmin_addons/all

View File

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

View File

@@ -0,0 +1,17 @@
// 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, 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 jquery-3.4.0.min
$(document).ready(function(){
console.log("- by http://extrapolo.com -")
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
@import 'activeadmin_addons/all';
// 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";
//*= require trix
.trix-button--icon-attach{
display: none
}
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// .status_tag { background: #6090DB; }

View File

@@ -0,0 +1,205 @@
p{
margin: 0px;
padding: 0px;
}
@font-face {
font-family: 'wild';
src: url('wildgrowth-webfont.woff2') format('woff2'),
url('wildgrowth-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
body {
padding: 20px;
font-family: 'Fira Sans', monospace;
background-color: #fff;
color: #4c4e4d;
background-image: url(bg.png);
background-repeat: repeat;
background-attachment: fixed;
}
a{
text-decoration: none;
color: #4c4e4d;
}
a:hover {
color:black;
}
#temas{
display: inline-block;
padding-right: 40px;
float: left;
width: 300px
}
.tema{
display: block;
background-color: #12d612d1;
margin: 5px;
padding: 2px;
padding-left: 10px;
padding-right: 10px;
color: black;
font-size: 14px;
padding-top: 4px;
text-decoration: none;
}
.tema:hover{
color: white;
background-color: green;
cursor: pointer;
}
.content{
display: contents;
color: black;
}
.content:hover{
color: white
}
.right{
float: right;
padding-left: 20px;
}
.logo{
font-family: "wild";
font-size: 30px;
padding-left: 50px;
letter-spacing: 3px;
text-shadow: 9px 5px 5px #0061226e;
user-select: none;
font-weight: bold;
}
.logo_img{
width: 215px;
padding: 3px 0px 0px 15px;
}
.texto{
font-size: 14px;
padding: 10px 10px 10px 0px;
background-color: white;
margin-top: 15px;
/* padding: 10px; */
border: 1px solid #80808036;
padding: 15px;
margin-bottom: 15px;
box-shadow: 5px 4px 14px 0px #80808038;
}
.texto>p{
margin-bottom: 10px;
line-height: 18px
}
#busca{
display: inline-block;
float: right;
padding-right: 25px;
padding-top: 12px;
}
.busca-btn{
padding: 3px;
border: 1px;
font-weight: 900;
width: 25px;
color: white;
background-color: #006122;
}
.busca-input{
font-family: 'Fira Sans';
padding: 3px;
border: 1px;
background-color: #33f739b0;
width: 190px;
}
#all{
width: 900px;
margin: 0px auto;
margin-top: 50px;
}
.link{
background-color: #ffdb00;
padding: 4px;
line-height: 33px;
display: inline;
font-weight: bold;
}
.tag{
display: inline-block;
padding: 4px;
margin: 3px;
background-color: #d8d4d4;
font-size: 12px;
}
#tags{
text-align: center;
padding: 10px 0px 25px 0px;
}
#informativos{
display: flow-root;
}
.tags{
margin: 2px;
display: inline-flex;
background-color: #d8d4d4b8;
font-size: 12px;
padding: 2px;
font-weight: normal;
}
h2{
margin: 0px
}
h3{
text-align: right;
font-size:15px;
}
#topo{
background-image: linear-gradient(to right, #47a91c, #066f09);
width: 100%;
display: inline-block;
top: 0px;
left: 0px;
position: absolute;
height: 45px;
border-bottom: 1px solid lightgray
}
.card{
/* color: black; */
width: 100%;
border-top: 1px solid lightgray;
padding-top: 10px;
display: inline-block;
background-color: white;
margin-bottom: 8px
}
.date{
font-size: 12px;
color: gray;
padding-top: 10px;
background-color: white;
display: table;
}
#nav{
display: inline-block;
width: 100%;
text-align: center;
padding: 10px;
font-size: 19px;
background-image: linear-gradient(to right, #33f739 , #329c04);
}
#baixo{
background-color: #d3d3d3bf;
font-size: 11px;
width: 100%;
/* bottom: 0px; */
position: fixed;
bottom: 0px;
left: 0px;
padding: 4px;
text-align: center;
}

View File

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

View File

View File

@@ -0,0 +1,41 @@
class PageController < ApplicationController
# caches_page :home, :informativo
def home
@informativos = Informativo.order("Datainc desc").page(params[:page] || 1)
end
def informativo
@informativo = Informativo.find(params[:id])
@title = @informativo.titulo
end
def tag
@tag = Tag.find_by(param: params[:param])
@informativos = @tag.informativos.page(params[:page] || 1)
@title = @tag.nome
render "list"
end
def tema
@tema = Tema.find_by(param: params[:param])
@informativos = @tema.informativos.page(params[:page] || 1)
@title = @tema.padrao
render "list"
end
def busca
@search = params[:q]
terms = @search.to_s.split(/\s+/)
scope = Informativo.all
terms.each do |term|
clean = term.gsub(/[+\-*"()~<>]/, "")
next if clean.blank?
scope = scope.where("titulo LIKE ?", "%#{clean}%")
end
@informativos = scope.order("Datainc desc").page(params[:page] || 1)
@title = "Busca: #{@search}"
render "list"
end
end

View File

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

View File

@@ -0,0 +1,10 @@
class AdminUser < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :validatable
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :validatable
end

View File

@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

View File

View File

@@ -0,0 +1,27 @@
class Informativo < ApplicationRecord
self.table_name = "informativo"
self.primary_key = "Idinformativo"
has_and_belongs_to_many :tags
before_save :meta
def temas
Tema.where("cod_tema = #{self.tema1} or cod_tema = #{self.tema2} or cod_tema = #{self.tema3}").map(&:tema)
end
def as_markdown
html = HTMLPage.new :contents => self.Descricao
html.markdown
end
def to_html
Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(self.markdown)
end
private
def meta
#expire_page action: "show", id: params[:list][:id]
self.Datainc = DateTime.now unless self.Datainc
end
end

16
current/app/models/tag.rb Normal file
View File

@@ -0,0 +1,16 @@
class Tag < ApplicationRecord
has_and_belongs_to_many :informativos
before_save :parameterize
validates :nome, uniqueness: true
def self.top
Tag.limit(80).order("count DESC")
end
private
def parameterize
self.nome.strip!
self.param = self.nome.parameterize
puts "Tag: #{self.nome}"
end
end

View File

@@ -0,0 +1,11 @@
class Tema < ApplicationRecord
self.table_name = "temas"
def self.infos
Tema.where(cod_tema_sub: 0).where.not(padrao: "").map { |t| [t.padrao, t.count] }.sort_by { |_, c| -c }
end
def informativos
Informativo.where("tema1 = ? OR tema2 = ? OR tema3 = ?", cod_tema, cod_tema, cod_tema)
end
end

View File

@@ -0,0 +1,35 @@
!!!
%html
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
- title = "Ambiente Já!"
- title = "#{@title} - #{title}" if @title
%title= title
= csrf_meta_tags
= csp_meta_tag
= favicon_link_tag asset_path('favicon.ico')
= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Fira+Sans&display=swap"
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
%body
#all
#topo
= link_to image_tag("logo.png", class: "logo_img"), "/"
#busca
= form_tag("/search", method: :get) do
= text_field_tag :q, "", class: 'busca-input', placeholder: "+agrofloresta +vida -lixo"
= submit_tag '⌕', class: 'busca-btn'
#temas
- Tema.infos.each do |t|
= link_to "/tema/#{t[0].parameterize}", class: "tema" do
%span.content= t[0]
%span.right= "(#{t[1]})"
= yield :tags
#informativos
= yield
#baixo
%span - AmbienteJá desde 2001 -

View File

@@ -0,0 +1,16 @@
- content_for :tags do
#tags
- Tag.top.each do |t|
%span= link_to "#{t.nome} (#{t.count})", "/tag/#{t.param}", class: "tags", target: "blank"
#informativos
- @informativos.each do |i|
.card
%p= link_to i.titulo.html_safe, CGI.unescapeHTML("/informativo/#{i.id}"), class: "link"
- i.tags.each do |t|
%span= link_to t.nome, "/tag/#{t.param}", class: "tags", target: "blank"
- from = i.operador_inc ? " | #{i.operador_inc.downcase.capitalize}" : ""
.date= "#{i.Datainc} #{from}"
#nav
= will_paginate @informativos

View File

@@ -0,0 +1,25 @@
:javascript
$(document).ready(function(){
$(".texto a").each(function(a){
$(this).attr("target", "_blank");
})
});
#todo
%h2.link= @informativo.titulo.html_safe
#br{style: "padding-top: 4px"}
- @informativo.tags.each do |t|
%span= link_to t.nome, "/tag/#{t.param}", class: "tags", target: "blank"
- from = @informativo.operador_inc ? " | #{@informativo.operador_inc.downcase.capitalize}" : ""
.date= "#{@informativo.Datainc} #{from}"
.texto!= @informativo.Descricao #to_html
-# %hr
-# != ap @informativo
%hr
#tags
- Tag.top.each do |t|
%span= link_to "#{t.nome} (#{t.count})", "/tag/#{t.param}", class: "tags", target: "blank"

View File

@@ -0,0 +1,14 @@
%h2.link= "[ #{@title} ]"
-# .date= "#{@informativos.count} informativos"
#br{style: "padding: 5px 0px 5px"}
- @informativos.each do |i|
.card
%p= link_to i.titulo.html_safe, CGI.unescapeHTML("/informativo/#{i.id}"), class: "link"
- i.tags.each do |t|
%span= link_to t.nome, "/tag/#{t.param}", class: "tags", target: "blank"
- from = i.operador_inc ? " | #{i.operador_inc.downcase.capitalize}" : ""
.date= "#{i.Datainc} #{from}"
#nav
= will_paginate @informativos

3
current/bin/bundle Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')

9
current/bin/rails Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

9
current/bin/rake Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run

36
current/bin/setup Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env ruby
require 'fileutils'
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

17
current/bin/spring Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# This file loads Spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require 'rubygems'
require 'bundler'
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
end
end

31
current/bin/update Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

5
current/config.ru Normal file
View File

@@ -0,0 +1,5 @@
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application

View File

@@ -0,0 +1,19 @@
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Ambienteja
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 8.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
end
end

4
current/config/boot.rb Normal file
View File

@@ -0,0 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
#require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

32
current/config/deploy.rb Normal file
View File

@@ -0,0 +1,32 @@
require 'mina/rails'
require 'mina/git'
require 'mina/bundler'
require 'mina/rbenv'
set :user, 'polo'
set :domain, '51.15.63.128'
set :deploy_to, '/home/polo/apps/abrigo/ambienteja'
set :repository, 'http://git.mostre.me:3500/rafapolo/ambienteja.git'
set :shared_dirs, fetch(:shared_dirs, ['log', 'public/upload', 'tmp', 'tmp/pids'])
set :shared_files, fetch(:shared_files, ['config/database.yml'])
set :rbenv_map_bins, %w{rake gem bundle ruby rails puma pumactl}
desc "Deploys the current version to the server."
task :deploy do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'rbenv:load'
invoke :'bundle:install'
invoke :'rails:assets_precompile'
# invoke :'restart'
end
end
task :start do
command "cd #{fetch(:deploy_to)}/current; bundle exec puma -C config/puma.rb &"
end
task :restart do
command "kill -SIGUSR2 `ps aux | grep tcp://0.0.0.0:3333 | grep puma | awk '{ print $2 }'`", quiet: true
end

View File

@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View File

@@ -0,0 +1,62 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

View File

@@ -0,0 +1,115 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
config.public_file_server.enabled = true
# config.action_controller.perform_caching = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
config.hosts << "ambienteja.org"
config.action_controller.perform_caching = true
config.cache_store = :file_store, "#{root}/tmp/cache/"
config.action_controller.page_cache_directory = Rails.root.join("tmp", "cached_pages")
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile =true
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "ambienteja_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Inserts middleware to perform automatic connection switching.
# The `database_selector` hash is used to pass options to the DatabaseSelector
# middleware. The `delay` is used to determine how long to wait after a write
# to send a subsequent read to the primary.
#
# The `database_resolver` class is used by the middleware to determine which
# database is appropriate to use based on the time delay.
#
# The `database_resolver_context` class is used by the middleware to set
# timestamps for the last write to the primary. The resolver uses the context
# class timestamps to determine how long to wait before reading from the
# replica.
#
# By default Rails will store a last write timestamp in the session. The
# DatabaseSelector middleware is designed as such you can define your own
# strategy for connection switching and pass that into the middleware through
# these configuration options.
# config.active_record.database_selector = { delay: 2.seconds }
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
end

View File

@@ -0,0 +1,48 @@
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.cache_classes = false
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end

View File

@@ -0,0 +1,331 @@
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "Ambiente Já"
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
#
# config.site_title_link = "/"
# Set an optional image to be displayed for the header
# instead of a string (overrides :site_title)
#
# Note: Aim for an image that's 21px high so it fits in the header.
#
# config.site_title_image = "logo.png"
# == Default Namespace
#
# Set the default namespace each administration resource
# will be added to.
#
# eg:
# config.default_namespace = :hello_world
#
# This will create resources in the HelloWorld module and
# will namespace routes to /hello_world/*
#
# To set no namespace by default, use:
# config.default_namespace = false
#
# Default:
# config.default_namespace = :admin
#
# You can customize the settings for each namespace by using
# a namespace block. For example, to change the site title
# within a namespace:
#
# config.namespace :admin do |admin|
# admin.site_title = "Custom Admin Title"
# end
#
# This will ONLY change the title for the admin section. Other
# namespaces will continue to use the main "site_title" configuration.
# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
# within the application controller.
config.authentication_method = :authenticate_admin_user!
# == User Authorization
#
# Active Admin will automatically call an authorization
# method in a before filter of all controller actions to
# ensure that there is a user with proper rights. You can use
# CanCanAdapter or make your own. Please refer to documentation.
# config.authorization_adapter = ActiveAdmin::CanCanAdapter
# In case you prefer Pundit over other solutions you can here pass
# the name of default policy class. This policy will be used in every
# case when Pundit is unable to find suitable policy.
# config.pundit_default_policy = "MyDefaultPunditPolicy"
# If you wish to maintain a separate set of Pundit policies for admin
# resources, you may set a namespace here that Pundit will search
# within when looking for a resource's policy.
# config.pundit_policy_namespace = :admin
# You can customize your CanCan Ability class name here.
# config.cancan_ability_class = "Ability"
# You can specify a method to be called on unauthorized access.
# This is necessary in order to prevent a redirect loop which happens
# because, by default, user gets redirected to Dashboard. If user
# doesn't have access to Dashboard, he'll end up in a redirect loop.
# Method provided here should be defined in application_controller.rb.
# config.on_unauthorized_access = :access_denied
# == Current User
#
# Active Admin will associate actions with the current
# user performing them.
#
# This setting changes the method which Active Admin calls
# (within the application controller) to return the currently logged in user.
config.current_user_method = :current_admin_user
# == Logging Out
#
# Active Admin displays a logout link on each screen. These
# settings configure the location and method used for the link.
#
# This setting changes the path where the link points to. If it's
# a string, the strings is used as the path. If it's a Symbol, we
# will call the method to return the path.
#
# Default:
config.logout_link_path = :destroy_admin_user_session_path
# This setting changes the http method used when rendering the
# link. For example :get, :delete, :put, etc..
#
# Default:
# config.logout_link_method = :get
config.register_stylesheet 'https://cdn.bootcss.com/trix/1.0.0/trix.css'
config.register_javascript 'https://cdn.bootcss.com/trix/1.0.0/trix.js'
# == Root
#
# Set the action to call for the root path. You can set different
# roots for each namespace.
#
# Default:
# config.root_to = 'dashboard#index'
config.root_to = 'informativos#index'
# == Admin Comments
#
# This allows your users to comment on any resource registered with Active Admin.
#
# You can completely disable comments:
config.comments = false
#
# You can change the name under which comments are registered:
# config.comments_registration_name = 'AdminComment'
#
# You can change the order for the comments and you can change the column
# to be used for ordering:
# config.comments_order = 'created_at ASC'
#
# You can disable the menu item for the comments index page:
# config.comments_menu = false
#
# You can customize the comment menu:
# config.comments_menu = { parent: 'Admin', priority: 1 }
# == Batch Actions
#
# Enable and disable Batch Actions
#
config.batch_actions = true
# == Controller Filters
#
# You can add before, after and around filters to all of your
# Active Admin resources and pages from here.
#
# config.before_action :do_something_awesome
# == Attribute Filters
#
# You can exclude possibly sensitive model attributes from being displayed,
# added to forms, or exported by default by ActiveAdmin
#
config.filter_attributes = [:encrypted_password, :password, :password_confirmation]
# == Localize Date/Time Format
#
# Set the localize format to display dates and times.
# To understand how to localize your app with I18n, read more at
# https://guides.rubyonrails.org/i18n.html
#
# You can run `bin/rails runner 'puts I18n.t("date.formats")'` to see the
# available formats in your application.
#
config.localize_format = :long
# == Setting a Favicon
#
# config.favicon = 'favicon.ico'
# == Meta Tags
#
# Add additional meta tags to the head element of active admin pages.
#
# Add tags to all pages logged in users see:
# config.meta_tags = { author: 'My Company' }
# By default, sign up/sign in/recover password pages are excluded
# from showing up in search engine results by adding a robots meta
# tag. You can reset the hash of meta tags included in logged out
# pages:
# config.meta_tags_for_logged_out_pages = {}
# == Removing Breadcrumbs
#
# Breadcrumbs are enabled by default. You can customize them for individual
# resources or you can disable them globally from here.
#
# config.breadcrumb = false
# == Create Another Checkbox
#
# Create another checkbox is disabled by default. You can customize it for individual
# resources or you can enable them globally from here.
#
# config.create_another = true
# == Register Stylesheets & Javascripts
#
# We recommend using the built in Active Admin layout and loading
# up your own stylesheets / javascripts to customize the look
# and feel.
#
# To load a stylesheet:
# config.register_stylesheet 'my_stylesheet.css'
#
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
# config.register_stylesheet 'my_print_stylesheet.css', media: :print
#
# To load a javascript file:
# config.register_javascript 'my_javascript.js'
# == CSV options
#
# Set the CSV builder separator
# config.csv_options = { col_sep: ';' }
#
# Force the use of quotes
# config.csv_options = { force_quotes: true }
# == Menu System
#
# You can add a navigation menu to be used in your application, or configure a provided menu
#
# To change the default utility navigation to show a link to your website & a logout btn
#
# config.namespace :admin do |admin|
# admin.build_menu :utility_navigation do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# admin.add_logout_button_to_menu menu
# end
# end
#
# If you wanted to add a static menu item to the default menu provided:
#
# config.namespace :admin do |admin|
# admin.build_menu :default do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# end
# end
# == Download Links
#
# You can disable download links on resource listing pages,
# or customize the formats shown per namespace/globally
#
# To disable/customize for the :admin namespace:
#
# config.namespace :admin do |admin|
#
# # Disable the links entirely
# admin.download_links = false
#
# # Only show XML & PDF options
# admin.download_links = [:xml, :pdf]
#
# # Enable/disable the links based on block
# # (for example, with cancan)
# admin.download_links = proc { can?(:view_download_links) }
#
# end
# == Pagination
#
# Pagination is enabled by default for all resources.
# You can control the default per page count for all resources here.
#
# config.default_per_page = 30
#
# You can control the max per page count too.
#
# config.max_per_page = 10_000
# == Filters
#
# By default the index screen includes a "Filters" sidebar on the right
# hand side with a filter for each attribute of the registered model.
# You can enable or disable them for all resources here.
#
# config.filters = true
#
# By default the filters include associations in a select, which means
# that every record will be loaded for each association (up
# to the value of config.maximum_association_filter_arity).
# You can enabled or disable the inclusion
# of those filters by default here.
#
# config.include_default_association_filters = true
# config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version
# config.filter_columns_for_large_association, [
# :display_name,
# :full_name,
# :name,
# :username,
# :login,
# :title,
# :email,
# ]
# config.filter_method_for_large_association, '_starts_with'
# == Head
#
# You can add your own content to the site head like analytics. Make sure
# you only pass content you trust.
#
# config.head = ''.html_safe
# == Footer
#
# By default, the footer shows the current Active Admin version. You can
# override the content of the footer here.
#
# config.footer = 'my custom footer text'
# == Sorting
#
# By default ActiveAdmin::OrderClause is used for sorting logic
# You can inherit it with own class and inject it for all resources
#
# config.order_clause = MyOrderClause
end

View File

@@ -0,0 +1,12 @@
ActiveadminAddons.setup do |config|
# Change to "default" if you want to use ActiveAdmin's default select control.
# config.default_select = "select2"
# Set default options for DateTimePickerInput. The options you can provide are the same as in
# xdan's datetimepicker library (https://github.com/xdan/datetimepicker/tree/2.5.4). Yo need to
# pass a ruby hash, avoid camelCase keys. For example: use min_date instead of minDate key.
# config.datetime_picker_default_options = {}
# Set DateTimePickerInput input format. This if for backend (Ruby)
# config.datetime_picker_input_format = "%Y-%m-%d %H:%M"
end

View File

@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join('public/images')
Rails.application.config.assets.precompile += %w(application.js application.css)
Rails.application.config.public_file_server.enabled = true
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
Rails.application.config.assets.precompile += %w( application.js application.css admin.js admin.css )

View File

@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@@ -0,0 +1,299 @@
# frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = '864f9f1c691528e65ef9e70895d1f68638f5f70479a5a9e0b5da0af35fca408cba42e50bf111536afde21416c09e201cc1268d2bdfb877a5b32657740a02264c'
# ==> Controller configuration
# Configure the parent class to the devise controllers.
# config.parent_controller = 'DeviseController'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
# Configure the parent class responsible to send e-mails.
# config.parent_mailer = 'ActionMailer::Base'
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'devise/orm/active_record'
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating a user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
# config.authentication_keys = [:email]
# Configure parameters from the request object used for authentication. Each entry
# given should be a request method and it will automatically be passed to the
# find_for_authentication method and considered in your model lookup. For instance,
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
# The same considerations mentioned for authentication_keys also apply to request_keys.
# config.request_keys = []
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
# given strategies, for example, `config.params_authenticatable = [:database]` will
# enable it only for database (email + password) authentication.
# config.params_authenticatable = true
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
# given strategies, for example, `config.http_authenticatable = [:database]` will
# enable it only for database authentication. The supported strategies are:
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication. 'Application' by default.
# config.http_authentication_realm = 'Application'
# It will change confirmation, password recovery and other workflows
# to behave the same regardless if the e-mail provided was right or wrong.
# Does not affect registerable.
# config.paranoid = true
# By default Devise will store the user in session. You can skip storage for
# particular strategies by setting this option.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
# passing skip: :sessions to `devise_for` in your config/routes.rb
config.skip_session_storage = [:http_auth]
# By default, Devise cleans up the CSRF token on authentication to
# avoid CSRF token fixation attacks. This means that, when using AJAX
# requests for sign in and sign up, you need to get a new CSRF token
# from the server. You can disable this option at your own risk.
# config.clean_up_csrf_token_on_authentication = true
# When false, Devise will not attempt to reload routes on eager load.
# This can reduce the time taken to boot the app but if your application
# requires the Devise mappings to be loaded during boot time the application
# won't boot properly.
# config.reload_routes = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
# using other algorithms, it sets how many times you want the password to be hashed.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
# a value less than 10 in other environments. Note that, for bcrypt (the default
# algorithm), the cost increases exponentially with the number of stretches (e.g.
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
config.stretches = Rails.env.test? ? 1 : 11
# Set up a pepper to generate the hashed password.
# config.pepper = '1991c71bc9a57b1ab03a829a16557f3f90e9491604f5b4daee96027234916b099e48dbddb922e0dff830b4e9ef319d17379459030ca795ab3f05712f59628171'
# Send a notification to the original email when the user's email is changed.
# config.send_email_changed_notification = false
# Send a notification email when the user's password is changed.
# config.send_password_change_notification = false
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day.
# You can also set it to nil, which will allow the user to access the website
# without confirming their account.
# Default is 0.days, meaning the user cannot access the website without
# confirming their account.
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed, new email is stored in
# unconfirmed_email column, and copied to email column on successful confirmation.
config.reconfirmable = true
# Defines which key will be used when confirming an account
# config.confirmation_keys = [:email]
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# Invalidates all the remember me tokens when the user signs out.
config.expire_all_remember_me_on_sign_out = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# Options to be passed to the created cookie. For instance, you can set
# secure: true in order to force SSL only cookies.
# config.rememberable_options = {}
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 6..128
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
# config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
# config.unlock_keys = [:email]
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
# config.unlock_strategy = :both
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
# config.maximum_attempts = 20
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
# config.last_attempt_warning = true
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
# config.reset_password_keys = [:email]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
# change their passwords.
config.reset_password_within = 6.hours
# When set to false, does not sign a user in automatically after their password is
# reset. Defaults to true, so a user is signed in automatically after a reset.
# config.sign_in_after_reset_password = true
# ==> Configuration for :encryptable
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
# You can use :sha1, :sha512 or algorithms from others authentication tools as
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
# for default behavior) and :restful_authentication_sha1 (then you should set
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views.
# config.scoped_views = false
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
# config.default_scope = :user
# Set this configuration to false if you want /users/sign_out to sign out
# only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
# :html, should redirect to the sign in page when the user does not have
# access, but formats like :xml or :json, should return 401.
#
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists.
#
# The "*/*" below is required to match Internet Explorer requests.
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
#
# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(scope: :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
# is mountable, there are some extra configurations to be taken into account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: '/my_engine'
#
# The router that invoked `devise_for`, in the example above, would be:
# config.router_name = :my_engine
#
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
# ==> Turbolinks configuration
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
#
# ActiveSupport.on_load(:devise_failure_app) do
# include Turbolinks::Controller
# end
# ==> Configuration for :registerable
# When set to false, does not sign a user in automatically after their password is
# changed. Defaults to true, so a user is signed in automatically after changing a password.
# config.sign_in_after_change_password = true
end

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@@ -0,0 +1,4 @@
# config/initializers/kaminari.rb
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View File

@@ -0,0 +1,65 @@
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
en:
devise:
confirmations:
confirmed: "Your email address has been successfully confirmed."
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked."
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
unconfirmed: "You have to confirm your email address before continuing."
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
reset_password_instructions:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock instructions"
email_changed:
subject: "Email Changed"
password_change:
subject: "Password Changed"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."
passwords:
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
updated: "Your password has been changed successfully. You are now signed in."
updated_not_active: "Your password has been changed successfully."
registrations:
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
signed_up: "Welcome! You have signed up successfully."
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
updated: "Your account has been updated successfully."
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
sessions:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."
already_signed_out: "Signed out successfully."
unlocks:
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
errors:
messages:
already_confirmed: "was already confirmed, please try signing in"
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
expired: "has expired, please request a new one"
not_found: "not found"
not_locked: "was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"

View File

@@ -0,0 +1,33 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at https://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

16
current/config/puma.rb Normal file
View File

@@ -0,0 +1,16 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
#daemonize true if ENV.fetch("RAILS_ENV") == "production"
port ENV.fetch("PORT") { 3333 }
environment ENV.fetch("RAILS_ENV") { "production" }
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

11
current/config/routes.rb Normal file
View File

@@ -0,0 +1,11 @@
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
root to: "page#home"
get '/search', to: 'page#busca'
get '/tema/:param', to: 'page#tema'
get '/tag/:param', to: 'page#tag'
get '/informativo/:id', to: 'page#informativo'
end

View File

@@ -0,0 +1,44 @@
# frozen_string_literal: true
class DeviseCreateAdminUsers < ActiveRecord::Migration[5.2]
def change
create_table :admin_users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
# t.integer :sign_in_count, default: 0, null: false
# t.datetime :current_sign_in_at
# t.datetime :last_sign_in_at
# t.string :current_sign_in_ip
# t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps null: false
end
add_index :admin_users, :email, unique: true
add_index :admin_users, :reset_password_token, unique: true
# add_index :admin_users, :confirmation_token, unique: true
# add_index :admin_users, :unlock_token, unique: true
end
end

View File

@@ -0,0 +1,17 @@
class CreateInformativoTags < ActiveRecord::Migration[6.0]
def change
# create_table :tags do |t|
# t.string :nome
# t.string :param
# t.integer :count
# end
# add_index(:tags, :param)
create_join_table :informativo, :tags do |t|
t.index :informativo_idinformativo
t.index :tag_id
end
end
end

73
current/db/schema.rb Normal file
View File

@@ -0,0 +1,73 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2019_12_18_191626) do
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at", precision: nil
t.datetime "remember_created_at", precision: nil
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.index ["email"], name: "index_admin_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
create_table "informativo", primary_key: "Idinformativo", force: :cascade do |t|
t.string "titulo"
t.text "Descricao"
t.integer "Idtipo"
t.string "Abrangencia"
t.date "Datainc"
t.integer "tema1", default: 0
t.integer "subtema1", default: 0
t.integer "tema2", default: 0
t.integer "subtema2", default: 0
t.integer "tema3", default: 0
t.integer "subtema3", default: 0
t.integer "tema4", default: 0
t.integer "subtema4", default: 0
t.string "operador_inc"
t.string "operador_alt"
t.text "markdown"
t.index ["Datainc"], name: "idx_info_datainc"
t.index ["Idtipo"], name: "idx_info_idtipo"
t.index ["tema1"], name: "idx_info_tema1"
end
create_table "informativo_tags", id: false, force: :cascade do |t|
t.integer "informativo_id", null: false
t.integer "tag_id", null: false
t.index ["informativo_id"], name: "index_informativo_tags_on_informativo_id"
t.index ["tag_id"], name: "index_informativo_tags_on_tag_id"
end
create_table "tags", force: :cascade do |t|
t.string "nome"
t.string "param"
t.integer "count"
t.index ["param"], name: "index_tags_on_param"
end
create_table "temas", force: :cascade do |t|
t.integer "cod_tema", default: 0
t.integer "cod_tema_sub", default: 0
t.string "tema", limit: 50
t.integer "ativo", default: 0
t.string "padrao", limit: 50
t.integer "count"
t.string "param", limit: 100
t.index ["cod_tema", "cod_tema_sub"], name: "index_temas_cod"
t.index ["param"], name: "index_temas_param"
end
end

0
current/lib/assets/.keep Normal file
View File

0
current/lib/tasks/.keep Normal file
View File

View File

@@ -0,0 +1,28 @@
namespace :import do
desc "generate markdown from html"
task :as_markdown => :environment do
Informativo.all.each do |i|
i.update(markdown: i.as_markdown)
end
end
desc "fix tags"
task :tags => :environment do
Informativo.all.each do |i|
tags = []
tags << i.tag1.split(", ") if i.tag1
tags << i.tag2.split(", ") if i.tag2
tags << i.tag3.split(", ") if i.tag3
tags.flatten.compact.each do |t|
i.tags << Tag.find_or_create_by(nome: t.gsub(",", "")) unless t.empty?
end
i.tags = i.tags.uniq
i.save
end
Tag.all.each do |t|
t.update(count: t.informativos.count)
end
end
end

12
current/node_modules/.yarn-integrity generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"systemParams": "linux-x64-64",
"modulesFolders": [],
"flags": [
"production"
],
"linkedModules": [],
"topLevelPatterns": [],
"lockfileEntries": {},
"files": [],
"artifacts": {}
}

View File

@@ -0,0 +1 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file

View File

@@ -0,0 +1,37 @@
require "test_helper"
class PageControllerTest < ActionDispatch::IntegrationTest
test "home returns 200" do
get root_path
assert_response :success
end
test "busca returns 200 with empty query" do
get "/search", params: { q: "" }
assert_response :success
end
test "busca returns 200 with search term" do
Informativo.create!(titulo: "Desmatamento na Amazônia")
get "/search", params: { q: "Amazônia" }
assert_response :success
end
test "informativo page returns 200 for valid id" do
info = Informativo.create!(titulo: "Artigo de teste", markdown: "Conteúdo")
get "/informativo/#{info.Idinformativo}"
assert_response :success
end
test "tag page returns 200 for existing tag" do
Tag.create!(nome: "biodiversidade")
get "/tag/biodiversidade"
assert_response :success
end
test "tema page returns 200 for existing tema" do
Tema.create!(cod_tema: 5, tema: "Água", padrao: "Água", param: "agua", count: 0)
get "/tema/agua"
assert_response :success
end
end

View File

@@ -0,0 +1,28 @@
require "test_helper"
class InformativoTest < ActiveSupport::TestCase
test "creates with titulo and sets Datainc automatically" do
info = Informativo.create!(titulo: "Novo artigo ambiental")
assert_not_nil info.Datainc
assert_not_nil info.Idinformativo
end
test "does not overwrite an existing Datainc" do
date = Date.new(2010, 6, 1)
info = Informativo.create!(titulo: "Artigo antigo", Datainc: date)
assert_equal date, info.Datainc
end
test "to_html renders markdown column as HTML" do
info = Informativo.create!(titulo: "Test", markdown: "## Título\nConteúdo")
html = info.to_html
assert_includes html, "<h2>"
assert_includes html, "Título"
end
test "temas returns matching tema names" do
tema = Tema.create!(cod_tema: 7, tema: "Energia", padrao: "Energia Renovável", count: 0)
info = Informativo.create!(titulo: "Solar", tema1: 7)
assert_includes info.temas, tema.tema
end
end

View File

@@ -0,0 +1,27 @@
require "test_helper"
class TagTest < ActiveSupport::TestCase
test "parameterize sets param on save" do
tag = Tag.create!(nome: "Energia Solar")
assert_equal "energia-solar", tag.param
end
test "strips whitespace from nome before save" do
tag = Tag.create!(nome: " mata ciliar ")
assert_equal "mata ciliar", tag.nome
end
test "nome uniqueness is enforced" do
Tag.create!(nome: "floresta")
dup = Tag.new(nome: "floresta")
assert_not dup.valid?
end
test "top returns at most 80 tags ordered by count desc" do
Tag.create!(nome: "tag-a", param: "tag-a", count: 100)
Tag.create!(nome: "tag-b", param: "tag-b", count: 5)
result = Tag.top
assert result.first.count >= result.last.count
assert result.size <= 80
end
end

View File

@@ -0,0 +1,22 @@
require "test_helper"
class TemaTest < ActiveSupport::TestCase
test "informativos returns articles linked to this tema" do
tema = Tema.create!(cod_tema: 3, tema: "Clima", padrao: "Mudanças Climáticas", count: 0)
info = Informativo.create!(titulo: "IPCC 2010", tema1: 3)
assert_includes tema.informativos, info
end
test "infos returns only root temas with padrao, sorted by count desc" do
Tema.create!(cod_tema: 1, cod_tema_sub: 0, padrao: "Legislação", count: 500)
Tema.create!(cod_tema: 2, cod_tema_sub: 0, padrao: "Fauna e Flora", count: 200)
Tema.create!(cod_tema: 3, cod_tema_sub: 1, padrao: "Subtema", count: 999)
result = Tema.infos
names = result.map(&:first)
assert_includes names, "Legislação"
assert_includes names, "Fauna e Flora"
assert_not_includes names, "Subtema"
assert result.first[1] >= result.last[1]
end
end

View File

@@ -0,0 +1,7 @@
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
class ActiveSupport::TestCase
self.use_transactional_tests = true
end