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

5
.gitignore vendored Normal file → Executable file
View File

@@ -7,3 +7,8 @@
/yarn-error.log
/public/assets
.byebug_history
.DS_Store
dump.sql
*.duckdb
*.duckdb.wal
shared/

0
.ruby-version Normal file → Executable file
View File

29
Gemfile
View File

@@ -1,29 +0,0 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.5'
gem 'rails', '~> 5.2.3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'haml'
gem 'mysql2'
gem 'activeadmin'
gem 'devise'
gem 'will_paginate'
gem "awesome_print"
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

View File

@@ -1,269 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.3)
actionpack (= 5.2.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activeadmin (2.4.0)
arbre (~> 1.2, >= 1.2.1)
formtastic (~> 3.1)
formtastic_i18n (~> 0.4)
inherited_resources (~> 1.7)
jquery-rails (~> 4.2)
kaminari (~> 1.0, >= 1.0.1)
railties (>= 5.0, < 6.1)
ransack (~> 2.1, >= 2.1.1)
sassc-rails (~> 2.1)
sprockets (>= 3.0, < 4.1)
sprockets-es6 (~> 0.9, >= 0.9.2)
activejob (5.2.3)
activesupport (= 5.2.3)
globalid (>= 0.3.6)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
marcel (~> 0.3.1)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arbre (1.2.1)
activesupport (>= 3.0.0)
arel (9.0.0)
awesome_print (1.8.0)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
msgpack (~> 1.0)
builder (3.2.3)
byebug (11.0.1)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.5)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
erubi (1.9.0)
execjs (2.7.0)
ffi (1.11.3)
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.1.2)
temple (>= 0.8.0)
tilt
has_scope (0.7.2)
actionpack (>= 4.1)
activesupport (>= 4.1)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
inherited_resources (1.11.0)
actionpack (>= 5.0, < 6.1)
has_scope (~> 0.6)
railties (>= 5.0, < 6.1)
responders (>= 2, < 4)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.3.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
msgpack (1.3.1)
mysql2 (0.5.2)
nio4r (2.5.2)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
polyamorous (2.3.0)
activerecord (>= 5.0)
puma (3.12.1)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
bundler (>= 1.3.0)
railties (= 5.2.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (13.0.1)
ransack (2.3.0)
actionpack (>= 5.0)
activerecord (>= 5.0)
activesupport (>= 5.0)
i18n
polyamorous (= 2.3.0)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
ruby_dep (1.5.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.1.0)
railties (>= 5.2.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sassc (2.2.1)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-es6 (0.9.2)
babel-source (>= 5.8.11)
babel-transpiler
sprockets (>= 3.0.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
temple (0.8.2)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
warden (1.2.8)
rack (>= 2.0.6)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
will_paginate (3.2.1)
PLATFORMS
ruby
DEPENDENCIES
activeadmin
awesome_print
bootsnap (>= 1.1.0)
byebug
coffee-rails (~> 4.2)
devise
haml
listen (>= 3.0.5, < 3.2)
mysql2
puma (~> 3.11)
rails (~> 5.2.3)
sass-rails (~> 5.0)
spring
spring-watcher-listen (~> 2.0.0)
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
will_paginate
RUBY VERSION
ruby 2.6.5p114
BUNDLED WITH
1.17.2

View File

@@ -1,16 +0,0 @@
# Ambiente Já!
### = fase#01
[ x ] Re-estructure old database
[ x ] Setup web application
[ x ] List articles @ sketch design
### = fase#02
[...] New design
[ ] Fix informativo links

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because one or more lines are too long

View File

@@ -1,78 +0,0 @@
body {
padding: 20px;
font-family: 'Inconsolata', monospace;
background-color: #fff;
color: #4c4e4d;
}
a{
text-decoration: none;
color: #4c4e4d;
font-size: 17px;
font-weight: bold;
}
a:hover {
color:black;
}
#all{
width: 900px;
margin: 0px auto;
margin-top: 35px;
}
.tags{
font-size: 13px;
margin: 5px 0px 5px 0px;
}
h2{
margin: 0px
}
h3{
text-align: right;
font-size:15px;
}
#topo{
background-color: #8bf712;
width: 100%;
text-align: center;
display: inline-block;
top: 0px;
left: 0px;
position: absolute;
font-size: 10px;
height: 35px;
border-bottom: 1px solid lightgray
}
.card{
/* color: black; */
border-top: 1px solid lightgray;
padding-top: 10px;
padding-bottom: 10px;
/* width: 200px; */
/* float: left;
border: 2px solid green;
margin: 10px;
padding: 25px;
font-size: 22px;
text-align: center;
box-shadow: 8px 8px 3px #1a54027a; */
}
.date{
font-size: 13px;
color: gray;
padding-top: 10px
}
#nav{
display: inline-block;
width: 100%;
text-align: center;
padding: 10px;
font-size: 19px;
background-color: #8bf712;
border: 1px solid gray;
}

View File

@@ -1,11 +0,0 @@
class PageController < ApplicationController
def home
@informativos = Informativo.order("data_inc desc").page(params[:page] || 1)
end
def informativo
@informativo = Informativo.find(params[:id])
end
end

View File

@@ -1,15 +0,0 @@
class Informativo < ApplicationRecord
self.table_name = "informativo"
paginates_per 10
def tags
tags = []
tags << self.tag1
tags << self.tag2
tags << self.tag3
tags = tags.uniq.join(", ").downcase
tags.chop! if tags[tags.size-1]==","
tags
end
end

View File

@@ -1,17 +0,0 @@
!!!
%html
%head
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%title Ambiente Já!
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Inconsolata&display=swap"
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
%body
#all
#topo
= link_to (image_tag "logo.png"), "/"
= yield

View File

@@ -1,11 +0,0 @@
%h3= "#{@informativos.count} informativos"
#infos
- @informativos.each do |i|
.card
%span.link= link_to i.titulo.html_safe, CGI.unescapeHTML("/informativo/#{i.id}")
%p.tags= i.tags
.date= "#{i.data_inc} | #{i.operador_inc.downcase.capitalize}"
#nav
= will_paginate @informativos

View File

@@ -1,15 +0,0 @@
// :javascript
// $(document).ready(function(){
// $("a").each(function(a){
// a.href = a.href.replace("http://localhost:3000/informativo/%22", "").replace("\"", "");
// })
// });
#todo
%h2= @informativo.titulo.html_safe
.tags= @informativo.tags
.date= @informativo.data_inc
-# %p= "Por #{@informativo.operador_inc}"
!= @informativo.Descricao.gsub("&quot;", "\"")
-# %hr
-# != ap @informativo

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end

View File

@@ -1 +0,0 @@
ZaWn2LkcPpkh1b4NwpoKP10kmIxshga41mh90XZx9Rm8DjmvKwRzMl3yNTyetWrIRmqNxzf0rqtvXoWli1GnEupvCCs9cuX4awxP8TS7AXQsXORhoadZGIfEe8YbsqfswFatIcLCzKCep7mEVn2FoElfXpwYNbxjkTEJGNLouaHJnFsfYt5WtldaDDNMV58oBEUupOc0MMRGQv29bhtATQkwSIdfvA0l6wlKsygNZNcC1ehF6vnFYTfKsQIJEFQzMkdlwfC/NW/ulb7XAHGaBHWMgvct7ApceOH/DYZQkmnzDgxlOpyH+/IArdE8yGuwnrRrIItnnrJBMSJPNxr1KPzlOvizQ3XXq1NM1lvwNv9XN4gSyhlh/bjWm0QrS1DEI+/HzcEeFIG+bpPkQ+7hoiyyLWi/wTL/Gyki--CIu5O4MaiFuFVxEi--dQNVGD340dDibi8ojYyHGQ==

View File

@@ -1,8 +0,0 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View File

@@ -1,7 +0,0 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@@ -1,25 +0,0 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View File

@@ -1,34 +0,0 @@
# 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.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3333 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "production" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

View File

@@ -1,10 +0,0 @@
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "page#home"
get '/informativo/:id', to: 'page#informativo'
end

View File

@@ -1,6 +0,0 @@
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
].each { |path| Spring.watch(path) }

View File

@@ -1,34 +0,0 @@
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]

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.

View File

@@ -1,5 +1,6 @@
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t("active_admin.dashboard") }
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

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

@@ -10,12 +10,8 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
//= require jquery-3.4.0.min
$(document).ready(function(){
// var msnry = new Masonry( '#infos', {
// columnWidth: 180,
// itemSelector: '.card'
// });
console.log("- by http://extrapolo.com -")
});

View File

@@ -1,3 +1,4 @@
@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
@@ -11,6 +12,11 @@
@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:
//

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

@@ -3,4 +3,8 @@ class AdminUser < ApplicationRecord
# :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,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

View File

@@ -1,4 +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

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
@@ -9,24 +8,25 @@ def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
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 if using Yarn
# Install JavaScript dependencies
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

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

View File

@@ -1,7 +1,6 @@
require_relative 'boot'
require 'rails/all'
require "awesome_print"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@@ -10,11 +9,7 @@ Bundler.require(*Rails.groups)
module Ambienteja
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.generators do |g|
g.template_engine :haml
end
config.load_defaults 8.0
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers

View File

@@ -1,4 +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.
#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

@@ -16,6 +16,7 @@ Rails.application.configure do
# 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 = {
@@ -27,9 +28,7 @@ Rails.application.configure do
config.cache_store = :null_store
end
config.serve_static_assets = true
# Store uploaded files on the local file system (see config/storage.yml for options)
# 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.
@@ -49,12 +48,12 @@ Rails.application.configure do
# 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 = true
config.assets.debug = false
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# 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,

View File

@@ -2,13 +2,18 @@ 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
@@ -19,17 +24,13 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = true #ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# 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
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
@@ -37,10 +38,10 @@ Rails.application.configure do
# 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)
# 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
# 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.*/ ]
@@ -58,9 +59,9 @@ Rails.application.configure do
# 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)
# 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_#{Rails.env}"
# config.active_job.queue_name_prefix = "ambienteja_production"
config.action_mailer.perform_caching = false
@@ -90,4 +91,25 @@ Rails.application.configure do
# 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

@@ -1,11 +1,12 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# 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!
config.cache_classes = true
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
@@ -21,6 +22,7 @@ Rails.application.configure do
# 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
@@ -28,7 +30,7 @@ Rails.application.configure do
# 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
# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test
config.action_mailer.perform_caching = false
@@ -41,6 +43,6 @@ Rails.application.configure do
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
end

View File

@@ -1,10 +1,12 @@
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 = "Ambienteja"
config.site_title = "Ambiente"
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
@@ -110,7 +112,8 @@ ActiveAdmin.setup do |config|
#
# 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
@@ -118,13 +121,13 @@ ActiveAdmin.setup do |config|
#
# 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
config.comments = false
#
# You can change the name under which comments are registered:
# config.comments_registration_name = 'AdminComment'
@@ -163,7 +166,10 @@ ActiveAdmin.setup do |config|
#
# Set the localize format to display dates and times.
# To understand how to localize your app with I18n, read more at
# https://github.com/svenfuchs/i18n/blob/master/lib%2Fi18n%2Fbackend%2Fbase.rb#L52
# 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
@@ -283,12 +289,25 @@ ActiveAdmin.setup do |config|
# config.filters = true
#
# By default the filters include associations in a select, which means
# that every record will be loaded for each association.
# 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

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

@@ -13,4 +13,4 @@ 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( admin.js admin.css )
Rails.application.config.assets.precompile += %w( application.js application.css admin.js admin.css )

View File

@@ -8,7 +8,7 @@ Devise.setup do |config|
# 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 = '8827c6d808b872254a07d83e789fb5d042e98ac355847e64d682affb32e9c8ebd5d3edbbfd48f88894e8efaba71021e9a5cd32ac9acdcd06a62bb1bed110abcc'
# config.secret_key = '864f9f1c691528e65ef9e70895d1f68638f5f70479a5a9e0b5da0af35fca408cba42e50bf111536afde21416c09e201cc1268d2bdfb877a5b32657740a02264c'
# ==> Controller configuration
# Configure the parent class to the devise controllers.
@@ -114,7 +114,7 @@ Devise.setup do |config|
config.stretches = Rails.env.test? ? 1 : 11
# Set up a pepper to generate the hashed password.
# config.pepper = '1c20c1ec9311917f0bac92310a31e36499ab83ef7a2d148dba06e7b6f607c4bfdbeebdb6ecd4c60d878338fda1227af8b47db0a51d79f9aec23b162897f59dfe'
# config.pepper = '1991c71bc9a57b1ab03a829a16557f3f90e9491604f5b4daee96027234916b099e48dbddb922e0dff830b4e9ef319d17379459030ca795ab3f05712f59628171'
# Send a notification to the original email when the user's email is changed.
# config.send_email_changed_notification = false

View File

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

View File

@@ -42,7 +42,7 @@ en:
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 confirm link to confirm your new email address."
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:

View File

@@ -27,7 +27,7 @@
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
# 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,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

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

Some files were not shown because too many files have changed in this diff Show More