diff --git a/Gemfile b/Gemfile index 01b976d..5a31f96 100644 --- a/Gemfile +++ b/Gemfile @@ -10,10 +10,12 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.2' gem 'bootsnap', '>= 1.1.0', require: false -gem 'haml-rails' +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] diff --git a/Gemfile.lock b/Gemfile.lock index c74effb..648d6d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,6 +57,7 @@ GEM 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) @@ -83,7 +84,6 @@ GEM responders warden (~> 1.2.3) erubi (1.8.0) - erubis (2.7.0) execjs (2.7.0) ffi (1.11.1) formtastic (3.1.5) @@ -94,20 +94,9 @@ GEM haml (5.1.1) temple (>= 0.8.0) tilt - haml-rails (2.0.1) - actionpack (>= 5.1) - activesupport (>= 5.1) - haml (>= 4.0.6, < 6.0) - html2haml (>= 1.0.1) - railties (>= 5.1) has_scope (0.7.2) actionpack (>= 4.1) activesupport (>= 4.1) - html2haml (2.2.0) - erubis (~> 2.7.0) - haml (>= 4.0, < 6) - nokogiri (>= 1.6.0) - ruby_parser (~> 3.5) i18n (1.6.0) concurrent-ruby (~> 1.0) inherited_resources (1.10.0) @@ -194,8 +183,6 @@ GEM actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) ruby_dep (1.5.0) - ruby_parser (3.13.1) - sexp_processor (~> 4.9) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -207,7 +194,6 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sexp_processor (4.12.0) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -242,17 +228,19 @@ GEM websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) + will_paginate (3.1.7) PLATFORMS ruby DEPENDENCIES activeadmin + awesome_print bootsnap (>= 1.1.0) byebug coffee-rails (~> 4.2) devise - haml-rails + haml listen (>= 3.0.5, < 3.2) mysql2 puma (~> 3.11) @@ -262,6 +250,7 @@ DEPENDENCIES spring-watcher-listen (~> 2.0.0) uglifier (>= 1.3.0) web-console (>= 3.3.0) + will_paginate RUBY VERSION ruby 2.5.5p157 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 82e6f0f..0a37005 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,7 +10,4 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // -//= require rails-ujs -//= require activestorage -//= require turbolinks //= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index d05ea0f..f33f48b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,15 +1,14 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's - * vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ +body { + padding: 20px; + font-family: 'Inconsolata', monospace; + background-color: #f5fff1; +} + +a { + color:black; +} + +a:hover{ + background-color: black; + color: white; +} diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb new file mode 100644 index 0000000..f36c8d0 --- /dev/null +++ b/app/controllers/page_controller.rb @@ -0,0 +1,11 @@ +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 diff --git a/app/models/informativo.rb b/app/models/informativo.rb new file mode 100644 index 0000000..79d2f2d --- /dev/null +++ b/app/models/informativo.rb @@ -0,0 +1,4 @@ +class Informativo < ApplicationRecord + self.table_name = "informativo" + paginates_per 10 +end diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml new file mode 100644 index 0000000..3ffae2a --- /dev/null +++ b/app/views/layouts/application.haml @@ -0,0 +1,13 @@ +!!! +%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' + %body + + %h1= "Ambiente Já!" + = yield diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 737f724..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - - - - Ambienteja - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> - - - - <%= yield %> - - diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb deleted file mode 100644 index cbd34d2..0000000 --- a/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bdd..0000000 --- a/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/app/views/page/home.haml b/app/views/page/home.haml new file mode 100644 index 0000000..d98311b --- /dev/null +++ b/app/views/page/home.haml @@ -0,0 +1,5 @@ +%h3= "#{@informativos.count} informativos" +- @informativos.each do |i| + %p= link_to "#{i.data_inc} > #{i.titulo}", "/informativo/#{i.id}" + += will_paginate @informativos diff --git a/app/views/page/informativo.haml b/app/views/page/informativo.haml new file mode 100644 index 0000000..8691de5 --- /dev/null +++ b/app/views/page/informativo.haml @@ -0,0 +1,3 @@ +!= @informativo.Descricao +%hr +!= ap @informativo diff --git a/config/application.rb b/config/application.rb index acd3355..8aa0487 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,7 @@ 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. @@ -11,6 +12,10 @@ module Ambienteja # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 + config.generators do |g| + g.template_engine :haml + end + # 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 diff --git a/config/routes.rb b/config/routes.rb index bcfcb87..8c6d477 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,4 +2,9 @@ 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 diff --git a/test/fixtures/admin_users.yml b/test/fixtures/admin_users.yml deleted file mode 100644 index 80aed36..0000000 --- a/test/fixtures/admin_users.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/models/admin_user_test.rb b/test/models/admin_user_test.rb deleted file mode 100644 index 6215c04..0000000 --- a/test/models/admin_user_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class AdminUserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end