Skip to content
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

Entrega 8 Luis Martínez Gallego SWCM #67

Open
wants to merge 14 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

# ignore al .DS_store files of MAC OSX
.DS_Store
#ignore paperclip installation files
public/system
.project
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ gem 'rails', '3.2.2'

gem 'sqlite3'

gem 'paperclip'

gem 'devise'

gem 'jquery-rails'

gem 'cleditor_rails'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
19 changes: 19 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)
builder (3.0.0)
cleditor_rails (0.0.3)
cocaine (0.2.1)
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,12 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.1.0)
orm_adapter (0.0.7)
paperclip (2.4.5)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
mime-types
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
Expand Down Expand Up @@ -98,13 +112,18 @@ GEM
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warden (1.1.1)
rack (>= 1.0)

PLATFORMS
ruby

DEPENDENCIES
cleditor_rails
coffee-rails (~> 3.2.1)
devise
jquery-rails
paperclip
rails (= 3.2.2)
sass-rails (~> 3.2.3)
sqlite3
Expand Down
Binary file added app/assets/images/fotocarnet.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/comentarios.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/comentarios.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the comentarios controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
64 changes: 64 additions & 0 deletions app/assets/stylesheets/planet.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,56 @@
font: bold smaller sans-serif;
}

#comentarios a {font-weight:bold;
color:black;
font: 105% sans-serif;
}
#links a { color : #555;}


#search {

position: relative;
width: 310px;
top: 5px;
left: 5px;




}

#search .notice {

color : red;

}

#links {

text-align:center;
margin-top: 10px;
margin-bottom: 10px;
word-spacing:25pt;

}
#map_canvas {
height: 300pt;
width: 300pt;
}



#cv {font:sans-serif;}

#personal-data {font:sans-serif;}

#personal-data img {
padding-bottom:60px;
padding-right:30px;
float:left;
}


#planet h1 {
font: 150% sans-serif;
Expand Down Expand Up @@ -71,6 +121,7 @@
#banner {
background: #668;
padding-top: 10px;

padding-bottom: 10px;
border-bottom: 2px solid;
font: small-caps 40px/40px "Times New Roman", serif;
Expand All @@ -83,6 +134,19 @@
padding-left: 10px;
}

#banner .user {
margin-top: 50px;
margin-right:20px;
float: right;
color: #bfb;
font-size: small;

}

#banner .user a {
color:#555;
}

#columns {
background: #446;
}
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/
99 changes: 99 additions & 0 deletions app/controllers/comentarios_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
class ComentariosController < ApplicationController
# GET /comentarios
# GET /comentarios.json
before_filter :authenticate_user!, :except => [:index,:show]
def index




@comentarios = Site.find(params[:site_id]).comentarios # path: /types/id/sites




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

end
end

# GET /comentarios/1
# GET /comentarios/1.json
def show
@comentario = Comentario.find(params[:id])

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

# GET /comentarios/new
# GET /comentarios/new.json
def new

@comentario = current_user.comentarios.build



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

# GET /comentarios/1/edit
def edit
@comentario = current_user.comentarios.find(params[:id])

end

# POST /comentarios
# POST /comentarios.json
def create

@comentario = current_user.comentarios.build(params[:comentario])#creamos un comentario con lo que nos pasa el formulario
@comentario.site_id = params[:site_id]

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

# PUT /comentarios/1
# PUT /comentarios/1.json
def update
@comentario = current_user.comentarios.find(params[:id]) #cogemos el comentario a actualizar


respond_to do |format|
if @comentario.update_attributes(params[:comentario])#intentamos actualizar el comentario con el pasado por el formulario
format.html { redirect_to site_comentarios_path(@comentario.site) , notice: 'Comentario was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @comentario.errors, status: :unprocessable_entity }
end
end
end

# DELETE /comentarios/1
# DELETE /comentarios/1.json
def destroy
@comentario = current_user.comentarios.find(params[:id])
@comentario.destroy

respond_to do |format|
format.html { redirect_to site_comentarios_path(@comentario.site) }
format.json { head :no_content }
end
end
end
20 changes: 20 additions & 0 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
class PlanetController < ApplicationController
# GET /planet/index

def index
end

def search
busqueda = params[:busqueda]
if busqueda.length < 3
flash[:notice] = "Debe introducir al menos 3 caracteres"
redirect_to planet_index_path
end
@sites= Site.where("name like ? or description like ?" , "%" + params[:busqueda] + "%" , "%" + params[:busqueda] + "%")
@trips= Trip.where("name like ? or description like ?" , "%" + params[:busqueda] + "%" , "%" + params[:busqueda] + "%")
end
# GET /planet/contact

def contact
end

# GET /planet/ejemplo

def ejemplo
end

# GET /planet/author

def author
end

end
17 changes: 12 additions & 5 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
class SitesController < ApplicationController

after_filter :count_visit, :only => :show

def count_visit
@site.increment!(:visitas)
end
before_filter :authenticate_user!, :except => [:index,:show]
# GET /sites
# GET /sites.json
def index
Expand Down Expand Up @@ -27,7 +34,7 @@ def show
# GET /sites/new
# GET /sites/new.json
def new
@site = Site.new
@site = current_user.sites.build #crea sitio vacio asociado a current user

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

# GET /sites/1/edit
def edit
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id])
end

# POST /sites
# POST /sites.json
def create
@site = Site.new(params[:site])
@site = current_user.sites.build(params[:site])

respond_to do |format|
if @site.save
Expand All @@ -59,7 +66,7 @@ def create
# PUT /sites/1
# PUT /sites/1.json
def update
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id])

respond_to do |format|
if @site.update_attributes(params[:site])
Expand All @@ -75,7 +82,7 @@ def update
# DELETE /sites/1
# DELETE /sites/1.json
def destroy
@site = Site.find(params[:id])
@site = current_user.sites.find(params[:id])
@site.destroy

respond_to do |format|
Expand Down
Loading