Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1ad6cd
commit 06cab03
Showing
25 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
about | ||
app:template | ||
app:update | ||
assets:clean[keep] | ||
assets:clobber | ||
assets:environment | ||
assets:precompile | ||
cache_digests:dependencies | ||
cache_digests:nested_dependencies | ||
db:create | ||
db:drop | ||
db:environment:set | ||
db:fixtures:load | ||
db:migrate | ||
db:migrate:status | ||
db:rollback | ||
db:schema:cache:clear | ||
db:schema:cache:dump | ||
db:schema:dump | ||
db:schema:load | ||
db:seed | ||
db:setup | ||
db:structure:dump | ||
db:structure:load | ||
db:version | ||
dev:cache | ||
initializers | ||
log:clear | ||
middleware | ||
notes | ||
notes:custom | ||
restart | ||
routes | ||
secret | ||
stats | ||
test | ||
test:db | ||
test:system | ||
time:zones[country_or_offset] | ||
tmp:clear | ||
tmp:create | ||
yarn:install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the Pages controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
margin: 33px; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { | ||
color: #000; | ||
|
||
&:visited { | ||
color: #666; | ||
} | ||
|
||
&:hover { | ||
color: #fff; | ||
background-color: #000; | ||
} | ||
} | ||
|
||
th { | ||
padding-bottom: 5px; | ||
} | ||
|
||
td { | ||
padding: 0 5px 7px; | ||
} | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px 7px 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
|
||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px -7px 0; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
} | ||
|
||
label { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class PagesController < ApplicationController | ||
before_action :set_page, only: [:find, :show, :update] | ||
|
||
def find | ||
if(@page.nil?) | ||
@page = Page.new(page_params) | ||
@page.save | ||
end | ||
|
||
render "show" | ||
end | ||
|
||
|
||
# RAILS STUFF | ||
|
||
# GET /pages/1 | ||
# GET /pages/1.json | ||
def show | ||
end | ||
|
||
# PATCH/PUT /pages/1 | ||
# PATCH/PUT /pages/1.json | ||
def update | ||
# puts "ENTROU NO LUGAR" | ||
respond_to do |format| | ||
if @page.update(page_params) | ||
format.html { } | ||
format.json { } | ||
else | ||
# format.html { render :edit } | ||
# format.json { render json: @page.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_page | ||
@page = Page.find_by(url: params[:url]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def page_params | ||
params.permit(:content, :url) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PagesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Page < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%= form_with(model: page, local: true) do |form| %> | ||
<% if page.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(page.errors.count, "error") %> prohibited this page from being saved:</h2> | ||
|
||
<ul> | ||
<% page.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :content %> | ||
<%= form.text_area :content, id: :page_content %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :url %> | ||
<%= form.text_field :url, id: :page_url %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! page, :id, :content, :url, :created_at, :updated_at | ||
json.url page_url(page, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Page</h1> | ||
|
||
<%= render 'form', page: @page %> | ||
<%= link_to 'Show', @page %> | | ||
<%= link_to 'Back', pages_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Pages</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Content</th> | ||
<th>Url</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @pages.each do |page| %> | ||
<tr> | ||
<td><%= page.content %></td> | ||
<td><%= page.url %></td> | ||
<td><%= link_to 'Show', page %></td> | ||
<td><%= link_to 'Edit', edit_page_path(page) %></td> | ||
<td><%= link_to 'Destroy', page, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Page', new_page_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @pages, partial: 'pages/page', as: :page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Page</h1> | ||
|
||
<%= render 'form', page: @page %> | ||
<%= link_to 'Back', pages_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h1>Dontfile</h1> | ||
<h4>Though it's just a dontpad for now...</h4> | ||
|
||
<textarea id="content" style="width: 100%; min-height: 400px;" oninput="save()" | ||
data-path="<%= @page.url %>" | ||
> | ||
<%= @page.content %> | ||
</textarea> | ||
|
||
<script> | ||
function save() { | ||
var element = document.getElementById("content"); | ||
var path = "/" + element.getAttribute("data-path"); | ||
var value = element.value; | ||
|
||
console.log(path); | ||
|
||
$.ajax({ | ||
url: path, | ||
type: "PATCH", | ||
data: { | ||
url: path, | ||
content: value | ||
}, | ||
success: function(resp) { | ||
console.log("foi carai"); | ||
} | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "pages/page", page: @page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
Rails.application.routes.draw do | ||
# resources :pages | ||
|
||
get '/:url', to: 'pages#find' | ||
patch '/:url', to: 'pages#update' | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreatePages < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :pages do |t| | ||
t.text :content | ||
t.string :url | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20180406161044) do | ||
|
||
# These are extensions that must be enabled in order to support this database | ||
enable_extension "plpgsql" | ||
|
||
create_table "pages", force: :cascade do |t| | ||
t.text "content" | ||
t.string "url" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
end |
Oops, something went wrong.