Skip to content

Entrega 6 Daniel Rubio Mesa #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gem 'rails', '3.2.2'

gem 'sqlite3'

gem 'devise'


# Gems used only for assets and not required
# in production environments by default.
Expand All @@ -22,6 +24,8 @@ end

gem 'jquery-rails'

gem 'cleditor_rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

Expand Down
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
builder (3.0.0)
cleditor_rails (0.0.3)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
devise (2.0.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1.1)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
Expand All @@ -53,6 +61,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.1.0)
orm_adapter (0.0.7)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
Expand Down Expand Up @@ -89,6 +98,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
sqlite3 (1.3.5-x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -98,12 +108,17 @@ GEM
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warden (1.1.1)
rack (>= 1.0)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
cleditor_rails
coffee-rails (~> 3.2.1)
devise
jquery-rails
rails (= 3.2.2)
sass-rails (~> 3.2.3)
Expand Down
Binary file added app/assets/images/danielrubio.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/email.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/juanquemada.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/juanquemada2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/telefono.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require cleditor
//= require jquery_ujs
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/comments.js.coffee
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://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/trips.js.coffee
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://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/javascripts/visits.js.coffee
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://jashkenas.github.com/coffee-script/
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require cleditor
*= require_tree .
*/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/comments.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
39 changes: 39 additions & 0 deletions app/assets/stylesheets/planet.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
border-bottom: 3px dotted #77d;
}

/* Estilos para el resto de cabeceras definidas en author*/
#planet h2 {
font: 135% sans-serif;
font-weight: bold;
color: #226;
}

#planet h3 {
font: 110% sans-serif;
font-weight: bold;
color: #226;
}

/* Styles for products/index */

#site_list table {
Expand Down Expand Up @@ -78,6 +91,13 @@
text-align: center;
}

/* Estilo para el banner de registro de usuarios */
#banner .user {
float: right;
color: #bfb;
font-size: small;
}

#banner img {
float: left;
padding-left: 10px;
Expand All @@ -91,6 +111,7 @@
margin-left: 9em; /* Ajuste de borde izquierdo */
padding-top: 4ex;
padding-left: 2em;
padding-bottom: 4ex;
background: white;
}

Expand All @@ -107,6 +128,24 @@
color: #bfb;
font-size: small;
}

#header_links { /* Estilos para los hiperenlaces superiores e inferiores*/
position: top;
background: #bfb;
border: 1px solid;
font: small-caps 16px/16px "Times New Roman", serif;
text-align: left;
}

#footer_links {
position: bottom;
background: #bfb;
border: 1px solid;
font: small-caps 16px/16px "Times New Roman", serif;
text-align: left;
}


/* END:mainlayout */

/* An entry in the store catalog (no utilizados de momento) */
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/trips.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the trips controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/visits.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the visits controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
91 changes: 91 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
class CommentsController < ApplicationController

# authenticate_user! ejecuta acción sólo si sesión existe
before_filter :authenticate_user!,:except=> [:index,:show]

# GET /comments
# GET /comments.json
def index
if params[:site_id].nil? or params[:site_id].empty?
@comments = Comment.all
else
@comments = Site.find(params[:site_id]).comments
end

respond_to do |format|
format.html # index.html.erb
format.json { render json: @comments }
end
end

# GET /comments/1
# GET /comments/1.json
def show
@comment = Comment.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @comment }
end
end

# GET /comments/new
# GET /comments/new.json
def new
@comment = current_user.comments.build #cambio comment por current_user.comments.build -- crea comentario vacio asociado a current_user

respond_to do |format|
format.html # new.html.erb
format.json { render json: @comment }
end
end

# GET /comments/1/edit
def edit
@comment = current_user.comments.find(params[:id]) #cambio Comment por current_user.comments -- busca solo en comentarios asociados a current_user
end

# POST /comments
# POST /comments.json
def create
@comment = current_user.comments.build(params[:comment]) #cambio Comment.new por current_user.comments.build -- asigna solo si comentario asociado a current_user

respond_to do |format|
if @comment.save
format.html { redirect_to @comment, notice: 'Comment was successfully created.' }
format.json { render json: @comment, status: :created, location: @comment }
else
format.html { render action: "new" }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end

# PUT /comments/1
# PUT /comments/1.json
def update
@comment = current_user.comments.find(params[:id]) #cambio Comment por current_user.comments.-- busca solo en comentarios asociados a current_user

respond_to do |format|
if @comment.update_attributes(params[:comment])
format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end

# DELETE /comments/1
# DELETE /comments/1.json
def destroy
@comment = current_user.comments.find(params[:id]) #cambiar Comment por current_user.comments -- busca solo en comentarios asociados a current_user
@comment.destroy

respond_to do |format|
format.html { redirect_to sites_url } #cambiar por sites_comments_url¿?¿?
format.json { head :no_content }
end
end
end
4 changes: 4 additions & 0 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ def contact

def ejemplo
end

# GET /planet/author
def author
end

end
38 changes: 32 additions & 6 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
class SitesController < ApplicationController

# authenticate_user! ejecuta acción sólo si sesión existe
before_filter :authenticate_user!, :except => [:index, :show, :search]

#filtro para contador de visitas
after_filter :count_visit, :only => :show

# Función de búsqueda en sitios y comentarios
# GET /sites/search
# GET /sites/search.json
def search
#@sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%")

#respond_to do |format|
# format.html # search.html.erb
# format.json { render json: @sites }
#end
end

# GET /sites
# GET /sites.json
def index
Expand All @@ -7,6 +26,7 @@ def index
else
@sites = Type.find(params[:type_id]).sites # path: /types/id/sites
end

respond_to do |format|
format.html # index.html.erb
format.json { render json: @sites }
Expand All @@ -27,7 +47,7 @@ def show
# GET /sites/new
# GET /sites/new.json
def new
@site = Site.new
@site = current_user.sites.build #cambio Site por current_user.sites.build -- crea sitio vacio asociado a current_user

respond_to do |format|
format.html # new.html.erb
Expand All @@ -37,13 +57,13 @@ def new

# GET /sites/1/edit
def edit
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id]) #cambio Site por current_user.sites -- busca solo en sitios asociados a current_user
end

# POST /sites
# POST /sites.json
def create
@site = Site.new(params[:site])
@site = current_user.sites.build(params[:site]) #cambio Site.new por current_user.sites.build -- asigna solo si sitio asociado a current_user

respond_to do |format|
if @site.save
Expand All @@ -59,7 +79,7 @@ def create
# PUT /sites/1
# PUT /sites/1.json
def update
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id]) #cambio Site por current_user.sites.-- busca solo en sitios asociados a current_user

respond_to do |format|
if @site.update_attributes(params[:site])
Expand All @@ -75,12 +95,18 @@ def update
# DELETE /sites/1
# DELETE /sites/1.json
def destroy
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id]) #cambiar Site por current_user.sites -- busca solo en sitios asociados a current_user
@site.destroy

respond_to do |format|
format.html { redirect_to sites_url }
format.json { head :no_content }
end
end
end

private
#definicion de la funcion contadora de visitas
def count_visit
@site.increment(:visits)
end
end
Loading