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 @@ +
+ +
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4c9e36..72ebf0d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,35 +1,102 @@ - Planet + <%= @page_title || "Planet Travel Site" %> + <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - - + <%# Load google maps API if %> + <% if (params[:controller] == 'sites' || params[:controller] == 'trips')&&(params[:action] == 'show') %> + + <% if params[:controller] == 'sites' %> + <%= javascript_include_tag "site_map" %> + <% else %> + <%= javascript_include_tag "trip_map" %> + <% end %> + <% end %> + + - - + + +
<%= link_to "Home", planet_index_path %>
<%= link_to "Tipos", types_path %>
- <%= link_to "Sitios", sites_path %>
- <%= link_to "Viajes", trips_path %>
+ <%= link_to "Sitios", sites_path %>
+
    + <% @types.each do |type| %> +
  • <%= link_to type.name, type %>
  • + <% end %> +
+ <%= link_to "Viajes", trips_path %>
<%= link_to "Contact", planet_contact_path %>
<%= link_to "Sign up", new_user_registration_path unless current_user %> +

Minimo:
+ <%= form_tag planet_minsearch_path, :method => "get", :id => "searchbox" do %> + <%= text_field_tag :min_visits %>
+ (Visitas) + <%= submit_tag :buscar %> + <% end %> +

-
-

<%= notice %>

<%= alert %>

- <%= yield %> -
+ +
+ + <%= + link_to(' Home ', planet_index_path)+" | "+ + link_to(' Contact ', planet_contact_path)+" | "+ + link_to(' Author ', planet_author_path)+" | "+ + link_to(' Ejemplo ', planet_ejemplo_path)+" | "+ + # Action before the controller on resources! + link_to(' Types', types_path) +" | "+ + link_to(' Ordered Types ', ordered_types_path) + # ordered_types_path) + # [@user, :posts] + %> +
+ +

<%= notice %>

<%= alert %>

+ <%= yield %>
+ + + <%= + link_to(' Home ', planet_index_path)+" | "+ + link_to(' Contact ', planet_contact_path)+" | "+ + link_to(' Author ', planet_author_path)+" | "+ + link_to(' Ejemplo ', planet_ejemplo_path)+" | "+ + link_to(' Types', types_path) +" | "+ + link_to(' Ordered Types ', ordered_types_path) + %> + +
- \ No newline at end of file + diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb new file mode 100644 index 0000000..3f0ee0e --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1,26 @@ +

Author's Page

+ +<%= image_tag('author.png') %> + +

Fausto Rodrigues

+ +
+
+

>>Personal data:

+
    +
  • Name: Fausto Rodrigues
  • +
  • Address: Call Melendez Valdes, 39, Madrid, España
  • +
  • Email: f4usto@gmail.com
  • +
+
+

>>Simple Curriculum Vitae:

+
    +
  • Academic: Universidade de São Paulo (Brasil) / Universidad Politecnica de Madrid (Erasmus)
  • +
  • Professional: TinkerLabs Group - Tiendalista(2012 - Actual)
  • +
  • Programing Skills:C, Assembly, PHP, Javascripts/JQuery, HTML, Ruby/RoR
  • +
  • Interests: Sports, Rollers, Movies
  • +
+ +
+ + diff --git a/app/views/planet/contact.html.erb b/app/views/planet/contact.html.erb index f339edd..7ba029b 100644 --- a/app/views/planet/contact.html.erb +++ b/app/views/planet/contact.html.erb @@ -1 +1,8 @@ -

Contact Planet Travel Site

To contact us send us an email to:

contact@planet.travel.com

or call us at: 615 783 567

\ No newline at end of file +

Contact Planet Travel Site

+ +

To contact us send us an email to:

+ +

+ contact@planet.travel.com

+ +

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 @@ -

ERb: Extended Ruby

El formato ERb o .erb es HTML extendido con anotaciones Ruby, delimitadas por <% o <%= y %> , como en el siguiente ejemplo +

ERb: Extended Ruby

-

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 @@ -

Wecome to the Planet Travel Site

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 +

+Wecome to the Planet Travel Site +

+ +

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 @@ +
+

Busqueda

+ + + <% unless @sites.nil? %> + <% @sites.each do |site| %> + + + + + + + + + <% end %> + <% end %> +
+ <%= link_to image_tag(site.image.url, :class => 'list_image'), site %> + +
+
<%= link_to site.name, site %>
+
<%= truncate(strip_tags(site.description), + :length => 80) %>
+
+
+ <%= 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 %> +
+
diff --git a/app/views/planet/topsearch.html.erb b/app/views/planet/topsearch.html.erb new file mode 100644 index 0000000..340e532 --- /dev/null +++ b/app/views/planet/topsearch.html.erb @@ -0,0 +1,63 @@ +
+

Busqueda

+ + +

Sitios encontrados

+ <% unless @sites.nil? %> + <% @sites.each do |site| %> + + + + + + + + + <% end %> + <% end %> +
+ <%= link_to image_tag(site.image.url, :class => 'list_image'), site %> + +
+
<%= link_to site.name, site %>
+
<%= truncate(strip_tags(site.description), + :length => 80) %>
+
+
+ <%= 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 %> +
+ +
+

Viajes encontrados

+ <% unless @trips.nil? %> + <% @trips.each do |trip| %> + + + + + + + <% end %> + <% end %> +
+
+
<%= link_to trip.name, trip_path(trip) %>
+
<%= truncate(strip_tags(trip.description), + :length => 80) + ', ' + trip.date.to_s %>
+
+
+ <%= 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 %> +
+
diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index f1fd754..c2811b6 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -23,6 +23,18 @@ <%= f.label :type_id %>
<%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %>
+
+ <%= f.label :longitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :latitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
<%= f.label :image %>
<%= f.file_field :image %> diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb index b8e4cae..019f8d6 100644 --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -14,6 +14,7 @@
<%= link_to site.name, site %>
<%= truncate(strip_tags(site.description), :length => 80) %>
+ <%= site.type.name if site.type %> diff --git a/app/views/sites/search.html.erb b/app/views/sites/search.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 01a5417..7daa24d 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,14 +1,24 @@
+ +

<%= @site.type.name if @site.type %>

<%= image_tag(@site.image.url, :class => 'site_image') %> +

<%= @site.name %>

- +

Position:
+ LAT: <%= @site.latitude %> LONG: <%= @site.longitude %>

+

<%=sanitize @site.description %>

-

Autor: <%= @site.user.name if @site.user %>

+

Autor: + <%= @site.user.name if @site.user %> +

+ +
+
@@ -16,4 +26,11 @@

-<% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> +<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> + + diff --git a/app/views/trips/_trip.html.erb b/app/views/trips/_trip.html.erb index 2d69c99..bd20541 100644 --- a/app/views/trips/_trip.html.erb +++ b/app/views/trips/_trip.html.erb @@ -2,8 +2,11 @@ <% trip.visits.order(:hour).each do |visit| %> - <% end %> diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb index 8bced6a..f6d3d4a 100644 --- a/app/views/trips/show.html.erb +++ b/app/views/trips/show.html.erb @@ -1,14 +1,32 @@ -

Name: <%= @trip.name %>

Date: <%= @trip.date %>

- Autor: <%= @trip.user.name if @trip.user %> -

-

Description: <%= simple_format @trip.description %>

+

+ Name: + <%= @trip.name %> +

+ + + +

+ Date: + <%= @trip.date %> +

+ +

+ Autor: + <%= @trip.user.name if @trip.user %> +

+ +

+ Description: + <%= simple_format @trip.description %> +

+

Sitios a visitar

<%= render(@trip) %> - <% if @trip.user == current_user %> + <% if @trip.user == current_user %> <%= form_for(@visit, :remote => true) do |f| %> <%= f.number_field :trip_id, :value => @trip.id, :hidden => true %> @@ -24,5 +42,16 @@
- <% if @trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(@trip) %> | <% end %> <%= link_to 'Back', trips_path %> - \ No newline at end of file + +<% if @trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(@trip) %> | +<% end %> + +

Mapa del viaje

+
+ +<%= link_to 'Back', trips_path %> + + diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index e761359..b33171d 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -7,9 +7,9 @@
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 @@ +
+

Listing Types

+ +
+ <%= link_to image_tag(visit.site.image.url, :class => 'list_image'), visit.site %> + + + @@ -20,7 +23,6 @@ <%= link_to 'Destroy', visit, :confirm => 'Are you sure?', :method => :delete if trip.user == current_user %> -
-
<%= link_to type.name, type_sites_path(type) %>
-
<%= truncate(strip_tags(type.description), - :length => 80) %>
+
<%= link_to type.name, type_sites_path(type.id) %>
+
<%= truncate(strip_tags(type.description), :length => 80) %>
+ <%= type.updated_at %>
+ <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), :length => 80) %>
+ <%= type.updated_at %> +
+
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type, + :confirm => 'Are you sure?', + :method => :delete %> +
+

+ +
+ +<%= link_to 'New Type', new_type_path %> diff --git a/app/views/types/show.html.erb b/app/views/types/show.html.erb index 98b32e7..583ef2f 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -10,6 +10,11 @@ <%= @type.description %>

+

+ 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 @@ + + + + + currentDocument + db/seeds.rb + documents + + + expanded + + name + planet2012 + regexFolderFilter + !.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ + sourceDirectory + + + + name + music_library + regexFolderFilter + !.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ + sourceDirectory + ../music_library + + + name + euita_fistube + regexFolderFilter + !.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$ + sourceDirectory + ../euita_fistube + + + fileHierarchyDrawerWidth + 198 + metaData + + ../euita_fistube/Gemfile + + caret + + column + 27 + line + 15 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + ../music_library/app/views/albums/index.html.erb + + caret + + column + 30 + line + 18 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + ../music_library/app/views/albums/new.html.erb + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + ../music_library/db/migrate/20120420004156_create_albums.rb + + caret + + column + 20 + line + 3 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + app/controllers/sites_controller.rb + + caret + + column + 5 + line + 47 + + firstVisibleColumn + 0 + firstVisibleLine + 25 + + app/views/sites/edit.html.erb + + caret + + column + 0 + line + 2 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + app/views/visits/index.html.erb + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + config/routes.rb + + caret + + column + 19 + line + 2 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + db/seeds.rb + + caret + + column + 49 + line + 55 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 0 + selectFrom + + column + 39 + line + 55 + + selectTo + + column + 49 + line + 55 + + + + openDocuments + + config/routes.rb + db/seeds.rb + + showFileHierarchyDrawer + + windowFrame + {{262, 0}, {1018, 778}} + + diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb index ce15d1b..407ffda 100644 --- a/test/functional/planet_controller_test.rb +++ b/test/functional/planet_controller_test.rb @@ -11,5 +11,25 @@ class PlanetControllerTest < ActionController::TestCase get :contact assert_response :success end + + test "should get author" do + get :author + assert_response :success + end + + test "should get minsearch" do + get :minsearch + assert_response :success + end + + test "should get topsearch" do + get :topsearch + assert_response :success + end + + test "should get ejemplo" do + get :ejemplo + assert_response :success + end end diff --git a/test/unit/helpers/planet_controller_test.rb b/test/unit/helpers/planet_controller_test.rb new file mode 100644 index 0000000..2c8349a --- /dev/null +++ b/test/unit/helpers/planet_controller_test.rb @@ -0,0 +1,25 @@ +require 'test_helper' + +class PlanetControllerTest < ActionController::TestCase + + test "index_test" do + get :index + assert_response :success + end + + test "contact_test" do + get :contact + assert_response :success + end + + test "ejemplo_test" do + get :ejemplo + assert_response :success + end + + test "author_test" do + get :author + assert_response :success + end + +end diff --git a/test/unit/helpers/planet_helper_test.rb b/test/unit/helpers/planet_helper_test.rb index b4082e5..85a79f7 100644 --- a/test/unit/helpers/planet_helper_test.rb +++ b/test/unit/helpers/planet_helper_test.rb @@ -1,4 +1,5 @@ require 'test_helper' class PlanetHelperTest < ActionView::TestCase + end