<%= notice %>
<%= alert %>
- <%= yield %> -diff --git a/.gitignore b/.gitignore index 4a4d70e..107bdfa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # Ignore the default SQLite database. /db/*.sqlite3 - +/db/*.sql # Ignore all logfiles and tempfiles. /log/*.log /tmp @@ -19,4 +19,4 @@ # ignore paperclip installation files public/system -.project \ No newline at end of file +.project diff --git a/Gemfile b/Gemfile index ec2ba7b..18a50fc 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development, :test do end group :production do - gem 'pg' + gem 'pg' end diff --git a/Gemfile.lock b/Gemfile.lock index fd905dc..b9db210 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.18) - multi_json (1.3.1) + multi_json (1.2.0) orm_adapter (0.0.7) paperclip (3.0.2) activemodel (>= 3.0.0) diff --git a/app/assets/images/author.png b/app/assets/images/author.png new file mode 100644 index 0000000..21c0b4b Binary files /dev/null and b/app/assets/images/author.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 84d87a2..3928339 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,3 +14,29 @@ //= require cleditor //= require jquery_ujs //= require_tree . + +function createMap(lat,lng,zoom) { + + // Store my position (“y=mylat”, “x=mylong”) in variable “lating” + var latlng = new google.maps.LatLng(lat, lng); + // Define my Google Maps options in variable “myOptions” + var myOptions = { + zoom: zoom, // Define scale + center: latlng, // Define map center + mapTypeId: google.maps.MapTypeId.ROADMAP // tipo Roadmad, Satellite, Terrain, Hybrid + }; + var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); + return map; +} + +function addMarkerToMap(map,lat,lng,title) { + // Store my position (“y=mylat”, “x=mylong”) in variable “lating” + var latlng = new google.maps.LatLng(lat, lng); + // Add marker in Google Maps “map” in position defined by “lating” + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title: title + }); + return false; +} \ No newline at end of file diff --git a/app/assets/javascripts/site_map.js b/app/assets/javascripts/site_map.js new file mode 100644 index 0000000..2d92572 --- /dev/null +++ b/app/assets/javascripts/site_map.js @@ -0,0 +1,12 @@ +function siteMapFunction() { + + var lat = $("#latitude").html(); + var lng = $("#longitude").html(); + var zoom = parseInt($("#zoom").html()); + + map = createMap(lat,lng,zoom); + addMarkerToMap(map,lat,lng); + + return false; +} + diff --git a/app/assets/javascripts/trip_map.js b/app/assets/javascripts/trip_map.js new file mode 100644 index 0000000..1c4a2c8 --- /dev/null +++ b/app/assets/javascripts/trip_map.js @@ -0,0 +1,17 @@ +function tripMapFunction() { + // Creates a default map + map = createMap(0,0,1); + + // Get the values for each + $(".list_parameters").each(function(index,element) { + + var lat = $("#latitude",$(this)).html(); + var lng = $("#longitude",$(this)).html(); + var title = $("#name",$(this)).html(); + + addMarkerToMap(map,lat,lng,title); + }); + + return false; +} + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 50d53e3..06670a3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,3 +12,14 @@ *= require cleditor *= require_tree . */ + +.search_box { + font-size:15px; + float:right; + color: black; + padding-left:15px; +} + +#min_visits { + width:70%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css index ead053a..d7ff0b2 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -1,5 +1,6 @@ /* Global styles (no utilizados de momento) */ + #planet #notice { color: #000; border: 2px solid red; @@ -16,6 +17,12 @@ border-bottom: 3px dotted #77d; } +/* Types */ + +.types_list li{ + margin-left:-25px; +} + /* Styles for products/index */ #site_list table { @@ -167,3 +174,6 @@ text-indent: 70%; } +.hidden { + display:none; +} \ No newline at end of file diff --git a/app/assets/stylesheets/planet.css.scss b/app/assets/stylesheets/planet.css.scss index 749d901..592413f 100644 --- a/app/assets/stylesheets/planet.css.scss +++ b/app/assets/stylesheets/planet.css.scss @@ -1,3 +1,7 @@ -// Place all the styles related to the planet controller here. +// Place all the styles related to the Planet controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +#search_visits { + width:70%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss index 682e55c..df6f526 100644 --- a/app/assets/stylesheets/sites.css.scss +++ b/app/assets/stylesheets/sites.css.scss @@ -1,3 +1,9 @@ // Place all the styles related to the sites controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +.site_map { + float:right; + width: 500px; + height: 300px; +} \ No newline at end of file diff --git a/app/assets/stylesheets/trips.css.scss b/app/assets/stylesheets/trips.css.scss index 473cbc3..c3044dc 100644 --- a/app/assets/stylesheets/trips.css.scss +++ b/app/assets/stylesheets/trips.css.scss @@ -1,3 +1,8 @@ // 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/ + +.trip_map { + width: 900px; + height: 500px; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..1fc83b1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,12 @@ class ApplicationController < ActionController::Base protect_from_forgery + + before_filter :get_types + + private #----------------------- + + def get_types + @types = Type.find(:all) + end + end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..0f5436e 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -26,8 +26,42 @@ def index # Método que define una acción vacía del controlador def contact end - # Método que define una acción vacía del controlador + + def author + end + + def ejemplo end - + + def minsearch + if params[:min_visits].nil? || params[:min_visits].empty? || Integer(params[:min_visits]) < 2 + flash[:notice] = "Busqueda no realizada informar numero minimo" + else + @sites = Site.find(:all, + :conditions => ["visitas > ?", params[:min_visits]]) + if @sites.nil? + flash[:notice] = "Busqueda no resulto viajes con el numero minimo de viajes" + else + flash[:notice] = "Busqueda realizada con suceso" + end + end + end + + def topsearch + if params[:query].nil? || params[:query].empty? || params[:query].length < 3 + flash[:notice] = "Busqueda no realizada informar numero minimo" + else + @sites = Site.find(:all, + :conditions => ["name LIKE ? OR description LIKE ?", "%"+params[:query]+"%", "%"+params[:query]+"%"]) + @trips = Trip.find(:all, + :conditions => ["name LIKE ? OR description LIKE ?", "%"+params[:query]+"%", "%"+params[:query]+"%"]) + if (@sites.nil?||@sites.empty?) && (@trips.nil?||@trips.empty?) + flash[:notice] = "Busqueda no resulto viajes con el numero minimo de viajes" + else + flash[:notice] = "Busqueda realizada con suceso" + end + end + end + end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..9c29085 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -9,8 +9,10 @@ class SitesController < ApplicationController def index if params[:type_id].nil? or params[:type_id].empty? @sites = Site.all # path: /types - else + @page_title = 'Todos los Sitios' + else @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + @page_title = Type.find(params[:type_id]).name end respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..b285d21 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -9,6 +9,15 @@ def index format.json { render json: @types } end end + + def ordered + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # ordered.html.erb + format.json { render json: @types } + end + end # GET /types/1 # GET /types/1.json diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..8421e7f 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,14 +1,16 @@ class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user has_many :visits has_many :trips, :through => :visits has_attached_file :image - # Debe estar protegido para evitar accesos indeseados attr_protected :user_id # Se añaden estas definiciones validates :name, :type_id, :presence => true # campo obligatorio + end diff --git a/app/models/type.rb b/app/models/type.rb index 2284d1f..862751c 100644 --- a/app/models/type.rb +++ b/app/models/type.rb @@ -1,8 +1,9 @@ class Type < ActiveRecord::Base - has_many :sites - + + has_many :sites # Se añade esta definición de recurso validates :name, :description, :presence => true # campo obligatorio validates :name, :uniqueness => true # Campo único (no repetido) + end diff --git a/app/views/layouts/_form.html.erb b/app/views/layouts/_form.html.erb new file mode 100644 index 0000000..37c9d08 --- /dev/null +++ b/app/views/layouts/_form.html.erb @@ -0,0 +1,6 @@ +
Minimo:
+ <%= form_tag planet_minsearch_path, :method => "get", :id => "searchbox" do %>
+ <%= text_field_tag :min_visits %>
+ (Visitas)
+ <%= submit_tag :buscar %>
+ <% end %>
+
<%= notice %>
<%= alert %>
- <%= yield %> -<%= notice %>
<%= alert %>
+ <%= yield %>>>Personal data:
+>>Simple Curriculum Vitae:
+To contact us send us an email to:
or call us at: 615 783 567
\ No newline at end of file +To contact us send us an email to:
+ + + +or call us at: 615 783 567
\ No newline at end of file diff --git a/app/views/planet/ejemplo.html.erb b/app/views/planet/ejemplo.html.erb index cb05eb9..6efb9e3 100644 --- a/app/views/planet/ejemplo.html.erb +++ b/app/views/planet/ejemplo.html.erb @@ -1,3 +1,14 @@ -También podemos generar un enlace al recurso (página) Home con el siguiente hiperenlace: <%= link_to('Home', planet_index_path) %>
Rails ejecuta el código Ruby y lo inserta en la página HTML antes de generar la página.
\ No newline at end of file +El formato ERb o .erb es HTML extendido con anotaciones Ruby, delimitadas por <% o <%= y %> , como en el siguiente ejemplo + +También podemos generar un enlace al recurso (página) Home con el siguiente hiperenlace: <%= link_to('Home', planet_index_path) %>
+ +Rails ejecuta el código Ruby y lo inserta en la página HTML antes de generar la página.
\ No newline at end of file diff --git a/app/views/planet/index.html.erb b/app/views/planet/index.html.erb index bbee722..6caf368 100644 --- a/app/views/planet/index.html.erb +++ b/app/views/planet/index.html.erb @@ -1 +1,15 @@ -This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.
<%= image_tag('pedriza2-m.png') %>Feel free to use it for your convenience and pleasure.
\ No newline at end of file +This site gathers information +of touristic sites from all over +the world and should help you to +organize your trips and your holidays. + +
+ +<%= image_tag('pedriza2-m.png') %> + +Feel free to use it for your +convenience and pleasure.
diff --git a/app/views/planet/minsearch.html.erb b/app/views/planet/minsearch.html.erb new file mode 100644 index 0000000..0be4696 --- /dev/null +++ b/app/views/planet/minsearch.html.erb @@ -0,0 +1,34 @@ +| + <%= link_to image_tag(site.image.url, :class => 'list_image'), site %> + | + +
+
|
+
+
+ <%= link_to 'Show', site %> + <% if site.user == current_user %> + <%= link_to 'Edit', edit_site_path(site) %> + <%= link_to 'Destroy', site, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> + |
+
| + <%= link_to image_tag(site.image.url, :class => 'list_image'), site %> + | + +
+
|
+
+
+ <%= link_to 'Show', site %> + <% if site.user == current_user %> + <%= link_to 'Edit', edit_site_path(site) %> + <%= link_to 'Destroy', site, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> + |
+
+
|
+
+
+ <%= link_to 'Show', trip %> + <% if trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(trip) %> + <%= link_to 'Destroy', trip, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> + |
+
Position:
+ LAT: <%= @site.latitude %> LONG: <%= @site.longitude %>
<%=sanitize @site.description %>
-Autor: <%= @site.user.name if @site.user %>
+Autor: + <%= @site.user.name if @site.user %> +
+ + +| + | <%= link_to image_tag(visit.site.image.url, :class => 'list_image'), visit.site %> + <%=visit.site.latitude%> + <%=visit.site.latitude%> + <%=visit.site.name%> | @@ -20,7 +23,6 @@ <%= link_to 'Destroy', visit, :confirm => 'Are you sure?', :method => :delete if trip.user == current_user %> - |
|
diff --git a/app/views/types/ordered.html.erb b/app/views/types/ordered.html.erb
new file mode 100644
index 0000000..bfef516
--- /dev/null
+++ b/app/views/types/ordered.html.erb
@@ -0,0 +1,30 @@
+
+
|
+
+
+ <%= link_to 'Show', type %> + <%= link_to 'Edit', edit_type_path(type) %> + <%= link_to 'Destroy', type, + :confirm => 'Are you sure?', + :method => :delete %> + |
+
+ Updated on: + <%= @type.updated_at %> +
+ <%= link_to 'Edit', edit_type_path(@type) %> | <%= link_to 'Back', types_path %> diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 2a0abc5..feda6ab 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -Planet::Application.config.secret_token = '1d0b0986958355469c26d5d36d0531ad5dccaa0483eefce0085cc8d90ae919113f57fc251d0a77dbcbe194736ae1f33a77fd54e95f4c72eb4851fdb4749f2b4a' +Planet::Application.config.secret_token = '9cebd658c9119c8a78b70df4e493ea66273b67ed0dc7402c15ebb2ebc9bb8f37c25f36decea6590d604aee7c596721eebe3f80bb510ab75d283cf6f837cf474c' diff --git a/config/routes.rb b/config/routes.rb index 29d3c86..b1b891f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,14 +9,24 @@ resources :sites resources :types do # Rutas anidadas /types/id/sites..., - resources :sites, :only => [ :index ] # Restringe a acción “index” + resources :sites, :only => [ :index ] # Restringe a acción “index” + collection do + get 'ordered' # Adds the ordered view to the routing + end end + # Planet Controller get "planet/index" - + get "planet/author" get "planet/contact" - get "planet/ejemplo" + get "planet/minsearch" + get "planet/topsearch" + + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => 'planet#index' # The priority is based upon order of creation: # first created -> highest priority. @@ -65,15 +75,9 @@ # resources :products # end - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. - # root :to => 'welcome#index' - - root :to => "planet#index" - # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id(.:format)))' + # match ':controller(/:action(/:id))(.:format)' end diff --git a/db/migrate/20120320100145_create_sites.rb b/db/migrate/20120320100145_create_sites.rb index 823209a..b148233 100644 --- a/db/migrate/20120320100145_create_sites.rb +++ b/db/migrate/20120320100145_create_sites.rb @@ -5,6 +5,9 @@ def change t.text :description t.integer :type_id t.string :image_url + t.float :longitude + t.float :latitude + t.float :zoom t.timestamps end diff --git a/db/migrate/20120317231537_create_types.rb b/db/migrate/20120327180813_create_types.rb similarity index 78% rename from db/migrate/20120317231537_create_types.rb rename to db/migrate/20120327180813_create_types.rb index fb4b514..d880426 100644 --- a/db/migrate/20120317231537_create_types.rb +++ b/db/migrate/20120327180813_create_types.rb @@ -7,4 +7,8 @@ def change t.timestamps end end + + def self.down + drop_table :types + end end diff --git a/db/schema.rb b/db/schema.rb index e6aa66f..aa1acbf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -18,6 +18,9 @@ t.text "description" t.integer "type_id" t.string "image_url" + t.float "longitude" + t.float "latitude" + t.float "zoom" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "user_id" diff --git a/db/seeds.rb b/db/seeds.rb index 2bda1ab..41516ee 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -35,6 +35,12 @@ email: 'javier.sedano@me.com', password: 'sedano22', password_confirmation: 'sedano22') + +user2 = User.create!( + name: 'Fausto Rodrigues', + email: 'f4usto@gmail.com', + password: '123qwe', + password_confirmation: '123qwe') Site.delete_all @@ -44,6 +50,9 @@ description: 'Magnifico valle al norte de Madrid en el Macizo Central', type_id: type2.id, image_url: 'pedriza.png', + longitude: 40.0, + latitude: 34.0, + zoom: 5, image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pedriza.png'), "r")) site1.user_id = user1.id ; site1.save @@ -52,6 +61,9 @@ description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento', type_id: type1.id, image_url: 'florencia.png', + longitude: 10.0, + latitude: -20.0, + zoom: 5, image: File.open(File.join(Rails.root, 'app', 'assets','images', 'florencia.png'), "r")) site2.user_id = user1.id ; site2.save @@ -60,6 +72,9 @@ description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista tenia su coleccion de plantas', type_id: type1.id, image_url: 'arbol1.png', + longitude: 80.0, + latitude: 10.0, + zoom: 5, image: File.open(File.join(Rails.root, 'app', 'assets','images', 'arbol1.png'), "r")) site3.user_id = user2.id ; site3.save @@ -68,6 +83,9 @@ description: 'Parlamento aleman en la ciudad de Berlin', type_id: type2.id, image_url: 'reichstag.png', + longitude: -53.0, + latitude: -78.0, + zoom: 5, image: File.open(File.join(Rails.root, 'app', 'assets','images', 'reichstag.png'), "r")) site4.user_id = user2.id ; site4.save @@ -76,11 +94,13 @@ description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin', type_id: type3.id, image_url: 'pergamo.png', + longitude: 35.0, + latitude: 35.0, + zoom: 5, image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pergamo.png'), "r")) site5.user_id = user1.id ; site5.save - Trip.delete_all trip1 = Trip.create!( @@ -112,6 +132,3 @@ hour: '16') visit3.trip_id = trip1.id visit3.site_id = site4.id ; visit3.save - - - diff --git a/planet.tmproj b/planet.tmproj new file mode 100644 index 0000000..85ee38e --- /dev/null +++ b/planet.tmproj @@ -0,0 +1,193 @@ + + +