diff --git a/Gemfile b/Gemfile index 7764763..d8a3997 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,16 @@ gem 'rails', '3.2.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'sqlite3' +group :development do + gem 'sqlite3' +end + +group :production do + gem 'pg' +end + +gem 'devise' # Gems used only for assets and not required # in production environments by default. @@ -21,6 +29,8 @@ group :assets do end gem 'jquery-rails' +gem 'cleditor_rails' +gem 'paperclip' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' @@ -35,4 +45,4 @@ gem 'jquery-rails' # gem 'capistrano' # To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' +# gem 'ruby-debug19', :require => 'ruby-debug' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 81a3ba7..f5d7ac6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,11 @@ 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) + cocaine (0.2.1) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -37,6 +41,11 @@ GEM 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) @@ -53,6 +62,14 @@ 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 + pg (0.13.2) + pg (0.13.2-x86-mingw32) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -89,6 +106,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) @@ -98,13 +116,20 @@ 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 + paperclip + pg rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 diff --git a/app/assets/images/arbol1.png b/app/assets/images/arbol1.png new file mode 100644 index 0000000..6affc09 Binary files /dev/null and b/app/assets/images/arbol1.png differ diff --git a/app/assets/images/bea.JPG b/app/assets/images/bea.JPG new file mode 100644 index 0000000..0194842 Binary files /dev/null and b/app/assets/images/bea.JPG differ diff --git a/app/assets/images/blue-marker.png b/app/assets/images/blue-marker.png new file mode 100644 index 0000000..e905e2e Binary files /dev/null and b/app/assets/images/blue-marker.png differ diff --git a/app/assets/images/florencia.png b/app/assets/images/florencia.png new file mode 100644 index 0000000..6398a2e Binary files /dev/null and b/app/assets/images/florencia.png differ diff --git a/app/assets/images/fot.jpg b/app/assets/images/fot.jpg new file mode 100644 index 0000000..49fc1c9 Binary files /dev/null and b/app/assets/images/fot.jpg differ diff --git a/app/assets/images/logo3.png b/app/assets/images/logo3.png new file mode 100644 index 0000000..bfa4c13 Binary files /dev/null and b/app/assets/images/logo3.png differ diff --git a/app/assets/images/pablo.jpg b/app/assets/images/pablo.jpg new file mode 100644 index 0000000..b66bf26 Binary files /dev/null and b/app/assets/images/pablo.jpg differ diff --git a/app/assets/images/paris.JPG b/app/assets/images/paris.JPG new file mode 100644 index 0000000..9092cc1 Binary files /dev/null and b/app/assets/images/paris.JPG differ diff --git a/app/assets/images/pedriza.png b/app/assets/images/pedriza.png new file mode 100644 index 0000000..8d300fb Binary files /dev/null and b/app/assets/images/pedriza.png differ diff --git a/app/assets/images/pergamo.png b/app/assets/images/pergamo.png new file mode 100644 index 0000000..7e462c2 Binary files /dev/null and b/app/assets/images/pergamo.png differ diff --git a/app/assets/images/reichstag.png b/app/assets/images/reichstag.png new file mode 100644 index 0000000..8b95380 Binary files /dev/null and b/app/assets/images/reichstag.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9097d83..fbc4bb2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,5 +11,6 @@ // GO AFTER THE REQUIRES BELOW. // //= require jquery +//= require cleditor //= require jquery_ujs -//= require_tree . +// require_tree . diff --git a/app/assets/javascripts/application.js~ b/app/assets/javascripts/application.js~ new file mode 100644 index 0000000..ab2116a --- /dev/null +++ b/app/assets/javascripts/application.js~ @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// +//= require jquery +//= require cleditor +//= require jquery_ujs + diff --git a/app/assets/javascripts/coments.form.geolocation.js b/app/assets/javascripts/coments.form.geolocation.js new file mode 100644 index 0000000..0b7aca0 --- /dev/null +++ b/app/assets/javascripts/coments.form.geolocation.js @@ -0,0 +1,57 @@ +function success(position) { + + if (document.getElementById('coment_latitude').value == ""){ + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + document.getElementById('coment_zoom').value=15; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = position.coords.latitude+","+position.coords.longitude; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/coments.geolocation.js~ b/app/assets/javascripts/coments.geolocation.js~ new file mode 100644 index 0000000..38b2521 --- /dev/null +++ b/app/assets/javascripts/coments.geolocation.js~ @@ -0,0 +1,56 @@ +function success(position) { + + if (document.getElementById('coment_latitude').value == ""){ + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = position.coords.latitude+","+position.coords.longitude; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/coments.js.coffee b/app/assets/javascripts/coments.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/coments.js.coffee @@ -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/ diff --git a/app/assets/javascripts/geolocation.js~ b/app/assets/javascripts/geolocation.js~ new file mode 100644 index 0000000..b976519 --- /dev/null +++ b/app/assets/javascripts/geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/planet.js.coffee b/app/assets/javascripts/planet.js.coffee index 7615679..2a5d841 100644 --- a/app/assets/javascripts/planet.js.coffee +++ b/app/assets/javascripts/planet.js.coffee @@ -1,3 +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/ +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ \ No newline at end of file diff --git a/app/assets/javascripts/sites.coments.show.geolocation.js b/app/assets/javascripts/sites.coments.show.geolocation.js new file mode 100644 index 0000000..6e506a0 --- /dev/null +++ b/app/assets/javascripts/sites.coments.show.geolocation.js @@ -0,0 +1,22 @@ +function posicionar(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + document.getElementById('coment_zoom').value=15; +} + +function error_posicionar(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(posicionar, error_posicionar); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.form.geolocation.js b/app/assets/javascripts/sites.form.geolocation.js new file mode 100644 index 0000000..d97d497 --- /dev/null +++ b/app/assets/javascripts/sites.form.geolocation.js @@ -0,0 +1,56 @@ +function success(position) { + if (document.getElementById('site_latitude').value == ""){ + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + document.getElementById('site_zoom').value=15; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.form.geolocation.js~ b/app/assets/javascripts/sites.form.geolocation.js~ new file mode 100644 index 0000000..49c5c72 --- /dev/null +++ b/app/assets/javascripts/sites.form.geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.geolocation.js b/app/assets/javascripts/sites.geolocation.js new file mode 100644 index 0000000..49c5c72 --- /dev/null +++ b/app/assets/javascripts/sites.geolocation.js @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.geolocation.js~ b/app/assets/javascripts/sites.geolocation.js~ new file mode 100644 index 0000000..b976519 --- /dev/null +++ b/app/assets/javascripts/sites.geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.get.coordenates.js b/app/assets/javascripts/sites.get.coordenates.js new file mode 100644 index 0000000..e47ab15 --- /dev/null +++ b/app/assets/javascripts/sites.get.coordenates.js @@ -0,0 +1,10 @@ +function get_site_coordenates(){ + var address = document.getElementById('site_name').value; + var latitude = $.get("/planet/jsonp?address="+address+"&coor=lat", function(data){ + document.getElementById('site_latitude').value = $.trim(data); +}); + var longitude = $.get("/planet/jsonp?address="+address+"&coor=lng", function(data){ + document.getElementById('site_longitude').value = $.trim(data); +}); + +} diff --git a/app/assets/javascripts/sites.js.coffee b/app/assets/javascripts/sites.js.coffee new file mode 100644 index 0000000..2a5d841 --- /dev/null +++ b/app/assets/javascripts/sites.js.coffee @@ -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/ \ No newline at end of file diff --git a/app/assets/javascripts/sites.map.js~ b/app/assets/javascripts/sites.map.js~ new file mode 100644 index 0000000..fc022f0 --- /dev/null +++ b/app/assets/javascripts/sites.map.js~ @@ -0,0 +1,54 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + + diff --git a/app/assets/javascripts/sites.show.geolocation.js b/app/assets/javascripts/sites.show.geolocation.js new file mode 100644 index 0000000..270eb35 --- /dev/null +++ b/app/assets/javascripts/sites.show.geolocation.js @@ -0,0 +1,54 @@ +function success() { + + var latitude = parseFloat(document.getElementById('latitude').value); + var longitude = parseFloat(document.getElementById('longitude').value); + var zoomlevel = parseFloat(document.getElementById('zoom').value); + + + + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + if(document.getElementById('latitude').value != ""){ + s.innerHTML = "Map:"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(latitude, longitude); + var myOptions = { + zoom: zoomlevel, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here!" + }); + }else{ + s.innerHTML = "There are no coordenates to show map"; + s.className = 'success'; + } + + +} + + + + + diff --git a/app/assets/javascripts/sites.show.geolocation.js~ b/app/assets/javascripts/sites.show.geolocation.js~ new file mode 100644 index 0000000..de20eb5 --- /dev/null +++ b/app/assets/javascripts/sites.show.geolocation.js~ @@ -0,0 +1,54 @@ +function success() { + + var latitude = parseFloat(document.getElementById('latitude').value); + var longitude = parseFloat(document.getElementById('longitude').value); + var zoomlevel = parseFloat(document.getElementById('zoom').value); + + + + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + if(document.getElementById('latitude').value != ""){ + s.innerHTML = "Map:"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + mapcanvas.style.text-align = 'right'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(latitude, longitude); + var myOptions = { + zoom: zoomlevel, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here!" + }); + }else{ + s.innerHTML = "There are no coordenates to show map"; + s.className = 'success'; + } + + +} + + + + + diff --git a/app/assets/javascripts/trips.js.coffee b/app/assets/javascripts/trips.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/trips.js.coffee @@ -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/ diff --git a/app/assets/javascripts/trips.show.geolocation.js b/app/assets/javascripts/trips.show.geolocation.js new file mode 100644 index 0000000..50b969b --- /dev/null +++ b/app/assets/javascripts/trips.show.geolocation.js @@ -0,0 +1,24 @@ +var s = document.querySelector('#status'); + + +s.innerHTML = "Map:"; +s.className = 'success'; + +var mapcanvas = document.createElement('div'); +mapcanvas.id = 'mapcanvas'; +mapcanvas.style.height = '200px'; +mapcanvas.style.width = '67%'; + + +document.querySelector('article').appendChild(mapcanvas); + +var latlng = new google.maps.LatLng(40, -3); + +var myOptions = { +zoom: 2, +center: latlng, +mapTypeControl: false, +navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, +mapTypeId: google.maps.MapTypeId.ROADMAP +}; +var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); diff --git a/app/assets/javascripts/visits.js.coffee b/app/assets/javascripts/visits.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/visits.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3b5cc66..1560d8e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -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 . -*/ +*/ \ No newline at end of file diff --git a/app/assets/stylesheets/coments.css.scss b/app/assets/stylesheets/coments.css.scss new file mode 100644 index 0000000..991976f --- /dev/null +++ b/app/assets/stylesheets/coments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the coments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css new file mode 100644 index 0000000..a5690f9 --- /dev/null +++ b/app/assets/stylesheets/planet.css @@ -0,0 +1,208 @@ +/* Global styles (no utilizados de momento) */ + +#planet #notice { + color: #000; + border: 2px solid red; + padding: 1em; + margin-bottom: 2em; + background-color: #f0f0f0; + font: bold smaller sans-serif; +} + + +#planet h1 { + font: 150% sans-serif; + color: #226; + border-bottom: 3px dotted #77d; +} + +/* Styles for products/index */ + +#site .site_image { + height: 200px; + padding-top: 40px; +} + +#googlemap{ + float: right; + padding-right: 50%; +} + +#site_list table { + border-collapse: collapse; +} + +#site_list table tr td { + padding: 5px; + vertical-align: top; +} + +#site_list .list_image { + width: 60px; + height: 70px; +} + +#site_list .list_description { + width: 60%; +} + +#site_list .list_description dl { + margin: 0; +} + +#site_list .list_description dt { + color: #244; + font-weight: bold; + font-size: larger; +} + +#site_list .enlaceComentarios dt { + color: #244; + font-weight: bold; + font-size: small; +} + +#site_list .list_description dd { + margin: 0; +} + +#site_list .list_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} +.comentarios .list_actions{ + font-size: x-small; + text-align: right; + padding-left: 1em; + float: right; +} +.comentarios{ + width: 75%; + padding: 5px; +} +.cadaComentario{ + border: solid; +} +.cadaComentario .dondeEstoy{ + font-style: italic; +} + +#site_list .list_line_even { + background: #a8b8f8; +} + +#site_list .list_line_odd { + background: #88b0f8; +} + + +/* START:mainlayout */ +/* Styles for main page */ + +#banner { + background: #668; + padding-top: 10px; + padding-bottom: 10px; + border-bottom: 2px solid; + font: small-caps 40px/40px "Times New Roman", serif; + color: #bfb; + text-align: center; +} + +#banner img { + float: left; + padding-left: 10px; +} + +#banner .user { + float: right; + color: #bfb; + font-size: small; +} + +#banner .formulario { + float: right; + padding-right:65.6%; + padding-top:10px; + color: #bfb; + font-size: small; +} + +#columns { + background: #446; +} + +#main { + margin-left: 9em; /* Ajuste de borde izquierdo */ + padding-top: 4ex; + padding-left: 2em; + background: white; +} + +#side { + float: left; + padding-top: 1em; + padding-left: 1em; + padding-bottom: 1em; + width: 8em; /* Ajuste de borde izquierdo */ + background: #446; +} + +#side a { + color: #bfb; + font-size: small; +} +/* END:mainlayout */ + +/* An entry in the store catalog (no utilizados de momento) */ + +#planet .entry { + overflow: auto; + margin-top: 1em; + border-bottom: 1px dotted #77d; +} + +#planet .name { + font-size: 120%; + font-family: sans-serif; +} + +#store .entry img { + width: 80px; + margin-right: 5px; + margin-bottom: 5px; + float: left; +} + + +#store .entry h3 { + margin-top: 0; + margin-bottom: 2px; + color: #227; +} + +#store .entry p { + margin-top: 0.5em; + margin-bottom: 0.8em; +} + +#store .entry .price_line { + clear: both; + margin-bottom: 0.5em; +} + +#store .entry .add_to_cart { + position: relative; +} + +#store .entry .price { + color: #44a; + font-weight: bold; + margin-right: 2em; +} + + +#main .visitas { + text-indent: 70%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss new file mode 100644 index 0000000..fa73be7 --- /dev/null +++ b/app/assets/stylesheets/sites.css.scss @@ -0,0 +1,3 @@ +// 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/ \ No newline at end of file diff --git a/app/assets/stylesheets/trips.css.scss b/app/assets/stylesheets/trips.css.scss new file mode 100644 index 0000000..473cbc3 --- /dev/null +++ b/app/assets/stylesheets/trips.css.scss @@ -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/ diff --git a/app/assets/stylesheets/visits.css.scss b/app/assets/stylesheets/visits.css.scss new file mode 100644 index 0000000..99b00b9 --- /dev/null +++ b/app/assets/stylesheets/visits.css.scss @@ -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/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..f6e5e7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ +# ApplicationController class ApplicationController < ActionController::Base protect_from_forgery end diff --git a/app/controllers/application_controller.rb~ b/app/controllers/application_controller.rb~ new file mode 100644 index 0000000..e8065d9 --- /dev/null +++ b/app/controllers/application_controller.rb~ @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/coments_controller.rb b/app/controllers/coments_controller.rb new file mode 100644 index 0000000..3740d89 --- /dev/null +++ b/app/controllers/coments_controller.rb @@ -0,0 +1,114 @@ +# ComentsController nos permite controlar las acciones relacionadas con los comentarios +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class ComentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + + + if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión + @coments = Coment.all #si no, se pondría solo esta linea + else + @coments = Site.find(params[:site_id]).coments + end + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # Muestra un comentario especifico + # GET /coments/1 + # GET /coments/1.json + def show + @coment = Coment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @coment } + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @coment = Coment.new + #@site = Site.find(params[:site_id]) + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @coment } + end + end + + # GET /coments/1/edit + def edit + @coment = Coment.find(params[:id]) + end + + # POST /coments + # POST /coments.json + def create + @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + else + @site = Site.find(params[:coment][:site_id]) + end + @coment = @site.coments.create(params[:coment]) + + + + respond_to do |format| + if @coment.save + format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' } + format.json { render json: site_path(@site), status: :created, location: @coment } + else + format.html { render action: "new" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /coments/1 + # PUT /coments/1.json + def update + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + + respond_to do |format| + if @coment.update_attributes(params[:coment]) + format.html { redirect_to @coment, notice: 'Coment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to coments_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/coments_controller.rb~ b/app/controllers/coments_controller.rb~ new file mode 100644 index 0000000..4befdce --- /dev/null +++ b/app/controllers/coments_controller.rb~ @@ -0,0 +1,114 @@ +# ComentsController nos permite controlar las acciones relacionadas con los comentarios +# ¡IMPORTANTE! Necesario haber inidiado sesión con un usuario +class ComentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + + + if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión + @coments = Coment.all #si no, se pondría solo esta linea + else + @coments = Site.find(params[:site_id]).coments + end + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # Muestra un comentario especifico + # GET /coments/1 + # GET /coments/1.json + def show + @coment = Coment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @coment } + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @coment = Coment.new + #@site = Site.find(params[:site_id]) + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @coment } + end + end + + # GET /coments/1/edit + def edit + @coment = Coment.find(params[:id]) + end + + # POST /coments + # POST /coments.json + def create + @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + else + @site = Site.find(params[:coment][:site_id]) + end + @coment = @site.coments.create(params[:coment]) + + + + respond_to do |format| + if @coment.save + format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' } + format.json { render json: site_path(@site), status: :created, location: @coment } + else + format.html { render action: "new" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /coments/1 + # PUT /coments/1.json + def update + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + + respond_to do |format| + if @coment.update_attributes(params[:coment]) + format.html { redirect_to @coment, notice: 'Coment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to coments_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index be7ac0a..9670007 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,11 +1,49 @@ +# PlanetController ilustra el uso de *RDoc*. La documentación de un proyecto en +# genera en el directorio *proy/doc* en formato Web con +# $proy> rake doc:app +# +# == Algunos comandos de formateo +# +# Tal y como muestra el subitulo anterior, este se define empezando la +# línea con ==. En los títulos debe empezar por =. +# +# Un [ ... ] seguido de texto define una lista titulada, como aquí +# [Clases, Módulos o Métodos] Se documentan con comentarios justo encima de sus definición, como aquí. +# +# Un * o - definen las entradas de una lista itemizada +# * Un URL se define así email[mailto:pepe@ejemplo.com] +# * o así {Pepe Rubio}[mailto:pepe@ejemplo.com] +# +# Un número o letra seguido de punto genera una lista númerada +# 1. + permite generar *negrita*, igual que con HTML +# 2. _ permite generar _cursiva_, igual que con HTML +# 3. * permite generar letra de +teletipo+, igual que con HTML +# class PlanetController < ApplicationController + + # GET /sites /search + def search + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + end + + # Método que define una acción vacía del controlador def index end - + # 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 + # Método que define una acción vacía del controlador def ejemplo end + + # Método para definir la acción que nos permite parsear json de la API de googlemaps + # +No renderiza el layout+ + def jsonp + render :layout => false + end end diff --git a/app/controllers/planet_controller.rb~ b/app/controllers/planet_controller.rb~ new file mode 100644 index 0000000..dd8c09a --- /dev/null +++ b/app/controllers/planet_controller.rb~ @@ -0,0 +1,49 @@ +# PlanetController ilustra el uso de *RDoc*. La documentacin de un proyecto en +# genera en el directorio *proy/doc* en formato Web con +# $proy> rake doc:app +# +# == Algunos comandos de formateo +# +# Tal y como muestra el subitulo anterior, este se define empezando la +# lnea con ==. En los ttulos debe empezar por =. +# +# Un [ ... ] seguido de texto define una lista titulada, como aqu +# [Clases, Mdulos o Mtodos] Se documentan con comentarios justo encima de sus definicin, como aqu. +# +# Un * o - definen las entradas de una lista itemizada +# * Un URL se define as email[mailto:pepe@ejemplo.com] +# * o as {Pepe Rubio}[mailto:pepe@ejemplo.com] +# +# Un nmero o letra seguido de punto genera una lista nmerada +# 1. + permite generar *negrita*, igual que con HTML +# 2. _ permite generar _cursiva_, igual que con HTML +# 3. * permite generar letra de +teletipo+, igual que con HTML +# +class PlanetController < ApplicationController + + # GET /sites /search + def search + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + end + + # Mtodo que define una accin vaca del controlador + def index + end + # Mtodo que define una accin vaca del controlador + def contact + end + # Mtodo que define una accin vaca del controlador + def author + end + # Mtodo que define una accin vaca del controlador + def ejemplo + end + + # Mtodo para definir la accin que nos permite parsear json de la API de googlemaps + # +No renderiza el layout+ + def jsonp + render :layout => false + end + +end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb new file mode 100644 index 0000000..43a832a --- /dev/null +++ b/app/controllers/sites_controller.rb @@ -0,0 +1,102 @@ +# SitesController nos permite controlar las acciones relacionadas con los sitios +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class SitesController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + after_filter :count_visita, :only => :show + + + # GET /sites + # GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + 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 } + end + end + + # GET /sites/1 + # GET /sites/1.json + def show + @site = Site.find(params[:id]) + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + format.json { render json: @coments } + + end + end + + # GET /sites/new + # GET /sites/new.json + def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end + end + + # GET /sites/1/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /sites + # POST /sites.json + def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PUT /sites/1 + # PUT /sites/1.json + def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 + # DELETE /sites/1.json + def destroy + @site = current_user.sites.find(params[:id]) # 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 + private + def count_visita + @site.increment!(:visitas) + end + +end diff --git a/app/controllers/sites_controller.rb~ b/app/controllers/sites_controller.rb~ new file mode 100644 index 0000000..8efd62a --- /dev/null +++ b/app/controllers/sites_controller.rb~ @@ -0,0 +1,102 @@ +# SitesController nos permite controlar las acciones relacionadas con los viajes +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class SitesController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + after_filter :count_visita, :only => :show + + + # GET /sites + # GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + 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 } + end + end + + # GET /sites/1 + # GET /sites/1.json + def show + @site = Site.find(params[:id]) + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + format.json { render json: @coments } + + end + end + + # GET /sites/new + # GET /sites/new.json + def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end + end + + # GET /sites/1/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /sites + # POST /sites.json + def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PUT /sites/1 + # PUT /sites/1.json + def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 + # DELETE /sites/1.json + def destroy + @site = current_user.sites.find(params[:id]) # 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 + private + def count_visita + @site.increment!(:visitas) + end + +end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb new file mode 100644 index 0000000..58d4dc7 --- /dev/null +++ b/app/controllers/trips_controller.rb @@ -0,0 +1,90 @@ +# TripsController nos permite controlar las acciones relacionadas con los viajes +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /trips + # GET /trips.json + def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end + end + + # GET /trips/1 + # GET /trips/1.json + def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/new + # GET /trips/new.json + def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/1/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # POST /trips + # POST /trips.json + def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # PUT /trips/1 + # PUT /trips/1.json + def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /trips/1 + # DELETE /trips/1.json + def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/trips_controller.rb~ b/app/controllers/trips_controller.rb~ new file mode 100644 index 0000000..321f6e3 --- /dev/null +++ b/app/controllers/trips_controller.rb~ @@ -0,0 +1,88 @@ +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /trips + # GET /trips.json + def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end + end + + # GET /trips/1 + # GET /trips/1.json + def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/new + # GET /trips/new.json + def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/1/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # POST /trips + # POST /trips.json + def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # PUT /trips/1 + # PUT /trips/1.json + def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /trips/1 + # DELETE /trips/1.json + def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..0f73231 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,4 +1,20 @@ +# Controlador de los tipos class TypesController < ApplicationController + + # GET /types + # GET /types.json + # Devuelve una lista ordenada por nombre + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + # GET /types # GET /types.json def index @@ -9,6 +25,8 @@ def index format.json { render json: @types } end end + + # GET /types/1 # GET /types/1.json diff --git a/app/controllers/types_controller.rb~ b/app/controllers/types_controller.rb~ new file mode 100644 index 0000000..6520f0f --- /dev/null +++ b/app/controllers/types_controller.rb~ @@ -0,0 +1,100 @@ +# Controlador de los tipos +class TypesController < ApplicationController + + # GET /types + # GET /types.json + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + + # GET /types + # GET /types.json + def index + @types = Type.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + + # GET /types/1 + # GET /types/1.json + def show + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end + end + + # GET /types/new + # GET /types/new.json + def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end + end + + # GET /types/1/edit + def edit + @type = Type.find(params[:id]) + end + + # POST /types + # POST /types.json + def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # PUT /types/1 + # PUT /types/1.json + def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /types/1 + # DELETE /types/1.json + def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb new file mode 100644 index 0000000..b2fde8e --- /dev/null +++ b/app/controllers/visits_controller.rb @@ -0,0 +1,88 @@ +# VisitsController para las visitas +class VisitsController < ApplicationController + # GET /visits + # GET /visits.json + # Nos devuelve todas las visitas + def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end + end + + # GET /visits/1 + # GET /visits/1.json + # Sólo aquella que coincide con el parámetro id + def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/new + # GET /visits/new.json + # Para crear una nueva visita + def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # POST /visits + # POST /visits.json + def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # PUT /visits/1 + # PUT /visits/1.json + def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /visits/1 + # DELETE /visits/1.json + def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/visits_controller.rb~ b/app/controllers/visits_controller.rb~ new file mode 100644 index 0000000..1830f62 --- /dev/null +++ b/app/controllers/visits_controller.rb~ @@ -0,0 +1,84 @@ +class VisitsController < ApplicationController + # GET /visits + # GET /visits.json + def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end + end + + # GET /visits/1 + # GET /visits/1.json + def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/new + # GET /visits/new.json + def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # POST /visits + # POST /visits.json + def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # PUT /visits/1 + # PUT /visits/1.json + def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /visits/1 + # DELETE /visits/1.json + def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end + end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..798c403 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,47 @@ +# Helpers que estarán disponibles desde todas las vistas module ApplicationHelper + +# Nos permite incluir un javascript. +# Deprecated: Usar javascript_include_tag en su lugar +def include_javascript (file) + s = " " + content_for(:head, raw(s)) +end + + + +# Nos permite obtener en formato string el nombre de la ciudad o región pasándo como parámetro latitud y longitud +def get_address(latitude,longitude) + + if (!latitude.nil?) + require 'open-uri' + require 'json' + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad +end + + + +# Añade un marcador en un mapa de google +# IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map' +def add_gmap_marker (latitude,longitude,text) + javascript = "" + if(!latitude.nil?) + javascript = "" + end + raw(javascript) +end + end diff --git a/app/helpers/application_helper.rb~ b/app/helpers/application_helper.rb~ new file mode 100644 index 0000000..fff3c83 --- /dev/null +++ b/app/helpers/application_helper.rb~ @@ -0,0 +1,46 @@ +# Helpers que estarán disponibles desde todas las vistas +module ApplicationHelper + +def include_javascript (file) + s = " " + content_for(:head, raw(s)) +end + + + + +def get_address(latitude,longitude) + + if (!latitude.nil?) + require 'open-uri' + require 'json' + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad +end + + + + + + +def add_gmap_marker (latitude,longitude,text) + javascript = "" + if(!latitude.nil?) + javascript = "" + end + raw(javascript) +end + +end diff --git a/app/helpers/coments_helper.rb b/app/helpers/coments_helper.rb new file mode 100644 index 0000000..31dd4b5 --- /dev/null +++ b/app/helpers/coments_helper.rb @@ -0,0 +1,5 @@ +# No se usa +module ComentsHelper + + +end diff --git a/app/helpers/coments_helper.rb~ b/app/helpers/coments_helper.rb~ new file mode 100644 index 0000000..0113d79 --- /dev/null +++ b/app/helpers/coments_helper.rb~ @@ -0,0 +1,4 @@ +module ComentsHelper + + +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..e74867c 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,3 @@ +# No se usa module PlanetHelper end diff --git a/app/helpers/planet_helper.rb~ b/app/helpers/planet_helper.rb~ new file mode 100644 index 0000000..5bbc197 --- /dev/null +++ b/app/helpers/planet_helper.rb~ @@ -0,0 +1,2 @@ +module PlanetHelper +end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb new file mode 100644 index 0000000..715d58f --- /dev/null +++ b/app/helpers/sites_helper.rb @@ -0,0 +1,7 @@ +module SitesHelper + def new_gmap(latitude,longitude,zoom) + + end + + +end diff --git a/app/helpers/sites_helper.rb~ b/app/helpers/sites_helper.rb~ new file mode 100644 index 0000000..10a1ce9 --- /dev/null +++ b/app/helpers/sites_helper.rb~ @@ -0,0 +1,16 @@ +module SitesHelper + def new_gmap(latitude,longitude,zoom) + + end + + def get_address(latitude,longitude) + if (!latitude.nil?) + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad + end +end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb new file mode 100644 index 0000000..d0c1ee0 --- /dev/null +++ b/app/helpers/trips_helper.rb @@ -0,0 +1,3 @@ +# No se usa +module TripsHelper +end diff --git a/app/helpers/trips_helper.rb~ b/app/helpers/trips_helper.rb~ new file mode 100644 index 0000000..04f333d --- /dev/null +++ b/app/helpers/trips_helper.rb~ @@ -0,0 +1,2 @@ +module TripsHelper +end diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb new file mode 100644 index 0000000..83968ef --- /dev/null +++ b/app/helpers/visits_helper.rb @@ -0,0 +1,3 @@ +# No se usa +module VisitsHelper +end diff --git a/app/helpers/visits_helper.rb~ b/app/helpers/visits_helper.rb~ new file mode 100644 index 0000000..8ce5f83 --- /dev/null +++ b/app/helpers/visits_helper.rb~ @@ -0,0 +1,2 @@ +module VisitsHelper +end diff --git a/app/models/coment.rb b/app/models/coment.rb new file mode 100644 index 0000000..3e645e5 --- /dev/null +++ b/app/models/coment.rb @@ -0,0 +1,15 @@ +class Coment < ActiveRecord::Base + belongs_to :site + belongs_to :user + + # Debe estar protegido para evitar accesos indeseados + #attr_protected :user_id + + # Se aaden estas definiciones + + validates :site_id, :presence => true + validates :user_id, :presence => true + validates :coment, :presence => true, + :length => { :maximum => 240 } + +end diff --git a/app/models/site.rb b/app/models/site.rb new file mode 100644 index 0000000..9b3ad0b --- /dev/null +++ b/app/models/site.rb @@ -0,0 +1,15 @@ +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + has_many :visits + has_many :coments + has_many :trips, :through => :visits + has_attached_file :image + + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se aaden estas definiciones + validates :name, :type_id, :presence => true # campo obligatorio +end \ No newline at end of file diff --git a/app/models/trip.rb b/app/models/trip.rb new file mode 100644 index 0000000..4ff6d83 --- /dev/null +++ b/app/models/trip.rb @@ -0,0 +1,7 @@ +class Trip < ActiveRecord::Base + belongs_to :user + has_many :visits + has_many :sites, :through => :visits + + attr_protected :user_id # por seguridad +end diff --git a/app/models/type.rb b/app/models/type.rb index e89da76..a1853a0 100644 --- a/app/models/type.rb +++ b/app/models/type.rb @@ -1,2 +1,8 @@ class Type < ActiveRecord::Base -end + has_many :sites + + + # Se aade esta definicin de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo nico (no repetido) +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..d0bacef --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,16 @@ +class User < ActiveRecord::Base + + has_many :sites + has_many :trips + has_many :coments + + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + validates_presence_of :name + + # Setup accessible (or protected) attributes for your model + attr_accessible :name, :email, :password, :password_confirmation, :remember_me +end \ No newline at end of file diff --git a/app/models/visit.rb b/app/models/visit.rb new file mode 100644 index 0000000..57546da --- /dev/null +++ b/app/models/visit.rb @@ -0,0 +1,4 @@ +class Visit < ActiveRecord::Base + belongs_to :trip + belongs_to :site +end diff --git a/app/views/coments/_form.html.erb b/app/views/coments/_form.html.erb new file mode 100644 index 0000000..be65978 --- /dev/null +++ b/app/views/coments/_form.html.erb @@ -0,0 +1,54 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'coments.form.geolocation' %> + + + +<%= form_for(@coment) do |f| %> + <% if @coment.errors.any? %> +
+

<%= pluralize(@coment.errors.count, "error") %> prohibited this coment from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :coment %>
+ <%= f.text_field :coment %> +
+
+ <%= f.hidden_field(:user_id, :value => current_user.id)%> +
+ +
+ <%= f.label :site_id %>
+ <%= f.collection_select(:site_id, Site.find(:all, :order => :name), :id, :name) if !@site %> + <%= f.hidden_field(:site_id, :value => @site.id) if @site%> + <%= @site.name if @site %> +
+
+
+ <%= f.label :latitude %>
+ <%= f.text_field :latitude %> +
+
+ <%= f.label :longitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+ +
+

Finding your location: checking...

+
+
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/coments/_form.html.erb~ b/app/views/coments/_form.html.erb~ new file mode 100644 index 0000000..12f73c0 --- /dev/null +++ b/app/views/coments/_form.html.erb~ @@ -0,0 +1,57 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'coments.geolocation' %> + + + + + + +<%= form_for(@coment) do |f| %> + <% if @coment.errors.any? %> +
+

<%= pluralize(@coment.errors.count, "error") %> prohibited this coment from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :coment %>
+ <%= f.text_field :coment %> +
+
+ <%= f.hidden_field(:user_id, :value => current_user.id)%> +
+ +
+ <%= f.label :site_id %>
+ <%= f.collection_select(:site_id, Site.find(:all, :order => :name), :id, :name) if !@site %> + <%= f.hidden_field(:site_id, :value => @site.id) if @site%> + <%= @site.name if @site %> +
+
+
+ <%= f.label :latitude %>
+ <%= f.text_field :latitude %> +
+
+ <%= f.label :longitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+ +
+

Finding your location: checking...

+
+
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/coments/edit.html.erb b/app/views/coments/edit.html.erb new file mode 100644 index 0000000..fe82e13 --- /dev/null +++ b/app/views/coments/edit.html.erb @@ -0,0 +1,6 @@ +

Editing coment

+ +<%= render 'form' %> + +<%= link_to 'Show', @coment %> | +<%= link_to 'Back', coments_path %> diff --git a/app/views/coments/index.html.erb b/app/views/coments/index.html.erb new file mode 100644 index 0000000..bcce31f --- /dev/null +++ b/app/views/coments/index.html.erb @@ -0,0 +1,36 @@ +<% +require 'open-uri' +require 'json' +%> + + +

Listing coments

+
+ <% @coments.each do |coment| %> +

+

+ <% if coment.user == current_user %> + <%= link_to 'Edit', edit_coment_path(coment) %> + <%= link_to 'Destroy', coment, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
+ Sitio:<%= coment.site.name if coment.site %>
+ <%= coment.user.name if coment.user %>: + <%= coment.coment %>
+ <%= image_tag('blue-marker.png') if !coment.longitude.nil? %><%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %> +
+

+ <% end %> + + +
+ + + + + + +<%= link_to 'New Coment', new_site_coment_path if !params[:site_id].nil? %> +<%= link_to 'New Coment', new_coment_path if params[:site_id].nil? %> diff --git a/app/views/coments/index.html.erb~ b/app/views/coments/index.html.erb~ new file mode 100644 index 0000000..4f77914 --- /dev/null +++ b/app/views/coments/index.html.erb~ @@ -0,0 +1,36 @@ +<% +require 'open-uri' +require 'json' +%> + + +

Listing coments

+
+ <% @coments.each do |coment| %> +

+

+ <% if coment.user == current_user %> + <%= link_to 'Edit', edit_coment_path(coment) %> + <%= link_to 'Destroy', coment, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
+ Sitio:<%= coment.site.name if coment.site %>
+ <%= coment.user.name if coment.user %>: + <%= coment.coment %>
+ <%= image_tag('pedriza2-m.png') if !coment.longitude.nil? %><%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %> +
+

+ <% end %> + + +
+ + + + + + +<%= link_to 'New Coment', new_site_coment_path if !params[:site_id].nil? %> +<%= link_to 'New Coment', new_coment_path if params[:site_id].nil? %> diff --git a/app/views/coments/new.html.erb b/app/views/coments/new.html.erb new file mode 100644 index 0000000..92cc1d3 --- /dev/null +++ b/app/views/coments/new.html.erb @@ -0,0 +1,6 @@ +

New coment

+ +<%= render 'form' %> + +<%= link_to 'Back', coments_path if !@site %> +<%= link_to 'Back', url_for([@site, @coment]) if @site %> diff --git a/app/views/coments/new.html.erb~ b/app/views/coments/new.html.erb~ new file mode 100644 index 0000000..88511cb --- /dev/null +++ b/app/views/coments/new.html.erb~ @@ -0,0 +1,6 @@ +

New coment

+ +<%= render 'form' %> + +<%= link_to 'Back', coments_path if !@site %> +<%= link_to 'Back', url_for([@site, @coment]) if !@site %> diff --git a/app/views/coments/show.html.erb b/app/views/coments/show.html.erb new file mode 100644 index 0000000..3cbe0c9 --- /dev/null +++ b/app/views/coments/show.html.erb @@ -0,0 +1,20 @@ +

<%= notice %>

+ +

+ Coment: + <%= @coment.coment %> +

+ +

+ User: + <%= @coment.user.name if @coment.user %> +

+ +

+ Site: + <%= @coment.site.name if @coment.site %> +

+ + +<%= link_to 'Edit', edit_coment_path(@coment) %> | +<%= link_to 'Back', coments_path %> diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb new file mode 100644 index 0000000..eab783a --- /dev/null +++ b/app/views/devise/_links.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Sign in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> \ No newline at end of file diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..18d81b1 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,12 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend confirmation instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..a5c4585 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @resource.email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..ae9e888 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password, and you can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..2263c21 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive amount of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5f7bcf8 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +

Change your password

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + <%= f.hidden_field :reset_password_token %> + +
<%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Change my password" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..b0b5690 --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,12 @@ +

Forgot your password?

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Send me reset password instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..3d2a882 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,25 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + +

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+ +
<%= f.submit "Update" %>
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..79a8c31 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,19 @@ +

Sign up

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +

<%= f.label :name %>
<%= f.text_field :name %>

+
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Sign up" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..f12116b --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,17 @@ +

Sign in

+ +<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ + <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..0dc79ac --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,12 @@ +

Resend unlock instructions

+ +<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend unlock instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 062c0a4..bf34ed3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,70 @@ - - - + + + Planet - <%= stylesheet_link_tag "application", :media => "all" %> + <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - - -<%= yield %> - - + + + + + +
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to 'Order Types', ordered_index_types_path %>
+ <%= link_to "Sitios", sites_path %>
+ <%= link_to "Viajes", trips_path %>
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to('Ejemplo', planet_ejemplo_path) %>
+ <%= link_to('Author', planet_author_path) %> + + +
+
+ + + <%= 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 'Order Types', ordered_index_types_path %> + <%= link_to 'Types', types_path %> + <%= link_to('Documentacion',)%> + +
+
+ + diff --git a/app/views/layouts/application.html.erb~ b/app/views/layouts/application.html.erb~ new file mode 100644 index 0000000..e1b7808 --- /dev/null +++ b/app/views/layouts/application.html.erb~ @@ -0,0 +1,70 @@ + + + + Planet + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + + + + + +
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to 'Order Types', ordered_index_types_path %>
+ <%= link_to "Sitios", sites_path %>
+ <%= link_to "Viajes", trips_path %>
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to('Ejemplo', planet_ejemplo_path) %>
+ <%= link_to('Author', planet_author_path) %> + + +
+
+ + + <%= 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 'Order Types', ordered_index_types_path %> + <%= link_to 'Types', types_path %> + <%= link_to('Documentacion', "/doc/app/index.html")%>
+ +
+
+ + diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb new file mode 100644 index 0000000..c584036 --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1,43 @@ + + + Planet + + + + + + +

Author:

+

+ <%= image_tag('bea.JPG') %> +

+

+

+ <%= image_tag('pablo.jpg') %> +

+

+ + +
+ + \ No newline at end of file diff --git a/app/views/planet/contact.html.erb b/app/views/planet/contact.html.erb index f339edd..36c1bd1 100644 --- a/app/views/planet/contact.html.erb +++ b/app/views/planet/contact.html.erb @@ -1 +1 @@ -

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/doc/README_FOR_APP b/app/views/planet/doc/README_FOR_APP new file mode 100644 index 0000000..fe41f5c --- /dev/null +++ b/app/views/planet/doc/README_FOR_APP @@ -0,0 +1,2 @@ +Use this README file to introduce your application and point to useful places in the API for learning more. +Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/app/views/planet/doc/app/ApplicationController.html b/app/views/planet/doc/app/ApplicationController.html new file mode 100644 index 0000000..09664a6 --- /dev/null +++ b/app/views/planet/doc/app/ApplicationController.html @@ -0,0 +1,159 @@ + + + + + + +class ApplicationController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ +
+ +

ApplicationController

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/ApplicationHelper.html b/app/views/planet/doc/app/ApplicationHelper.html new file mode 100644 index 0000000..dd55afb --- /dev/null +++ b/app/views/planet/doc/app/ApplicationHelper.html @@ -0,0 +1,290 @@ + + + + + + +module ApplicationHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +

Helpers que estarán disponibles desde todas las vistas

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ add_gmap_marker(latitude,longitude,text) + click to toggle source +
+ + +
+ +

Añade un marcador en un mapa de google

+ +
IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map'
+ + + +
+
# File app/helpers/application_helper.rb, line 32
+def add_gmap_marker (latitude,longitude,text)
+        javascript = ""
+        if(!latitude.nil?)
+                javascript = "<script>                                                
+                        latlng = new google.maps.LatLng(#{latitude}, #{longitude});
+                        marker = new google.maps.Marker({
+                                position: latlng, 
+                                map: map, 
+                                title:'#{text}'
+                        });
+                      </script>"
+        end
+        raw(javascript)
+end
+
+ +
+ + + + +
+ + +
+ +
+ get_address(latitude,longitude) + click to toggle source +
+ + +
+ +

Nos permite obtener en formato string el nombre de la ciudad o región +pasándo como parámetro latitud y longitud

+ + + +
+
# File app/helpers/application_helper.rb, line 14
+def get_address(latitude,longitude)
+                        
+                if (!latitude.nil?)
+                        require 'open-uri'
+                        require 'json'
+                        result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read)
+                        localidad = "near "+result['results'][0]['address_components'][3]['long_name']
+                else
+                        localidad = ""
+                end
+                
+                localidad     
+end
+
+ +
+ + + + +
+ + +
+ +
+ include_javascript(file) + click to toggle source +
+ + +
+ +

Nos permite incluir un javascript.

+ +
Deprecated: Usar javascript_include_tag en su lugar
+ + + +
+
# File app/helpers/application_helper.rb, line 6
+def include_javascript (file)
+    s = " <script type=\"text/javascript\">" + render(:file => file) + "</script>"
+    content_for(:head, raw(s))
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/ComentsController.html b/app/views/planet/doc/app/ComentsController.html new file mode 100644 index 0000000..16c91eb --- /dev/null +++ b/app/views/planet/doc/app/ComentsController.html @@ -0,0 +1,465 @@ + + + + + + +class ComentsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ComentsController

+ +
+ +

ComentsController nos permite +controlar las acciones relacionadas con los comentarios

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /coments POST /coments.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 62
+def create 
+  @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user
+      
+      if !params[:site_id].nil?
+              @site = Site.find(params[:site_id])
+      else       
+              @site = Site.find(params[:coment][:site_id]) 
+      end
+      @coment = @site.coments.create(params[:coment]) 
+      
+        
+
+      respond_to do |format|
+               if @coment.save
+                      format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' }
+                      format.json { render json: site_path(@site), status: :created, location: @coment }
+           else
+                  format.html { render action: "new" }
+                      format.json { render json: @coment.errors, status: :unprocessable_entity }
+               end
+      end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /coments/1 DELETE /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 104
+def destroy
+  @coment = current_user.coments.find(params[:id])  # busca solo en sitios asociados a current_user
+#  @coment = Coment.find(params[:id])
+  @coment.destroy
+
+  respond_to do |format|
+    format.html { redirect_to coments_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /coments/1/edit

+ + + +
+
# File app/controllers/coments_controller.rb, line 56
+def edit
+  @coment = Coment.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /coments GET /coments.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 10
+def index
+  
+
+       if params[:site_id].nil?      #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión
+    @coments = Coment.all                                                     #si no, se pondría solo esta linea
+    else
+    @coments = Site.find(params[:site_id]).coments  
+  end
+      
+      
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @coments }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Nos permite crear un nuevo comentario GET /coments/new GET +/coments/new.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 41
+def new
+  @coment = Coment.new
+  #@site = Site.find(params[:site_id])
+  if !params[:site_id].nil?   
+      @site = Site.find(params[:site_id])            
+  end
+      
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @coment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Muestra un comentario especifico GET /coments/1 GET /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 29
+def show
+  @coment = Coment.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @coment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /coments/1 PUT /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 87
+def update
+  @coment = current_user.coments.find(params[:id])  # busca solo en sitios asociados a current_user
+ # @coment = Coment.find(params[:id])
+
+  respond_to do |format|
+    if @coment.update_attributes(params[:coment])
+      format.html { redirect_to @coment, notice: 'Coment was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @coment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/ComentsHelper.html b/app/views/planet/doc/app/ComentsHelper.html new file mode 100644 index 0000000..47259ed --- /dev/null +++ b/app/views/planet/doc/app/ComentsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module ComentsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ComentsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/PlanetController.html b/app/views/planet/doc/app/PlanetController.html new file mode 100644 index 0000000..2f05dcc --- /dev/null +++ b/app/views/planet/doc/app/PlanetController.html @@ -0,0 +1,397 @@ + + + + + + +class PlanetController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class PlanetController

+ +
+ +

PlanetController ilustra el uso de +RDoc. La documentación de un proyecto en genera en el +directorio proy/doc en formato Web con

+ +
$proy> rake doc:app
+ +

Algunos comandos de formateo

+ +

Tal y como muestra el subitulo anterior, este se define empezando la línea +con ==. En los títulos debe empezar por =.

+ +

Un [ … ] seguido de texto define una lista titulada, como aquí

+
Clases, Módulos o Métodos +
+

Se documentan con comentarios justo encima de sus definición, como aquí.

+
+ +

Un * o - definen las entradas de una lista itemizada

+ + +

Un número o letra seguido de punto genera una lista númerada

+
  1. +

    + permite generar negrita, igual que con +HTML

    +
  2. +

    _ permite generar cursiva, igual que con HTML

    +
    • +

      permite generar letra de teletipo, igual que con +HTML

      +
    +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ author() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 37
+def author
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 34
+def contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ ejemplo() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 40
+def ejemplo
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 31
+def index
+end
+
+ +
+ + + + +
+ + +
+ +
+ jsonp() + click to toggle source +
+ + +
+ +

Método para definir la acción que nos permite parsear json de la API de +googlemaps +No renderiza el layout+

+ + + +
+
# File app/controllers/planet_controller.rb, line 45
+ def jsonp
+      render :layout => false
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/PlanetHelper.html b/app/views/planet/doc/app/PlanetHelper.html new file mode 100644 index 0000000..fb564f2 --- /dev/null +++ b/app/views/planet/doc/app/PlanetHelper.html @@ -0,0 +1,153 @@ + + + + + + +module PlanetHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module PlanetHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/SitesController.html b/app/views/planet/doc/app/SitesController.html new file mode 100644 index 0000000..a1082db --- /dev/null +++ b/app/views/planet/doc/app/SitesController.html @@ -0,0 +1,447 @@ + + + + + + +class SitesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class SitesController

+ +
+ +

SitesController nos permite controlar +las acciones relacionadas con los sitios

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /sites POST /sites.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 56
+def create
+   @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user
+
+  respond_to do |format|
+    if @site.save
+      format.html { redirect_to @site, notice: 'Site was successfully created.' }
+      format.json { render json: @site, status: :created, location: @site }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @site.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /sites/1 DELETE /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 88
+def destroy
+  @site = current_user.sites.find(params[:id])  # 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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /sites/1/edit

+ + + +
+
# File app/controllers/sites_controller.rb, line 50
+def edit
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /sites GET /sites.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 12
+def index
+  if params[:type_id].nil? or params[:type_id].empty?
+    @sites = Site.all            # path: /types
+    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 }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /sites/new GET /sites/new.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 40
+def new
+  @site = current_user.sites.build # crea sitio vacio asociado a current_user
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @site }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /sites/1 GET /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 26
+def show
+  @site = Site.find(params[:id])
+
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @site }
+        format.json { render json: @coments }
+
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /sites/1 PUT /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 72
+def update
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+
+  respond_to do |format|
+    if @site.update_attributes(params[:site])
+      format.html { redirect_to @site, notice: 'Site was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @site.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/SitesHelper.html b/app/views/planet/doc/app/SitesHelper.html new file mode 100644 index 0000000..650a688 --- /dev/null +++ b/app/views/planet/doc/app/SitesHelper.html @@ -0,0 +1,197 @@ + + + + + + +module SitesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module SitesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ new_gmap(latitude,longitude,zoom) + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/sites_helper.rb, line 2
+def new_gmap(latitude,longitude,zoom)    
+
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/Trip.html b/app/views/planet/doc/app/Trip.html new file mode 100644 index 0000000..c2bdc6c --- /dev/null +++ b/app/views/planet/doc/app/Trip.html @@ -0,0 +1,157 @@ + + + + + + +class Trip - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Trip

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/TripsController.html b/app/views/planet/doc/app/TripsController.html new file mode 100644 index 0000000..3b8a417 --- /dev/null +++ b/app/views/planet/doc/app/TripsController.html @@ -0,0 +1,442 @@ + + + + + + +class TripsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TripsController

+ +
+ +

TripsController nos permite controlar +las acciones relacionadas con los viajes

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /trips POST /trips.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 49
+def create
+  @trip = current_user.trips.build(params[:trip])
+
+  respond_to do |format|
+    if @trip.save
+      format.html { redirect_to @trip, notice: 'Trip was successfully created.' }
+      format.json { render json: @trip, status: :created, location: @trip }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @trip.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /trips/1 DELETE /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 81
+def destroy
+  @trip = current_user.trips.find(params[:id])
+  @trip.destroy
+
+  respond_to do |format|
+    format.html { redirect_to trips_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /trips/1/edit

+ + + +
+
# File app/controllers/trips_controller.rb, line 43
+def edit
+  @trip = current_user.trips.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /trips GET /trips.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 10
+def index
+  @trips = Trip.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @trips }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /trips/new GET /trips/new.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 33
+def new
+  @trip = current_user.trips.build
+  
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /trips/1 GET /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 21
+def show
+  @trip = Trip.find(params[:id])
+  @visit = @trip.visits.build
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /trips/1 PUT /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 65
+def update
+  @trip = current_user.trips.find(params[:id])
+  
+  respond_to do |format|
+    if @trip.update_attributes(params[:trip])
+      format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @trip.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/TripsHelper.html b/app/views/planet/doc/app/TripsHelper.html new file mode 100644 index 0000000..d5f992a --- /dev/null +++ b/app/views/planet/doc/app/TripsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module TripsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TripsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/TypesController.html b/app/views/planet/doc/app/TypesController.html new file mode 100644 index 0000000..d66042b --- /dev/null +++ b/app/views/planet/doc/app/TypesController.html @@ -0,0 +1,475 @@ + + + + + + +class TypesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TypesController

+ +
+ +

Controlador de los tipos

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /types POST /types.json

+ + + +
+
# File app/controllers/types_controller.rb, line 60
+def create
+  @type = Type.new(params[:type])
+
+  respond_to do |format|
+    if @type.save
+      format.html { redirect_to @type, notice: 'Type was successfully created.' }
+      format.json { render json: @type, status: :created, location: @type }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /types/1 DELETE /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 92
+def destroy
+  @type = Type.find(params[:id])
+  @type.destroy
+
+  respond_to do |format|
+    format.html { redirect_to types_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /types/1/edit

+ + + +
+
# File app/controllers/types_controller.rb, line 54
+def edit
+  @type = Type.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /types GET /types.json

+ + + +
+
# File app/controllers/types_controller.rb, line 20
+def index
+  @types = Type.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /types/new GET /types/new.json

+ + + +
+
# File app/controllers/types_controller.rb, line 44
+def new
+  @type = Type.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ ordered_index() + click to toggle source +
+ + +
+ +

GET /types GET /types.json Devuelve una lista ordenada por nombre

+ + + +
+
# File app/controllers/types_controller.rb, line 7
+def ordered_index
+      @types = Type.find(:all, :order => :name) 
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /types/1 GET /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 33
+def show
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /types/1 PUT /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 76
+def update
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    if @type.update_attributes(params[:type])
+      format.html { redirect_to @type, notice: 'Type was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/TypesHelper.html b/app/views/planet/doc/app/TypesHelper.html new file mode 100644 index 0000000..1cf73d9 --- /dev/null +++ b/app/views/planet/doc/app/TypesHelper.html @@ -0,0 +1,151 @@ + + + + + + +module TypesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TypesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/User.html b/app/views/planet/doc/app/User.html new file mode 100644 index 0000000..afb0e72 --- /dev/null +++ b/app/views/planet/doc/app/User.html @@ -0,0 +1,157 @@ + + + + + + +class User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/Visit.html b/app/views/planet/doc/app/Visit.html new file mode 100644 index 0000000..e3c36e9 --- /dev/null +++ b/app/views/planet/doc/app/Visit.html @@ -0,0 +1,157 @@ + + + + + + +class Visit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Visit

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/VisitsController.html b/app/views/planet/doc/app/VisitsController.html new file mode 100644 index 0000000..cc00fb9 --- /dev/null +++ b/app/views/planet/doc/app/VisitsController.html @@ -0,0 +1,440 @@ + + + + + + +class VisitsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class VisitsController

+ +
+ +

VisitsController para las visitas

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /visits POST /visits.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 46
+def create
+  @visit = Visit.new(params[:visit])
+
+  respond_to do |format|
+    if @visit.save
+      format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' }
+      format.js
+      format.json { render json: @visit, status: :created, location: @visit }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @visit.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /visits/1 DELETE /visits/1.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 79
+def destroy
+  @visit = Visit.find(params[:id])
+  @visit.destroy
+
+  respond_to do |format|
+    format.html { redirect_to @visit.trip }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /visits/1/edit

+ + + +
+
# File app/controllers/visits_controller.rb, line 40
+def edit
+  @visit = Visit.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /visits GET /visits.json Nos devuelve todas las visitas

+ + + +
+
# File app/controllers/visits_controller.rb, line 6
+def index
+  @visits = Visit.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @visits }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /visits/new GET /visits/new.json Para crear una nueva visita

+ + + +
+
# File app/controllers/visits_controller.rb, line 30
+def new
+  @visit = Visit.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /visits/1 GET /visits/1.json Sólo aquella que coincide con el parámetro +id

+ + + +
+
# File app/controllers/visits_controller.rb, line 18
+def show
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /visits/1 PUT /visits/1.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 63
+def update
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    if @visit.update_attributes(params[:visit])
+      format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @visit.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/app/views/planet/doc/app/VisitsHelper.html b/app/views/planet/doc/app/VisitsHelper.html new file mode 100644 index 0000000..dfd73b9 --- /dev/null +++ b/app/views/planet/doc/app/VisitsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module VisitsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module VisitsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/app/views/planet/doc/app/created.rid b/app/views/planet/doc/app/created.rid new file mode 100644 index 0000000..1e8f65c --- /dev/null +++ b/app/views/planet/doc/app/created.rid @@ -0,0 +1,22 @@ +Fri, 27 Apr 2012 00:28:16 +0200 +doc/README_FOR_APP Sun, 22 Apr 2012 18:24:18 +0200 +app/models/trip.rb Thu, 12 Apr 2012 12:33:34 +0200 +app/models/user.rb Sun, 15 Apr 2012 11:06:32 +0200 +app/models/coment.rb Thu, 19 Apr 2012 15:16:14 +0200 +app/models/visit.rb Thu, 12 Apr 2012 12:33:34 +0200 +app/models/type.rb Sun, 22 Apr 2012 18:24:18 +0200 +app/models/site.rb Sat, 14 Apr 2012 19:45:02 +0200 +app/controllers/application_controller.rb Fri, 27 Apr 2012 00:19:36 +0200 +app/controllers/visits_controller.rb Fri, 27 Apr 2012 00:23:17 +0200 +app/controllers/sites_controller.rb Fri, 27 Apr 2012 00:20:47 +0200 +app/controllers/coments_controller.rb Fri, 27 Apr 2012 00:21:05 +0200 +app/controllers/types_controller.rb Fri, 27 Apr 2012 00:22:16 +0200 +app/controllers/trips_controller.rb Fri, 27 Apr 2012 00:21:34 +0200 +app/controllers/planet_controller.rb Fri, 27 Apr 2012 00:13:18 +0200 +app/helpers/planet_helper.rb Fri, 27 Apr 2012 00:27:36 +0200 +app/helpers/application_helper.rb Fri, 27 Apr 2012 00:25:52 +0200 +app/helpers/sites_helper.rb Thu, 26 Apr 2012 01:54:18 +0200 +app/helpers/visits_helper.rb Fri, 27 Apr 2012 00:27:45 +0200 +app/helpers/trips_helper.rb Fri, 27 Apr 2012 00:27:40 +0200 +app/helpers/types_helper.rb Sun, 22 Apr 2012 18:24:18 +0200 +app/helpers/coments_helper.rb Fri, 27 Apr 2012 00:27:30 +0200 diff --git a/app/views/planet/doc/app/doc/README_FOR_APP.html b/app/views/planet/doc/app/doc/README_FOR_APP.html new file mode 100644 index 0000000..c8b0478 --- /dev/null +++ b/app/views/planet/doc/app/doc/README_FOR_APP.html @@ -0,0 +1,117 @@ + + + + + + +README_FOR_APP - Rails Application Documentation + + + + + + + + + + + + + + + + +
+ +

Use this README file to introduce your application and point to useful +places in the API for learning more. Run “rake doc:app” to generate API +documentation for your models, controllers, helpers, and libraries.

+ +
+ + + + + diff --git a/app/views/planet/doc/app/images/add.png b/app/views/planet/doc/app/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/app/views/planet/doc/app/images/add.png differ diff --git a/app/views/planet/doc/app/images/brick.png b/app/views/planet/doc/app/images/brick.png new file mode 100644 index 0000000..7851cf3 Binary files /dev/null and b/app/views/planet/doc/app/images/brick.png differ diff --git a/app/views/planet/doc/app/images/brick_link.png b/app/views/planet/doc/app/images/brick_link.png new file mode 100644 index 0000000..9ebf013 Binary files /dev/null and b/app/views/planet/doc/app/images/brick_link.png differ diff --git a/app/views/planet/doc/app/images/bug.png b/app/views/planet/doc/app/images/bug.png new file mode 100644 index 0000000..2d5fb90 Binary files /dev/null and b/app/views/planet/doc/app/images/bug.png differ diff --git a/app/views/planet/doc/app/images/bullet_black.png b/app/views/planet/doc/app/images/bullet_black.png new file mode 100644 index 0000000..5761970 Binary files /dev/null and b/app/views/planet/doc/app/images/bullet_black.png differ diff --git a/app/views/planet/doc/app/images/bullet_toggle_minus.png b/app/views/planet/doc/app/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 Binary files /dev/null and b/app/views/planet/doc/app/images/bullet_toggle_minus.png differ diff --git a/app/views/planet/doc/app/images/bullet_toggle_plus.png b/app/views/planet/doc/app/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 Binary files /dev/null and b/app/views/planet/doc/app/images/bullet_toggle_plus.png differ diff --git a/app/views/planet/doc/app/images/date.png b/app/views/planet/doc/app/images/date.png new file mode 100644 index 0000000..783c833 Binary files /dev/null and b/app/views/planet/doc/app/images/date.png differ diff --git a/app/views/planet/doc/app/images/delete.png b/app/views/planet/doc/app/images/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/app/views/planet/doc/app/images/delete.png differ diff --git a/app/views/planet/doc/app/images/find.png b/app/views/planet/doc/app/images/find.png new file mode 100644 index 0000000..1547479 Binary files /dev/null and b/app/views/planet/doc/app/images/find.png differ diff --git a/app/views/planet/doc/app/images/loadingAnimation.gif b/app/views/planet/doc/app/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 Binary files /dev/null and b/app/views/planet/doc/app/images/loadingAnimation.gif differ diff --git a/app/views/planet/doc/app/images/macFFBgHack.png b/app/views/planet/doc/app/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 Binary files /dev/null and b/app/views/planet/doc/app/images/macFFBgHack.png differ diff --git a/app/views/planet/doc/app/images/package.png b/app/views/planet/doc/app/images/package.png new file mode 100644 index 0000000..da3c2a2 Binary files /dev/null and b/app/views/planet/doc/app/images/package.png differ diff --git a/app/views/planet/doc/app/images/page_green.png b/app/views/planet/doc/app/images/page_green.png new file mode 100644 index 0000000..de8e003 Binary files /dev/null and b/app/views/planet/doc/app/images/page_green.png differ diff --git a/app/views/planet/doc/app/images/page_white_text.png b/app/views/planet/doc/app/images/page_white_text.png new file mode 100644 index 0000000..813f712 Binary files /dev/null and b/app/views/planet/doc/app/images/page_white_text.png differ diff --git a/app/views/planet/doc/app/images/page_white_width.png b/app/views/planet/doc/app/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 Binary files /dev/null and b/app/views/planet/doc/app/images/page_white_width.png differ diff --git a/app/views/planet/doc/app/images/plugin.png b/app/views/planet/doc/app/images/plugin.png new file mode 100644 index 0000000..6187b15 Binary files /dev/null and b/app/views/planet/doc/app/images/plugin.png differ diff --git a/app/views/planet/doc/app/images/ruby.png b/app/views/planet/doc/app/images/ruby.png new file mode 100644 index 0000000..f763a16 Binary files /dev/null and b/app/views/planet/doc/app/images/ruby.png differ diff --git a/app/views/planet/doc/app/images/tag_blue.png b/app/views/planet/doc/app/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f Binary files /dev/null and b/app/views/planet/doc/app/images/tag_blue.png differ diff --git a/app/views/planet/doc/app/images/tag_green.png b/app/views/planet/doc/app/images/tag_green.png new file mode 100644 index 0000000..83ec984 Binary files /dev/null and b/app/views/planet/doc/app/images/tag_green.png differ diff --git a/app/views/planet/doc/app/images/transparent.png b/app/views/planet/doc/app/images/transparent.png new file mode 100644 index 0000000..d665e17 Binary files /dev/null and b/app/views/planet/doc/app/images/transparent.png differ diff --git a/app/views/planet/doc/app/images/wrench.png b/app/views/planet/doc/app/images/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/app/views/planet/doc/app/images/wrench.png differ diff --git a/app/views/planet/doc/app/images/wrench_orange.png b/app/views/planet/doc/app/images/wrench_orange.png new file mode 100644 index 0000000..565a933 Binary files /dev/null and b/app/views/planet/doc/app/images/wrench_orange.png differ diff --git a/app/views/planet/doc/app/images/zoom.png b/app/views/planet/doc/app/images/zoom.png new file mode 100644 index 0000000..908612e Binary files /dev/null and b/app/views/planet/doc/app/images/zoom.png differ diff --git a/app/views/planet/doc/app/index.html b/app/views/planet/doc/app/index.html new file mode 100644 index 0000000..1a3c1c3 --- /dev/null +++ b/app/views/planet/doc/app/index.html @@ -0,0 +1,110 @@ + + + + + + +Rails Application Documentation + + + + + + + + + + + + + + + + +

This is the API documentation for Rails Application Documentation. + + +

+ diff --git a/app/views/planet/doc/app/js/darkfish.js b/app/views/planet/doc/app/js/darkfish.js new file mode 100644 index 0000000..4be722f --- /dev/null +++ b/app/views/planet/doc/app/js/darkfish.js @@ -0,0 +1,153 @@ +/** + * + * Darkfish Page Functions + * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ + * + * Author: Michael Granger + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

Table of Contents - Rails Application Documentation

+ +

Pages

+ + +

Classes/Modules

+ + +

Methods

+ + + + + diff --git a/app/views/planet/ejemplo.html.erb b/app/views/planet/ejemplo.html.erb index cb05eb9..f6237be 100644 --- a/app/views/planet/ejemplo.html.erb +++ b/app/views/planet/ejemplo.html.erb @@ -1,3 +1,3 @@ -

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

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 +

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..a4a7a15 100644 --- a/app/views/planet/index.html.erb +++ b/app/views/planet/index.html.erb @@ -1 +1 @@ -

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.


\ No newline at end of file diff --git a/app/views/planet/jsonp.html.erb b/app/views/planet/jsonp.html.erb new file mode 100644 index 0000000..d7e4fa6 --- /dev/null +++ b/app/views/planet/jsonp.html.erb @@ -0,0 +1,18 @@ +<% + +require 'open-uri' +require 'json' + +address = params[:address] +address = address.gsub(" ","%20") + + +result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?address=#{address}&sensor=true").read) + + %> + + <%= + + result['results'][0]['geometry']['location'][params[:coor]] + + %> diff --git a/app/views/planet/search.html.erb b/app/views/planet/search.html.erb new file mode 100644 index 0000000..7bb6480 --- /dev/null +++ b/app/views/planet/search.html.erb @@ -0,0 +1,77 @@ +
+

Listing Sites

+ + + <% @sites.each do |site| %> + + + + + + + + + <% 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 'Comentarios', site_coments_path(site) %> + <%= ':' %> <%= site.coments.length %> + <% if site.coments.empty? %> + <%= 'Este sitio no tiene comentarios. ¿Añades uno?' %> + <% end %> +
+
+

+
+
+ <%= 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 'New site', new_site_path %> + +
+

Viajes

+ + + <% @trips.each do |trip| %> + + + + + + + <% 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 %> +
+

+ +<%= link_to 'New Trip', new_trip_path %> \ No newline at end of file diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb new file mode 100644 index 0000000..29f01e2 --- /dev/null +++ b/app/views/sites/_form.html.erb @@ -0,0 +1,53 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'sites.form.geolocation' %> +<%= javascript_include_tag 'sites.get.coordenates' %> + + +<%= form_for(@site) do |f| %> + <% if @site.errors.any? %> +
+

<%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image %>
+ <%= f.file_field :image %> +
+
+ <%= f.label :latitude %>
+ <%= f.text_field :latitude %> +
+
+ <%= f.label :longitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+
+

Finding your location: checking...

+
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sites/_form.html.erb~ b/app/views/sites/_form.html.erb~ new file mode 100644 index 0000000..78aa0eb --- /dev/null +++ b/app/views/sites/_form.html.erb~ @@ -0,0 +1,51 @@ + + + +<%= form_for(@site) do |f| %> + <% if @site.errors.any? %> +
+

<%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
+
+ <%= f.label :latitude %>
+ <%= f.text_field :latitude %> +
+
+ <%= f.label :longitude %>
+ <%= f.text_field :longitude %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+
+

Finding your location: checking...

+
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sites/edit.html.erb b/app/views/sites/edit.html.erb new file mode 100644 index 0000000..d46384f --- /dev/null +++ b/app/views/sites/edit.html.erb @@ -0,0 +1,6 @@ +

Editing site

+ +<%= render 'form' %> + +<%= link_to 'Show', @site %> | +<%= link_to 'Back', sites_path %> diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb new file mode 100644 index 0000000..7a4d6e3 --- /dev/null +++ b/app/views/sites/index.html.erb @@ -0,0 +1,46 @@ +
+

Listing Sites

+ + + <% @sites.each do |site| %> + + + + + + + + + <% 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 'Comentarios', site_coments_path(site) %> + <%= ':' %> <%= site.coments.length %> + <% if site.coments.empty? %> + <%= 'Este sitio no tiene comentarios. ¿Añades uno?' %> + <% end %> +
+
+

+
+
+ <%= 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 'New site', new_site_path %> \ No newline at end of file diff --git a/app/views/sites/new.html.erb b/app/views/sites/new.html.erb new file mode 100644 index 0000000..2988bdc --- /dev/null +++ b/app/views/sites/new.html.erb @@ -0,0 +1,5 @@ +

New site

+ +<%= render 'form' %> + +<%= link_to 'Back', sites_path %> diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb new file mode 100644 index 0000000..bd4f618 --- /dev/null +++ b/app/views/sites/show.html.erb @@ -0,0 +1,95 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'sites.show.geolocation' %> +<%= javascript_include_tag 'sites.coments.show.geolocation' %> + + +
+ + ites has no column named latitud + +

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

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

Location

+
+
+ +

<%= @site.name %>

+ +

<%=sanitize @site.description %>

+ +

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

+ + + + + + +
+ + + +
+ Visitas: <%= @site.visitas %> +
+ +
+ +

Comentarios:

+ <% @site.coments.each do |coment| %> +

+ +

+ <% if coment.user == current_user %> + <%= link_to 'Edit', edit_coment_path(coment) %> + <%= link_to 'Destroy', coment, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
+ <%= coment.user.name if coment.user %>: + <%= coment.coment %>
+ (<%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %>) +
+ +

+ <% end %> + + + + <%= form_for([@site, @site.coments.build]) do |f| %> + +
+ <%= f.hidden_field :latitude %> +
+
+ <%= f.hidden_field :longitude %> +
+
+ <%= f.hidden_field :zoom %> +
+ +
+ <%= f.label :comentario %>
+ <%= f.text_field :coment %> +
+
+ <% if current_user %> + <%= f.hidden_field(:user_id, :value => current_user.id)%> + <% end %> +
+
+ <%= f.submit %> +
+ <% end %> +
+ +<%= link_to 'Back', sites_path %> diff --git a/app/views/sites/show.html.erb~ b/app/views/sites/show.html.erb~ new file mode 100644 index 0000000..f5d2c5d --- /dev/null +++ b/app/views/sites/show.html.erb~ @@ -0,0 +1,95 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'sites.show.geolocation' %> +<%= javascript_include_tag 'sites.coments.show.geolocation' %> + + +
+ + ites has no column named latitud + +

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

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

Location

+
+
+ +

<%= @site.name %>

+ +

<%=sanitize @site.description %>

+ +

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

+ + + + + + +
+ + + +
+ Visitas: <%= @site.visitas %> +
+ +
+ +

Comentarios:

+ <% @site.coments.each do |coment| %> +

+ +

+ <% if coment.user == current_user %> + <%= link_to 'Edit', edit_coment_path(coment) %> + <%= link_to 'Destroy', coment, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
+ <%= coment.user.name if coment.user %>: + <%= coment.coment %>
+ (<%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %>) +
+ +

+ <% end %> + + + + <%= form_for([@site, @site.coments.build]) do |f| %> + +
+ <%= f.hidden_field :latitude %> +
+
+ <%= f.hidden_field :longitude %> +
+
+ <%= f.hidden_field :zoom %> +
+ +
+ <%= f.label :comentario %>
+ <%= f.text_field :coment %> +
+
+ <% if current_user %> + <%= f.hidden_field(:user_id, :value => current_user.id)%> + <% end %> +
+
+ <%= f.submit %> +
+ <% end %> +
+ +<%= link_to 'Back', sites_path %> diff --git a/app/views/sites/sites.map.js~ b/app/views/sites/sites.map.js~ new file mode 100644 index 0000000..29e3da9 --- /dev/null +++ b/app/views/sites/sites.map.js~ @@ -0,0 +1,37 @@ +function new_gmap(lat,long,zoomlevel) { + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + + var latlng = new google.maps.LatLng(lat, long); + var myOptions = { + zoom: zoomlevel, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById('mapcanvas'), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + + + diff --git a/app/views/trips/_form.html.erb b/app/views/trips/_form.html.erb new file mode 100644 index 0000000..fa8cb2f --- /dev/null +++ b/app/views/trips/_form.html.erb @@ -0,0 +1,30 @@ +<%= form_for(@trip) do |f| %> + <% if @trip.errors.any? %> +
+

<%= pluralize(@trip.errors.count, "error") %> prohibited this trip from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description %> +
+
+ <%= f.label :date %>
+ <%= f.date_select :date %> +
+ +
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/trips/_trip.html.erb b/app/views/trips/_trip.html.erb new file mode 100644 index 0000000..66d292e --- /dev/null +++ b/app/views/trips/_trip.html.erb @@ -0,0 +1,31 @@ +
+ + <% trip.visits.order(:hour).each do |visit| %> + + + + + + + + <%= add_gmap_marker(visit.site.latitude,visit.site.longitude,visit.site.name) %> + <% end %> +
+ <%= link_to image_tag(visit.site.image.url, :class => 'list_image'), visit.site %> + +
+
<%= visit.hour.to_s + 'h: ' %> + <%=link_to(visit.site.name, visit.site) %>
+
<%= truncate(strip_tags(visit.site.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', visit.site %>
+ <%= link_to 'Destroy', visit, + :confirm => 'Are you sure?', + :method => :delete if trip.user == current_user %> + +
+ +
+ diff --git a/app/views/trips/_trip.html.erb~ b/app/views/trips/_trip.html.erb~ new file mode 100644 index 0000000..c5d0825 --- /dev/null +++ b/app/views/trips/_trip.html.erb~ @@ -0,0 +1,31 @@ +
+ + <% trip.visits.order(:hour).each do |visit| %> + + + + + + + + <%= add_gmap_marker(visit.site.latitude,visit.site.longitude,visit.site.name) %> + <% end %> +
+ <%= link_to image_tag(visit.site.image_url, :class => 'list_image'), visit.site %> + +
+
<%= visit.hour.to_s + 'h: ' %> + <%=link_to(visit.site.name, visit.site) %>
+
<%= truncate(strip_tags(visit.site.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', visit.site %>
+ <%= link_to 'Destroy', visit, + :confirm => 'Are you sure?', + :method => :delete if trip.user == current_user %> + +
+ +
+ diff --git a/app/views/trips/edit.html.erb b/app/views/trips/edit.html.erb new file mode 100644 index 0000000..71287a4 --- /dev/null +++ b/app/views/trips/edit.html.erb @@ -0,0 +1,6 @@ +

Editing trip

+ +<%= render 'form' %> + +<%= link_to 'Show', @trip %> | +<%= link_to 'Back', trips_path %> diff --git a/app/views/trips/index.html.erb b/app/views/trips/index.html.erb new file mode 100644 index 0000000..ec66e06 --- /dev/null +++ b/app/views/trips/index.html.erb @@ -0,0 +1 @@ +

Viajes

<% @trips.each do |trip| %> <% 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 %>

<%= link_to 'New Trip', new_trip_path %> \ No newline at end of file diff --git a/app/views/trips/new.html.erb b/app/views/trips/new.html.erb new file mode 100644 index 0000000..dd3e49d --- /dev/null +++ b/app/views/trips/new.html.erb @@ -0,0 +1,5 @@ +

New trip

+ +<%= render 'form' %> + +<%= link_to 'Back', trips_path %> diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb new file mode 100644 index 0000000..926ad00 --- /dev/null +++ b/app/views/trips/show.html.erb @@ -0,0 +1 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>

Name: <%= @trip.name %>

Date: <%= @trip.date %>

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

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

Location

<%= javascript_include_tag 'trips.show.geolocation' %>

Sitios a visitar

<%= render(@trip) %> <% if @trip.user == current_user %> <%= form_for(@visit, :remote => true) do |f| %> <%= f.number_field :trip_id, :value => @trip.id, :hidden => true %> <%= f.collection_select(:site_id, Site.all, :id, :name) %> <%= f.select(:hour, Array.new(24, 0).fill {|i| [(i.to_s + 'H'), i]}) %> <%= f.submit "Añadir sitio" %> <% end %> <% end %>

<% if @trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(@trip) %> | <% end %> <%= link_to 'Back', trips_path %> \ No newline at end of file diff --git a/app/views/trips/show.html.erb~ b/app/views/trips/show.html.erb~ new file mode 100644 index 0000000..949b357 --- /dev/null +++ b/app/views/trips/show.html.erb~ @@ -0,0 +1 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>

Name: <%= @trip.name %>

Date: <%= @trip.date %>

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

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

Location

<%= javascript_include_tag 'trips.show.geolocation' %>

Sitios a visitar

<%= render(@trip) %> <% if @trip.user == current_user %> <%= form_for(@visit, :remote => true) do |f| %> <%= f.number_field :trip_id, :value => @trip.id, :hidden => true %> <%= f.collection_select(:site_id, Site.all, :id, :name) %> <%= f.select(:hour, Array.new(24, 0).fill {|i| [(i.to_s + 'H'), i]}) %> <%= f.submit "Añadir sitio" %> <% end %> <% end %>

<% if @trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(@trip) %> | <% end %> <%= link_to 'Back', trips_path %> \ No newline at end of file diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index 50bda49..7fef715 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -1,24 +1,29 @@ -

Listing types

- - - - - - - - - - -<% @types.each do |type| %> - - - - - - - -<% end %> -
NameDescription
<%= type.name %><%= type.description %><%= link_to 'Show', type %><%= link_to 'Edit', edit_type_path(type) %><%= link_to 'Destroy', type, confirm: 'Are you sure?', method: :delete %>
+
+

Listing Types

+ + + <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type, + :confirm => 'Are you sure?', + :method => :delete %> +
+

diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb new file mode 100644 index 0000000..0eabc9e --- /dev/null +++ b/app/views/types/ordered_index.html.erb @@ -0,0 +1,28 @@ +

Listing ordered types

+ + + + + + + + + + + +<% @types.each do |type| %> + + + + + + + + +<% end %> +
Última modificaciónNameDescription
<%= type.updated_at %><%= type.name %><%= type.description %><%= 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..eeef754 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -1,4 +1,9 @@ -

<%= notice %>

+

<%= notice %>

+ +

+ Última modificación: + <%= @type.updated_at %> +

Name: @@ -13,3 +18,4 @@ <%= link_to 'Edit', edit_type_path(@type) %> | <%= link_to 'Back', types_path %> + diff --git a/app/views/visits/_form.html.erb b/app/views/visits/_form.html.erb new file mode 100644 index 0000000..12ab912 --- /dev/null +++ b/app/views/visits/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for(@visit) do |f| %> + <% if @visit.errors.any? %> +

+

<%= pluralize(@visit.errors.count, "error") %> prohibited this visit from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :trip_id %>
+ <%= f.number_field :trip_id %> +
+
+ <%= f.label :site_id %>
+ <%= f.number_field :site_id %> +
+
+ <%= f.label :hour %>
+ <%= f.number_field :hour %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/visits/create.js.erb b/app/views/visits/create.js.erb new file mode 100644 index 0000000..b41cad6 --- /dev/null +++ b/app/views/visits/create.js.erb @@ -0,0 +1 @@ +$('#visit').html("<%= j render @visit.trip %>"); \ No newline at end of file diff --git a/app/views/visits/edit.html.erb b/app/views/visits/edit.html.erb new file mode 100644 index 0000000..66d34d9 --- /dev/null +++ b/app/views/visits/edit.html.erb @@ -0,0 +1,6 @@ +

Editing visit

+ +<%= render 'form' %> + +<%= link_to 'Show', @visit %> | +<%= link_to 'Back', visits_path %> diff --git a/app/views/visits/index.html.erb b/app/views/visits/index.html.erb new file mode 100644 index 0000000..c7bea46 --- /dev/null +++ b/app/views/visits/index.html.erb @@ -0,0 +1,27 @@ +

Listing visits

+ + + + + + + + + + + +<% @visits.each do |visit| %> + + + + + + + + +<% end %> +
TripSiteHour
<%= visit.trip_id %><%= visit.site_id %><%= visit.hour %><%= link_to 'Show', visit %><%= link_to 'Edit', edit_visit_path(visit) %><%= link_to 'Destroy', visit, confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Visit', new_visit_path %> diff --git a/app/views/visits/new.html.erb b/app/views/visits/new.html.erb new file mode 100644 index 0000000..1be1930 --- /dev/null +++ b/app/views/visits/new.html.erb @@ -0,0 +1,5 @@ +

New visit

+ +<%= render 'form' %> + +<%= link_to 'Back', visits_path %> diff --git a/app/views/visits/show.html.erb b/app/views/visits/show.html.erb new file mode 100644 index 0000000..2bf41f5 --- /dev/null +++ b/app/views/visits/show.html.erb @@ -0,0 +1,20 @@ +

<%= notice %>

+ +

+ Trip: + <%= @visit.trip_id %> +

+ +

+ Site: + <%= @visit.site_id %> +

+ +

+ Hour: + <%= @visit.hour %> +

+ + +<%= link_to 'Edit', edit_visit_path(@visit) %> | +<%= link_to 'Back', visits_path %> diff --git a/config/application.rb b/config/application.rb index 5ab23d7..9f505c5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,7 +44,7 @@ class Application < Rails::Application # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. + # Enforce whitelist mode for mass assignment. # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. @@ -55,5 +55,9 @@ class Application < Rails::Application # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + # Avoid problem when deploying to Heroku + # https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar#troubleshooting + config.assets.initialize_on_precompile = false end end diff --git a/config/boot.rb b/config/boot.rb index 4489e58..e9f2a0f 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,5 +1,8 @@ require 'rubygems' +require 'yaml' +YAML::ENGINE.yamler = 'syck' + # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/config/boot.rb~ b/config/boot.rb~ new file mode 100644 index 0000000..4489e58 --- /dev/null +++ b/config/boot.rb~ @@ -0,0 +1,6 @@ +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/environments/development.rb b/config/environments/development.rb index 90121c9..99037c3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,6 +16,9 @@ # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false + # introducido para devise!!!! + config.action_mailer.default_url_options = { :host => 'localhost:3000' } + # Print deprecation notices to the Rails logger config.active_support.deprecation = :log @@ -34,4 +37,4 @@ # Expands the lines which load the assets config.assets.debug = true -end +end \ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..a78d7ea --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,223 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class with default "from" parameter. + config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" + + # Configure the class responsible to send e-mails. + # config.mailer = "Devise::Mailer" + + # Automatically apply schema changes in tableless databases + config.apply_schema = false + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [ :email ] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:token]` will + # enable it only for token authentication. + # config.http_authenticatable = false + + # If http headers should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. "Application" by default. + # config.http_authentication_realm = "Application" + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # :http_auth and :token_auth by adding those symbols to the array below. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing :skip => :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. + config.stretches = Rails.env.test? ? 1 : 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = "f807173825cac6c9c837bda6b02a30347a55bf933bb79161023a13d6827452aca8150a7940b27a4abf741e0159050a7b80787f789373c4a8b4475e1b2b3a47f6" + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming his account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming his account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming his account. + # config.allow_unconfirmed_access_for = 2.days + + # If true, requires any email changes to be confirmed (exctly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed new email is stored in + # unconfirmed email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # If true, uses the password salt as remember token. This should be turned + # to false if you are not using database authenticatable. + config.use_salt_as_remember_token = true + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.cookie_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 6..128. + # config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # an one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper) + # config.encryptor = :sha512 + + # ==> Configuration for :token_authenticatable + # Defines name of the authentication token params key + # config.token_authentication_key = :auth_token + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Configure sign_out behavior. + # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). + # The default is true, which means any logout action will sign out all active scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ["*/*", :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # end +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..73df488 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,57 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + errors: + messages: + expired: "has expired, please request a new one" + not_found: "not found" + already_confirmed: "was already confirmed, please try signing in" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" + + devise: + failure: + already_authenticated: 'You are already signed in.' + unauthenticated: 'You need to sign in or sign up before continuing.' + unconfirmed: 'You have to confirm your account before continuing.' + locked: 'Your account is locked.' + invalid: 'Invalid email or password.' + invalid_token: 'Invalid authentication token.' + timeout: 'Your session expired, please sign in again to continue.' + inactive: 'Your account was not activated yet.' + sessions: + signed_in: 'Signed in successfully.' + signed_out: 'Signed out successfully.' + passwords: + send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' + updated: 'Your password was changed successfully. You are now signed in.' + updated_not_active: 'Your password was changed successfully.' + send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail" + confirmations: + send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' + send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' + confirmed: 'Your account was successfully confirmed. You are now signed in.' + registrations: + signed_up: 'Welcome! You have signed up successfully.' + signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' + signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' + signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' + updated: 'You updated your account successfully.' + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + unlocks: + send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' + unlocked: 'Your account has been unlocked successfully. Please sign in to continue.' + send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.' + omniauth_callbacks: + success: 'Successfully authorized from %{kind} account.' + failure: 'Could not authorize you from %{kind} because "%{reason}".' + mailer: + confirmation_instructions: + subject: 'Confirmation instructions' + reset_password_instructions: + subject: 'Reset password instructions' + unlock_instructions: + subject: 'Unlock Instructions' diff --git a/config/routes.rb b/config/routes.rb index 4cd1976..9e76324 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,35 @@ Planet::Application.routes.draw do - resources :types + resources :coments + resources :visits + + resources :trips + + devise_for :users + + resources :sites do + resources :coments + end + + resources :types do # Rutas anidadas /types/id/sites..., + resources :sites, :only => [ :index ] # Restringe a accin index + + get "ordered_index", :on => :collection + end + + get "planet/search" + get "planet/index" get "planet/contact" get "planet/ejemplo" + + get "planet/author" + + get "planet/jsonp" + + get "doc/app" # The priority is based upon order of creation: # first created -> highest priority. diff --git a/config/routes.rb~ b/config/routes.rb~ new file mode 100644 index 0000000..68b081a --- /dev/null +++ b/config/routes.rb~ @@ -0,0 +1,92 @@ +Planet::Application.routes.draw do + resources :coments + + resources :visits + + resources :trips + + devise_for :users + + resources :sites do + resources :coments + end + + resources :types do # Rutas anidadas /types/id/sites..., + resources :sites, :only => [ :index ] # Restringe a accin index + + get "ordered_index", :on => :collection + end + + get "planet/search" + + get "planet/index" + + get "planet/contact" + + get "planet/ejemplo" + + get "planet/author" + + get "planet/jsonp" + + get "planet/doc" + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # 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)))' +end diff --git a/db/development.sql b/db/development.sql new file mode 100644 index 0000000..b28910e --- /dev/null +++ b/db/development.sql @@ -0,0 +1 @@ +SELECT * FROM users; \ No newline at end of file diff --git a/db/migrate/20120320100145_create_sites.rb b/db/migrate/20120320100145_create_sites.rb new file mode 100644 index 0000000..602645a --- /dev/null +++ b/db/migrate/20120320100145_create_sites.rb @@ -0,0 +1,12 @@ +class CreateSites < ActiveRecord::Migration + def change + create_table :sites do |t| + t.string :name + t.text :description + t.integer :type_id + t.string :image_url + + t.timestamps + end + end +end \ No newline at end of file diff --git a/db/migrate/20120328230302_devise_create_users.rb b/db/migrate/20120328230302_devise_create_users.rb new file mode 100644 index 0000000..540333c --- /dev/null +++ b/db/migrate/20120328230302_devise_create_users.rb @@ -0,0 +1,49 @@ +class DeviseCreateUsers < ActiveRecord::Migration + def change + create_table(:users) do |t| + ## Database authenticatable + t.string :email, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, :default => 0 + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Encryptable + # t.string :password_salt + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + ## Token authenticatable + # t.string :authentication_token + + + t.timestamps + end + + add_index :users, :email, :unique => true + add_index :users, :reset_password_token, :unique => true + # add_index :users, :confirmation_token, :unique => true + # add_index :users, :unlock_token, :unique => true + # add_index :users, :authentication_token, :unique => true + end +end diff --git a/db/migrate/20120329060322_user_name.rb b/db/migrate/20120329060322_user_name.rb new file mode 100644 index 0000000..14ba63a --- /dev/null +++ b/db/migrate/20120329060322_user_name.rb @@ -0,0 +1,13 @@ +class UserName < ActiveRecord::Migration + def up + change_table :users do |t| # añade la columna name a la tabla sites + t.column :name, :string + end + end + + def down + change_table :users do |t| + t.remove :name + end + end +end diff --git a/db/migrate/20120329080433_user_sites.rb b/db/migrate/20120329080433_user_sites.rb new file mode 100644 index 0000000..37bbc3b --- /dev/null +++ b/db/migrate/20120329080433_user_sites.rb @@ -0,0 +1,13 @@ +class UserSites < ActiveRecord::Migration + def up + change_table :sites do |t| # añade la columna user_id a la tabla sites + t.column :user_id, :integer + end + end + + def down + change_table :sites do |t| + t.remove :user_id + end + end +end diff --git a/db/migrate/20120409085740_create_trips.rb b/db/migrate/20120409085740_create_trips.rb new file mode 100644 index 0000000..9acf33c --- /dev/null +++ b/db/migrate/20120409085740_create_trips.rb @@ -0,0 +1,12 @@ +class CreateTrips < ActiveRecord::Migration + def change + create_table :trips do |t| + t.string :name + t.text :description + t.date :date + t.integer :user_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120409143117_create_visits.rb b/db/migrate/20120409143117_create_visits.rb new file mode 100644 index 0000000..248b6be --- /dev/null +++ b/db/migrate/20120409143117_create_visits.rb @@ -0,0 +1,11 @@ +class CreateVisits < ActiveRecord::Migration + def change + create_table :visits do |t| + t.integer :trip_id + t.integer :site_id + t.integer :hour + + t.timestamps + end + end +end diff --git a/db/migrate/20120411095828_add_paperclip_to_sites.rb b/db/migrate/20120411095828_add_paperclip_to_sites.rb new file mode 100644 index 0000000..b9bbcbc --- /dev/null +++ b/db/migrate/20120411095828_add_paperclip_to_sites.rb @@ -0,0 +1,19 @@ +class AddPaperclipToSites < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :image_file_name, :string + t.column :image_content_type, :string + t.column :image_file_size, :string + t.column :image_updated_at, :datetime + end + end + + def down + change_table :sites do |t| + t.remove :image_file_name, :string + t.remove :image_content_type, :string + t.remove :image_file_size, :string + t.remove :image_updated_at, :datetime + end + end +end diff --git a/db/migrate/20120411160519_site_visitas.rb b/db/migrate/20120411160519_site_visitas.rb new file mode 100644 index 0000000..25cd06d --- /dev/null +++ b/db/migrate/20120411160519_site_visitas.rb @@ -0,0 +1,13 @@ +class SiteVisitas < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :visitas, :integer, :default => 0 + end + end + + def down + change_table :sites do |t| + t.remove :visitas + end + end +end diff --git a/db/migrate/20120414173600_create_coments.rb b/db/migrate/20120414173600_create_coments.rb new file mode 100644 index 0000000..fbc3afa --- /dev/null +++ b/db/migrate/20120414173600_create_coments.rb @@ -0,0 +1,11 @@ +class CreateComents < ActiveRecord::Migration + def change + create_table :coments do |t| + t.string :coment + t.integer :user_id + t.integer :site_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120422161356_add_longitude_and_latitude_and_zoom_to_sites.rb b/db/migrate/20120422161356_add_longitude_and_latitude_and_zoom_to_sites.rb new file mode 100644 index 0000000..9120adf --- /dev/null +++ b/db/migrate/20120422161356_add_longitude_and_latitude_and_zoom_to_sites.rb @@ -0,0 +1,10 @@ +class AddLongitudeAndLatitudeAndZoomToSites < ActiveRecord::Migration + def change + add_column :sites, :longitude, :float + + add_column :sites, :latitude, :float + + add_column :sites, :zoom, :float + + end +end diff --git a/db/migrate/20120423013602_add_longitude_and_latitude_and_zoom_to_coments.rb b/db/migrate/20120423013602_add_longitude_and_latitude_and_zoom_to_coments.rb new file mode 100644 index 0000000..afb438d --- /dev/null +++ b/db/migrate/20120423013602_add_longitude_and_latitude_and_zoom_to_coments.rb @@ -0,0 +1,10 @@ +class AddLongitudeAndLatitudeAndZoomToComents < ActiveRecord::Migration + def change + add_column :coments, :longitude, :float + + add_column :coments, :latitude, :float + + add_column :coments, :zoom, :int + + end +end diff --git a/db/schema.rb b/db/schema.rb index 8084ffc..ac061c6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,45 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120317231537) do +ActiveRecord::Schema.define(:version => 20120423013602) do + + create_table "coments", :force => true do |t| + t.string "coment" + t.integer "user_id" + t.integer "site_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "longitude" + t.float "latitude" + t.integer "zoom" + end + + create_table "sites", :force => true do |t| + t.string "name" + t.text "description" + t.integer "type_id" + t.string "image_url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + t.string "image_file_name" + t.string "image_content_type" + t.string "image_file_size" + t.datetime "image_updated_at" + t.integer "visitas", :default => 0 + t.float "longitude" + t.float "latitude" + t.float "zoom" + end + + create_table "trips", :force => true do |t| + t.string "name" + t.text "description" + t.date "date" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end create_table "types", :force => true do |t| t.string "name" @@ -20,4 +58,31 @@ t.datetime "updated_at", :null => false end + create_table "users", :force => true do |t| + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", :default => 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "name" + end + + add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + + create_table "visits", :force => true do |t| + t.integer "trip_id" + t.integer "site_id" + t.integer "hour" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + end diff --git a/db/seeds.rb b/db/seeds.rb index ca6a311..bb2ec2b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,20 +1,60 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# This file should contain all the record creation needed to seed the +# database with its default values. The data can then be loaded with +# the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -Type.create( +Type.delete_all + +tm = Type.create( name: 'Monumento', description: 'Edificio de interes turistico o artistico') -Type.create( +tn = Type.create( name: 'Naturaleza', description: 'Lugar al aire libre de interes natural o de recreo') -Type.create( +tr = Type.create( name: 'Ruina', description: 'Lugar o resto de interes arquelogico') + +Site.delete_all + + +Site.create( + name: 'Pedriza', + description: 'Magnifico valle al norte de Madrid en el Macizo Central', + type_id: tn.id, + image_url: 'pedriza.png') + +Site.create( + name: 'Catedral de Florencia', + description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento', + type_id: tm.id, + image_url: 'florencia.png') + +Site.create( + name: 'Jardin de Lineo', + description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista enia su coleccion de plantas', + type_id: tn.id, + image_url: 'arbol1.png') + +Site.create( + name: 'Reichstag', + description: 'Parlamento aleman en la ciudad de Berlin', + type_id: tm.id, + image_url: 'reichstag.png') + +Site.create( + name: 'Pergamo', + description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin', + type_id: tr.id, + image_url: 'pergamo.png') + +# user_id esta protegido con "attr_protected" y debe inicializarse asi, +# Site.create(....) levantaria una excepcipn al intentar inicializarlo +Site.all.each { |obj| obj.user_id = 1 ; obj.save } \ No newline at end of file diff --git a/doc/app/ApplicationController.html b/doc/app/ApplicationController.html new file mode 100644 index 0000000..09664a6 --- /dev/null +++ b/doc/app/ApplicationController.html @@ -0,0 +1,159 @@ + + + + + + +class ApplicationController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ + + + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/ApplicationHelper.html b/doc/app/ApplicationHelper.html new file mode 100644 index 0000000..dd55afb --- /dev/null +++ b/doc/app/ApplicationHelper.html @@ -0,0 +1,290 @@ + + + + + + +module ApplicationHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +

Helpers que estarán disponibles desde todas las vistas

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ add_gmap_marker(latitude,longitude,text) + click to toggle source +
+ + +
+ +

Añade un marcador en un mapa de google

+ +
IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map'
+ + + +
+
# File app/helpers/application_helper.rb, line 32
+def add_gmap_marker (latitude,longitude,text)
+        javascript = ""
+        if(!latitude.nil?)
+                javascript = "<script>                                                
+                        latlng = new google.maps.LatLng(#{latitude}, #{longitude});
+                        marker = new google.maps.Marker({
+                                position: latlng, 
+                                map: map, 
+                                title:'#{text}'
+                        });
+                      </script>"
+        end
+        raw(javascript)
+end
+
+ +
+ + + + +
+ + +
+ +
+ get_address(latitude,longitude) + click to toggle source +
+ + +
+ +

Nos permite obtener en formato string el nombre de la ciudad o región +pasándo como parámetro latitud y longitud

+ + + +
+
# File app/helpers/application_helper.rb, line 14
+def get_address(latitude,longitude)
+                        
+                if (!latitude.nil?)
+                        require 'open-uri'
+                        require 'json'
+                        result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read)
+                        localidad = "near "+result['results'][0]['address_components'][3]['long_name']
+                else
+                        localidad = ""
+                end
+                
+                localidad     
+end
+
+ +
+ + + + +
+ + +
+ +
+ include_javascript(file) + click to toggle source +
+ + +
+ +

Nos permite incluir un javascript.

+ +
Deprecated: Usar javascript_include_tag en su lugar
+ + + +
+
# File app/helpers/application_helper.rb, line 6
+def include_javascript (file)
+    s = " <script type=\"text/javascript\">" + render(:file => file) + "</script>"
+    content_for(:head, raw(s))
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/ComentsController.html b/doc/app/ComentsController.html new file mode 100644 index 0000000..16c91eb --- /dev/null +++ b/doc/app/ComentsController.html @@ -0,0 +1,465 @@ + + + + + + +class ComentsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ComentsController

+ +
+ +

ComentsController nos permite +controlar las acciones relacionadas con los comentarios

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /coments POST /coments.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 62
+def create 
+  @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user
+      
+      if !params[:site_id].nil?
+              @site = Site.find(params[:site_id])
+      else       
+              @site = Site.find(params[:coment][:site_id]) 
+      end
+      @coment = @site.coments.create(params[:coment]) 
+      
+        
+
+      respond_to do |format|
+               if @coment.save
+                      format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' }
+                      format.json { render json: site_path(@site), status: :created, location: @coment }
+           else
+                  format.html { render action: "new" }
+                      format.json { render json: @coment.errors, status: :unprocessable_entity }
+               end
+      end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /coments/1 DELETE /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 104
+def destroy
+  @coment = current_user.coments.find(params[:id])  # busca solo en sitios asociados a current_user
+#  @coment = Coment.find(params[:id])
+  @coment.destroy
+
+  respond_to do |format|
+    format.html { redirect_to coments_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /coments/1/edit

+ + + +
+
# File app/controllers/coments_controller.rb, line 56
+def edit
+  @coment = Coment.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /coments GET /coments.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 10
+def index
+  
+
+       if params[:site_id].nil?      #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión
+    @coments = Coment.all                                                     #si no, se pondría solo esta linea
+    else
+    @coments = Site.find(params[:site_id]).coments  
+  end
+      
+      
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @coments }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Nos permite crear un nuevo comentario GET /coments/new GET +/coments/new.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 41
+def new
+  @coment = Coment.new
+  #@site = Site.find(params[:site_id])
+  if !params[:site_id].nil?   
+      @site = Site.find(params[:site_id])            
+  end
+      
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @coment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Muestra un comentario especifico GET /coments/1 GET /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 29
+def show
+  @coment = Coment.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @coment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /coments/1 PUT /coments/1.json

+ + + +
+
# File app/controllers/coments_controller.rb, line 87
+def update
+  @coment = current_user.coments.find(params[:id])  # busca solo en sitios asociados a current_user
+ # @coment = Coment.find(params[:id])
+
+  respond_to do |format|
+    if @coment.update_attributes(params[:coment])
+      format.html { redirect_to @coment, notice: 'Coment was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @coment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/ComentsHelper.html b/doc/app/ComentsHelper.html new file mode 100644 index 0000000..47259ed --- /dev/null +++ b/doc/app/ComentsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module ComentsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ComentsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/PlanetController.html b/doc/app/PlanetController.html new file mode 100644 index 0000000..2f05dcc --- /dev/null +++ b/doc/app/PlanetController.html @@ -0,0 +1,397 @@ + + + + + + +class PlanetController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class PlanetController

+ +
+ +

PlanetController ilustra el uso de +RDoc. La documentación de un proyecto en genera en el +directorio proy/doc en formato Web con

+ +
$proy> rake doc:app
+ +

Algunos comandos de formateo

+ +

Tal y como muestra el subitulo anterior, este se define empezando la línea +con ==. En los títulos debe empezar por =.

+ +

Un [ … ] seguido de texto define una lista titulada, como aquí

+
Clases, Módulos o Métodos +
+

Se documentan con comentarios justo encima de sus definición, como aquí.

+
+ +

Un * o - definen las entradas de una lista itemizada

+ + +

Un número o letra seguido de punto genera una lista númerada

+
  1. +

    + permite generar negrita, igual que con +HTML

    +
  2. +

    _ permite generar cursiva, igual que con HTML

    +
    • +

      permite generar letra de teletipo, igual que con +HTML

      +
    +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ author() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 37
+def author
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 34
+def contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ ejemplo() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 40
+def ejemplo
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador

+ + + +
+
# File app/controllers/planet_controller.rb, line 31
+def index
+end
+
+ +
+ + + + +
+ + +
+ +
+ jsonp() + click to toggle source +
+ + +
+ +

Método para definir la acción que nos permite parsear json de la API de +googlemaps +No renderiza el layout+

+ + + +
+
# File app/controllers/planet_controller.rb, line 45
+ def jsonp
+      render :layout => false
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/doc/app/PlanetHelper.html b/doc/app/PlanetHelper.html new file mode 100644 index 0000000..fb564f2 --- /dev/null +++ b/doc/app/PlanetHelper.html @@ -0,0 +1,153 @@ + + + + + + +module PlanetHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module PlanetHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Site.html b/doc/app/Site.html new file mode 100644 index 0000000..3c8b96c --- /dev/null +++ b/doc/app/Site.html @@ -0,0 +1,157 @@ + + + + + + +class Site - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Site

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/SitesController.html b/doc/app/SitesController.html new file mode 100644 index 0000000..a1082db --- /dev/null +++ b/doc/app/SitesController.html @@ -0,0 +1,447 @@ + + + + + + +class SitesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class SitesController

+ +
+ +

SitesController nos permite controlar +las acciones relacionadas con los sitios

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /sites POST /sites.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 56
+def create
+   @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user
+
+  respond_to do |format|
+    if @site.save
+      format.html { redirect_to @site, notice: 'Site was successfully created.' }
+      format.json { render json: @site, status: :created, location: @site }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @site.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /sites/1 DELETE /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 88
+def destroy
+  @site = current_user.sites.find(params[:id])  # 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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /sites/1/edit

+ + + +
+
# File app/controllers/sites_controller.rb, line 50
+def edit
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /sites GET /sites.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 12
+def index
+  if params[:type_id].nil? or params[:type_id].empty?
+    @sites = Site.all            # path: /types
+    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 }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /sites/new GET /sites/new.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 40
+def new
+  @site = current_user.sites.build # crea sitio vacio asociado a current_user
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @site }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /sites/1 GET /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 26
+def show
+  @site = Site.find(params[:id])
+
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @site }
+        format.json { render json: @coments }
+
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /sites/1 PUT /sites/1.json

+ + + +
+
# File app/controllers/sites_controller.rb, line 72
+def update
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+
+  respond_to do |format|
+    if @site.update_attributes(params[:site])
+      format.html { redirect_to @site, notice: 'Site was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @site.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/SitesHelper.html b/doc/app/SitesHelper.html new file mode 100644 index 0000000..650a688 --- /dev/null +++ b/doc/app/SitesHelper.html @@ -0,0 +1,197 @@ + + + + + + +module SitesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module SitesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ new_gmap(latitude,longitude,zoom) + click to toggle source +
+ + +
+ + + + + +
+
# File app/helpers/sites_helper.rb, line 2
+def new_gmap(latitude,longitude,zoom)    
+
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Trip.html b/doc/app/Trip.html new file mode 100644 index 0000000..c2bdc6c --- /dev/null +++ b/doc/app/Trip.html @@ -0,0 +1,157 @@ + + + + + + +class Trip - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Trip

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TripsController.html b/doc/app/TripsController.html new file mode 100644 index 0000000..3b8a417 --- /dev/null +++ b/doc/app/TripsController.html @@ -0,0 +1,442 @@ + + + + + + +class TripsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TripsController

+ +
+ +

TripsController nos permite controlar +las acciones relacionadas con los viajes

+ +
¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /trips POST /trips.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 49
+def create
+  @trip = current_user.trips.build(params[:trip])
+
+  respond_to do |format|
+    if @trip.save
+      format.html { redirect_to @trip, notice: 'Trip was successfully created.' }
+      format.json { render json: @trip, status: :created, location: @trip }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @trip.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /trips/1 DELETE /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 81
+def destroy
+  @trip = current_user.trips.find(params[:id])
+  @trip.destroy
+
+  respond_to do |format|
+    format.html { redirect_to trips_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /trips/1/edit

+ + + +
+
# File app/controllers/trips_controller.rb, line 43
+def edit
+  @trip = current_user.trips.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /trips GET /trips.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 10
+def index
+  @trips = Trip.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @trips }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /trips/new GET /trips/new.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 33
+def new
+  @trip = current_user.trips.build
+  
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /trips/1 GET /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 21
+def show
+  @trip = Trip.find(params[:id])
+  @visit = @trip.visits.build
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /trips/1 PUT /trips/1.json

+ + + +
+
# File app/controllers/trips_controller.rb, line 65
+def update
+  @trip = current_user.trips.find(params[:id])
+  
+  respond_to do |format|
+    if @trip.update_attributes(params[:trip])
+      format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @trip.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TripsHelper.html b/doc/app/TripsHelper.html new file mode 100644 index 0000000..d5f992a --- /dev/null +++ b/doc/app/TripsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module TripsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TripsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Type.html b/doc/app/Type.html new file mode 100644 index 0000000..c9f3a24 --- /dev/null +++ b/doc/app/Type.html @@ -0,0 +1,157 @@ + + + + + + +class Type - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Type

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TypesController.html b/doc/app/TypesController.html new file mode 100644 index 0000000..d66042b --- /dev/null +++ b/doc/app/TypesController.html @@ -0,0 +1,475 @@ + + + + + + +class TypesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TypesController

+ +
+ +

Controlador de los tipos

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /types POST /types.json

+ + + +
+
# File app/controllers/types_controller.rb, line 60
+def create
+  @type = Type.new(params[:type])
+
+  respond_to do |format|
+    if @type.save
+      format.html { redirect_to @type, notice: 'Type was successfully created.' }
+      format.json { render json: @type, status: :created, location: @type }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /types/1 DELETE /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 92
+def destroy
+  @type = Type.find(params[:id])
+  @type.destroy
+
+  respond_to do |format|
+    format.html { redirect_to types_url }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /types/1/edit

+ + + +
+
# File app/controllers/types_controller.rb, line 54
+def edit
+  @type = Type.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /types GET /types.json

+ + + +
+
# File app/controllers/types_controller.rb, line 20
+def index
+  @types = Type.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /types/new GET /types/new.json

+ + + +
+
# File app/controllers/types_controller.rb, line 44
+def new
+  @type = Type.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ ordered_index() + click to toggle source +
+ + +
+ +

GET /types GET /types.json Devuelve una lista ordenada por nombre

+ + + +
+
# File app/controllers/types_controller.rb, line 7
+def ordered_index
+      @types = Type.find(:all, :order => :name) 
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /types/1 GET /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 33
+def show
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /types/1 PUT /types/1.json

+ + + +
+
# File app/controllers/types_controller.rb, line 76
+def update
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    if @type.update_attributes(params[:type])
+      format.html { redirect_to @type, notice: 'Type was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @type.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TypesHelper.html b/doc/app/TypesHelper.html new file mode 100644 index 0000000..1cf73d9 --- /dev/null +++ b/doc/app/TypesHelper.html @@ -0,0 +1,151 @@ + + + + + + +module TypesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TypesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/User.html b/doc/app/User.html new file mode 100644 index 0000000..afb0e72 --- /dev/null +++ b/doc/app/User.html @@ -0,0 +1,157 @@ + + + + + + +class User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Visit.html b/doc/app/Visit.html new file mode 100644 index 0000000..e3c36e9 --- /dev/null +++ b/doc/app/Visit.html @@ -0,0 +1,157 @@ + + + + + + +class Visit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Visit

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/VisitsController.html b/doc/app/VisitsController.html new file mode 100644 index 0000000..cc00fb9 --- /dev/null +++ b/doc/app/VisitsController.html @@ -0,0 +1,440 @@ + + + + + + +class VisitsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class VisitsController

+ +
+ +

VisitsController para las visitas

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

POST /visits POST /visits.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 46
+def create
+  @visit = Visit.new(params[:visit])
+
+  respond_to do |format|
+    if @visit.save
+      format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' }
+      format.js
+      format.json { render json: @visit, status: :created, location: @visit }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @visit.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

DELETE /visits/1 DELETE /visits/1.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 79
+def destroy
+  @visit = Visit.find(params[:id])
+  @visit.destroy
+
+  respond_to do |format|
+    format.html { redirect_to @visit.trip }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

GET /visits/1/edit

+ + + +
+
# File app/controllers/visits_controller.rb, line 40
+def edit
+  @visit = Visit.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

GET /visits GET /visits.json Nos devuelve todas las visitas

+ + + +
+
# File app/controllers/visits_controller.rb, line 6
+def index
+  @visits = Visit.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @visits }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

GET /visits/new GET /visits/new.json Para crear una nueva visita

+ + + +
+
# File app/controllers/visits_controller.rb, line 30
+def new
+  @visit = Visit.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

GET /visits/1 GET /visits/1.json Sólo aquella que coincide con el parámetro +id

+ + + +
+
# File app/controllers/visits_controller.rb, line 18
+def show
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

PUT /visits/1 PUT /visits/1.json

+ + + +
+
# File app/controllers/visits_controller.rb, line 63
+def update
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    if @visit.update_attributes(params[:visit])
+      format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @visit.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/VisitsHelper.html b/doc/app/VisitsHelper.html new file mode 100644 index 0000000..dfd73b9 --- /dev/null +++ b/doc/app/VisitsHelper.html @@ -0,0 +1,153 @@ + + + + + + +module VisitsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module VisitsHelper

+ +
+ +

No se usa

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/created.rid b/doc/app/created.rid new file mode 100644 index 0000000..1e8f65c --- /dev/null +++ b/doc/app/created.rid @@ -0,0 +1,22 @@ +Fri, 27 Apr 2012 00:28:16 +0200 +doc/README_FOR_APP Sun, 22 Apr 2012 18:24:18 +0200 +app/models/trip.rb Thu, 12 Apr 2012 12:33:34 +0200 +app/models/user.rb Sun, 15 Apr 2012 11:06:32 +0200 +app/models/coment.rb Thu, 19 Apr 2012 15:16:14 +0200 +app/models/visit.rb Thu, 12 Apr 2012 12:33:34 +0200 +app/models/type.rb Sun, 22 Apr 2012 18:24:18 +0200 +app/models/site.rb Sat, 14 Apr 2012 19:45:02 +0200 +app/controllers/application_controller.rb Fri, 27 Apr 2012 00:19:36 +0200 +app/controllers/visits_controller.rb Fri, 27 Apr 2012 00:23:17 +0200 +app/controllers/sites_controller.rb Fri, 27 Apr 2012 00:20:47 +0200 +app/controllers/coments_controller.rb Fri, 27 Apr 2012 00:21:05 +0200 +app/controllers/types_controller.rb Fri, 27 Apr 2012 00:22:16 +0200 +app/controllers/trips_controller.rb Fri, 27 Apr 2012 00:21:34 +0200 +app/controllers/planet_controller.rb Fri, 27 Apr 2012 00:13:18 +0200 +app/helpers/planet_helper.rb Fri, 27 Apr 2012 00:27:36 +0200 +app/helpers/application_helper.rb Fri, 27 Apr 2012 00:25:52 +0200 +app/helpers/sites_helper.rb Thu, 26 Apr 2012 01:54:18 +0200 +app/helpers/visits_helper.rb Fri, 27 Apr 2012 00:27:45 +0200 +app/helpers/trips_helper.rb Fri, 27 Apr 2012 00:27:40 +0200 +app/helpers/types_helper.rb Sun, 22 Apr 2012 18:24:18 +0200 +app/helpers/coments_helper.rb Fri, 27 Apr 2012 00:27:30 +0200 diff --git a/doc/app/doc/README_FOR_APP.html b/doc/app/doc/README_FOR_APP.html new file mode 100644 index 0000000..c8b0478 --- /dev/null +++ b/doc/app/doc/README_FOR_APP.html @@ -0,0 +1,117 @@ + + + + + + +README_FOR_APP - Rails Application Documentation + + + + + + + + + + + + + + + + +
+ +

Use this README file to introduce your application and point to useful +places in the API for learning more. Run “rake doc:app” to generate API +documentation for your models, controllers, helpers, and libraries.

+ +
+ + + + + diff --git a/doc/app/images/add.png b/doc/app/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/doc/app/images/add.png differ diff --git a/doc/app/images/brick.png b/doc/app/images/brick.png new file mode 100644 index 0000000..7851cf3 Binary files /dev/null and b/doc/app/images/brick.png differ diff --git a/doc/app/images/brick_link.png b/doc/app/images/brick_link.png new file mode 100644 index 0000000..9ebf013 Binary files /dev/null and b/doc/app/images/brick_link.png differ diff --git a/doc/app/images/bug.png b/doc/app/images/bug.png new file mode 100644 index 0000000..2d5fb90 Binary files /dev/null and b/doc/app/images/bug.png differ diff --git a/doc/app/images/bullet_black.png b/doc/app/images/bullet_black.png new file mode 100644 index 0000000..5761970 Binary files /dev/null and b/doc/app/images/bullet_black.png differ diff --git a/doc/app/images/bullet_toggle_minus.png b/doc/app/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 Binary files /dev/null and b/doc/app/images/bullet_toggle_minus.png differ diff --git a/doc/app/images/bullet_toggle_plus.png b/doc/app/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 Binary files /dev/null and b/doc/app/images/bullet_toggle_plus.png differ diff --git a/doc/app/images/date.png b/doc/app/images/date.png new file mode 100644 index 0000000..783c833 Binary files /dev/null and b/doc/app/images/date.png differ diff --git a/doc/app/images/delete.png b/doc/app/images/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/doc/app/images/delete.png differ diff --git a/doc/app/images/find.png b/doc/app/images/find.png new file mode 100644 index 0000000..1547479 Binary files /dev/null and b/doc/app/images/find.png differ diff --git a/doc/app/images/loadingAnimation.gif b/doc/app/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 Binary files /dev/null and b/doc/app/images/loadingAnimation.gif differ diff --git a/doc/app/images/macFFBgHack.png b/doc/app/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 Binary files /dev/null and b/doc/app/images/macFFBgHack.png differ diff --git a/doc/app/images/package.png b/doc/app/images/package.png new file mode 100644 index 0000000..da3c2a2 Binary files /dev/null and b/doc/app/images/package.png differ diff --git a/doc/app/images/page_green.png b/doc/app/images/page_green.png new file mode 100644 index 0000000..de8e003 Binary files /dev/null and b/doc/app/images/page_green.png differ diff --git a/doc/app/images/page_white_text.png b/doc/app/images/page_white_text.png new file mode 100644 index 0000000..813f712 Binary files /dev/null and b/doc/app/images/page_white_text.png differ diff --git a/doc/app/images/page_white_width.png b/doc/app/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 Binary files /dev/null and b/doc/app/images/page_white_width.png differ diff --git a/doc/app/images/plugin.png b/doc/app/images/plugin.png new file mode 100644 index 0000000..6187b15 Binary files /dev/null and b/doc/app/images/plugin.png differ diff --git a/doc/app/images/ruby.png b/doc/app/images/ruby.png new file mode 100644 index 0000000..f763a16 Binary files /dev/null and b/doc/app/images/ruby.png differ diff --git a/doc/app/images/tag_blue.png b/doc/app/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f Binary files /dev/null and b/doc/app/images/tag_blue.png differ diff --git a/doc/app/images/tag_green.png b/doc/app/images/tag_green.png new file mode 100644 index 0000000..83ec984 Binary files /dev/null and b/doc/app/images/tag_green.png differ diff --git a/doc/app/images/transparent.png b/doc/app/images/transparent.png new file mode 100644 index 0000000..d665e17 Binary files /dev/null and b/doc/app/images/transparent.png differ diff --git a/doc/app/images/wrench.png b/doc/app/images/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/doc/app/images/wrench.png differ diff --git a/doc/app/images/wrench_orange.png b/doc/app/images/wrench_orange.png new file mode 100644 index 0000000..565a933 Binary files /dev/null and b/doc/app/images/wrench_orange.png differ diff --git a/doc/app/images/zoom.png b/doc/app/images/zoom.png new file mode 100644 index 0000000..908612e Binary files /dev/null and b/doc/app/images/zoom.png differ diff --git a/doc/app/index.html b/doc/app/index.html new file mode 100644 index 0000000..1a3c1c3 --- /dev/null +++ b/doc/app/index.html @@ -0,0 +1,110 @@ + + + + + + +Rails Application Documentation + + + + + + + + + + + + + + + + +

This is the API documentation for Rails Application Documentation. + + +

+ diff --git a/doc/app/js/darkfish.js b/doc/app/js/darkfish.js new file mode 100644 index 0000000..4be722f --- /dev/null +++ b/doc/app/js/darkfish.js @@ -0,0 +1,153 @@ +/** + * + * Darkfish Page Functions + * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $ + * + * Author: Michael Granger + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

Table of Contents - Rails Application Documentation

+ +

Pages

+ + +

Classes/Modules

+ + +

Methods

+ + + + + diff --git a/public/system/images/10/original/reichstag.png b/public/system/images/10/original/reichstag.png new file mode 100644 index 0000000..8b95380 Binary files /dev/null and b/public/system/images/10/original/reichstag.png differ diff --git a/public/system/images/11/original/pergamo.png b/public/system/images/11/original/pergamo.png new file mode 100644 index 0000000..7e462c2 Binary files /dev/null and b/public/system/images/11/original/pergamo.png differ diff --git a/public/system/images/12/original/ETSIT2.gif b/public/system/images/12/original/ETSIT2.gif new file mode 100644 index 0000000..a0c7809 Binary files /dev/null and b/public/system/images/12/original/ETSIT2.gif differ diff --git a/public/system/images/13/original/eiffel.jpg b/public/system/images/13/original/eiffel.jpg new file mode 100644 index 0000000..9df1b87 Binary files /dev/null and b/public/system/images/13/original/eiffel.jpg differ diff --git a/public/system/images/7/original/pedriza.png b/public/system/images/7/original/pedriza.png new file mode 100644 index 0000000..8d300fb Binary files /dev/null and b/public/system/images/7/original/pedriza.png differ diff --git a/public/system/images/8/original/florencia.png b/public/system/images/8/original/florencia.png new file mode 100644 index 0000000..6398a2e Binary files /dev/null and b/public/system/images/8/original/florencia.png differ diff --git a/public/system/images/9/original/arbol1.png b/public/system/images/9/original/arbol1.png new file mode 100644 index 0000000..6affc09 Binary files /dev/null and b/public/system/images/9/original/arbol1.png differ diff --git a/test/fixtures/coments.yml b/test/fixtures/coments.yml new file mode 100644 index 0000000..d10e661 --- /dev/null +++ b/test/fixtures/coments.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + coment: MyString + user: one + site: one + +two: + coment: MyString + user: two + site: two diff --git a/test/fixtures/coments.yml~ b/test/fixtures/coments.yml~ new file mode 100644 index 0000000..e7e2ac9 --- /dev/null +++ b/test/fixtures/coments.yml~ @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + coment: MyString + user_id: 1 + site_id: 1 + +two: + coment: MyString + user_id: 1 + site_id: 1 diff --git a/test/fixtures/sites.yml b/test/fixtures/sites.yml new file mode 100644 index 0000000..5cc96ba --- /dev/null +++ b/test/fixtures/sites.yml @@ -0,0 +1,21 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + type: one + image_url: MyString + user: one + latitude: 1 + longitude: 1 + zoom: 5 + +two: + name: YourString + description: YourText + type: two + image_url: YourString + user: two + latitude: 1 + longitude: 1 + zoom: 5 diff --git a/test/fixtures/sites.yml~ b/test/fixtures/sites.yml~ new file mode 100644 index 0000000..92ffa0c --- /dev/null +++ b/test/fixtures/sites.yml~ @@ -0,0 +1,21 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + type: one + image_url: MyString + user: one + latitud: 1 + longitud: 1 + zoom: 5 + +two: + name: YourString + description: YourText + type: two + image_url: YourString + user: two + latitud: 1 + longitud: 1 + zoom: 5 diff --git a/test/fixtures/trips.yml b/test/fixtures/trips.yml new file mode 100644 index 0000000..2b0ecb6 --- /dev/null +++ b/test/fixtures/trips.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + date: 2012-04-09 + user: one + +two: + name: YourString + description: YourText + date: 2012-04-09 + user: two \ No newline at end of file diff --git a/test/fixtures/types.yml b/test/fixtures/types.yml index 53b2c6a..79e980b 100644 --- a/test/fixtures/types.yml +++ b/test/fixtures/types.yml @@ -1,5 +1,3 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - one: name: MyString description: MyText @@ -7,3 +5,6 @@ one: two: name: MyString description: MyText + + +# Podriamos aadir nuevos datos de inicializacin, que se referencian como diff --git a/test/fixtures/types.yml~ b/test/fixtures/types.yml~ new file mode 100644 index 0000000..c6a300d --- /dev/null +++ b/test/fixtures/types.yml~ @@ -0,0 +1,12 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + +two: + name: MyString + description: MyText + + +# Podriamos aadir nuevos datos de inicializacin, que se referencian como \ No newline at end of file diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..9625621 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: + name: Jose Perez + email: jose.perez@gmail.com + encrypted_password: perez22222 +# column: value +# +two: + name: Jose Perez + email: jose.perez@me.com + encrypted_password: perez33333 +# column: value diff --git a/test/fixtures/users.yml~ b/test/fixtures/users.yml~ new file mode 100644 index 0000000..2e8c5e4 --- /dev/null +++ b/test/fixtures/users.yml~ @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: + name: Jose Perez + email: jose.perez@gmail.com + encrypted_password: perez22222 +# column: value +# +two: + name: Jose Perez + email: jose.perez@me.com + encrypted_password: perez33333 +# column: value diff --git a/test/fixtures/visits.yml b/test/fixtures/visits.yml new file mode 100644 index 0000000..f539c19 --- /dev/null +++ b/test/fixtures/visits.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + trip: one + site: one + hour: 9 + +two: + trip: two + site: two + hour: 9 \ No newline at end of file diff --git a/test/functional/coments_controller_test.rb b/test/functional/coments_controller_test.rb new file mode 100644 index 0000000..04c824b --- /dev/null +++ b/test/functional/coments_controller_test.rb @@ -0,0 +1,51 @@ +require 'test_helper' + +class ComentsControllerTest < ActionController::TestCase + setup do + @coment = coments(:one) + @user = @coment.user + sign_in @user + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:coments) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create coment" do + assert_difference('Coment.count') do + post :create, coment: @coment.attributes + end + + assert_redirected_to site_path(assigns(:site)) + end + + test "should show coment" do + get :show, id: @coment + assert_response :success + end + + test "should get edit" do + get :edit, id: @coment + assert_response :success + end + + test "should update coment" do + put :update, id: @coment, coment: @coment.attributes + assert_redirected_to coment_path(assigns(:coment)) + end + + test "should destroy coment" do + assert_difference('Coment.count', -1) do + delete :destroy, id: @coment + end + + assert_redirected_to coments_path + end +end diff --git a/test/functional/coments_controller_test.rb~ b/test/functional/coments_controller_test.rb~ new file mode 100644 index 0000000..16bf372 --- /dev/null +++ b/test/functional/coments_controller_test.rb~ @@ -0,0 +1,51 @@ +require 'test_helper' + +class ComentsControllerTest < ActionController::TestCase + setup do + @coment = coments(:one) + @user = @coment.user + sign_in @user + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:coments) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create coment" do + assert_difference('Coment.count') do + post :create, coment: @coment.attributes + end + + assert_redirected_to site_path(assigns(:coment)) + end + + test "should show coment" do + get :show, id: @coment + assert_response :success + end + + test "should get edit" do + get :edit, id: @coment + assert_response :success + end + + test "should update coment" do + put :update, id: @coment, coment: @coment.attributes + assert_redirected_to coment_path(assigns(:coment)) + end + + test "should destroy coment" do + assert_difference('Coment.count', -1) do + delete :destroy, id: @coment + end + + assert_redirected_to coments_path + end +end diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb index 88229e0..1f1b4fd 100644 --- a/test/functional/planet_controller_test.rb +++ b/test/functional/planet_controller_test.rb @@ -1,14 +1,28 @@ -require 'test_helper' - -class PlanetControllerTest < ActionController::TestCase - test "should get index" do - get :index - assert_response :success - end - - test "should get contact" do - get :contact - assert_response :success - end - -end +require 'test_helper' + +class PlanetControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get contact" do + get :contact + assert_response :success + end + + test "should get ejemplo" do + get :ejemplo + assert_response :success + end + + test "should get author" do + get :author + assert_response :success + end + + test "should get search found" do + get :search, :search => "hola".to_param + assert_response :success + end +end diff --git a/test/functional/sites_controller_test.rb b/test/functional/sites_controller_test.rb new file mode 100644 index 0000000..c8f4720 --- /dev/null +++ b/test/functional/sites_controller_test.rb @@ -0,0 +1,56 @@ +require 'test_helper' + +class SitesControllerTest < ActionController::TestCase + setup do + @site = sites(:one) + @update = { # @update: parametros diferentes + :name => 'AnotherType', + :description => 'AnotherText', + :type_id => types(:one).id + } + @user = @site.user + sign_in @user + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:sites) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create site" do + assert_difference('Site.count') do + post :create, site: @update + end + + assert_redirected_to site_path(assigns(:site)) + end + + test "should show site" do + get :show, id: @site + assert_response :success + end + + test "should get edit" do + get :edit, id: @site + assert_response :success + end + + test "should update site" do + put :update, id: @site, site: @update + assert_redirected_to site_path(assigns(:site)) + end + + test "should destroy site" do + assert_difference('Site.count', -1) do + delete :destroy, id: @site + end + + assert_redirected_to sites_path + end +end diff --git a/test/functional/trips_controller_test.rb b/test/functional/trips_controller_test.rb new file mode 100644 index 0000000..da22239 --- /dev/null +++ b/test/functional/trips_controller_test.rb @@ -0,0 +1,56 @@ +require 'test_helper' + +class TripsControllerTest < ActionController::TestCase + setup do + @trip = trips(:one) + @update = { # @update: parametros diferentes + :name => 'AnotherType', + :description => 'AnotherText', + :date => '2012-04-09' + } + @user = @trip.user + sign_in @user + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:trips) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create trip" do + assert_difference('Trip.count') do + post :create, trip: @update + end + + assert_redirected_to trip_path(assigns(:trip)) + end + + test "should show trip" do + get :show, id: @trip + assert_response :success + end + + test "should get edit" do + get :edit, id: @trip + assert_response :success + end + + test "should update trip" do + put :update, id: @trip, trip: @update + assert_redirected_to trip_path(assigns(:trip)) + end + + test "should destroy trip" do + assert_difference('Trip.count', -1) do + delete :destroy, id: @trip + end + + assert_redirected_to trips_path + end +end diff --git a/test/functional/types_controller_test.rb b/test/functional/types_controller_test.rb index 2e1931b..1da4990 100644 --- a/test/functional/types_controller_test.rb +++ b/test/functional/types_controller_test.rb @@ -3,6 +3,12 @@ class TypesControllerTest < ActionController::TestCase setup do @type = types(:one) + @update = { # @update: parametros diferentes + :name => 'AnotherType', + :description => 'AnotherText', + } + @user = users(:one) + sign_in @user end test "should get index" do @@ -18,7 +24,7 @@ class TypesControllerTest < ActionController::TestCase test "should create type" do assert_difference('Type.count') do - post :create, type: @type.attributes + post :create, type: @update end assert_redirected_to type_path(assigns(:type)) @@ -35,7 +41,7 @@ class TypesControllerTest < ActionController::TestCase end test "should update type" do - put :update, id: @type, type: @type.attributes + put :update, id: @type, type: @update assert_redirected_to type_path(assigns(:type)) end diff --git a/test/functional/visits_controller_test.rb b/test/functional/visits_controller_test.rb new file mode 100644 index 0000000..f988f15 --- /dev/null +++ b/test/functional/visits_controller_test.rb @@ -0,0 +1,50 @@ +require 'test_helper' + +class VisitsControllerTest < ActionController::TestCase + setup do + @visit = visits(:one) + @trip = @visit.trip + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:visits) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create visit" do + assert_difference('Visit.count') do + post :create, visit: @visit.attributes + end + + assert_redirected_to @trip + end + + test "should show visit" do + get :show, id: @visit + assert_response :success + end + + test "should get edit" do + get :edit, id: @visit + assert_response :success + end + + test "should update visit" do + put :update, id: @visit, visit: @visit.attributes + assert_redirected_to @trip + end + + test "should destroy visit" do + assert_difference('Visit.count', -1) do + delete :destroy, id: @visit + end + + assert_redirected_to @trip + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192..2d5a817 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,3 +11,7 @@ class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... end + +ActionController::TestCase.class_eval do + include Devise::TestHelpers +end \ No newline at end of file diff --git a/test/unit/coment_test.rb b/test/unit/coment_test.rb new file mode 100644 index 0000000..da19270 --- /dev/null +++ b/test/unit/coment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ComentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/coments_helper_test.rb b/test/unit/helpers/coments_helper_test.rb new file mode 100644 index 0000000..d2cf3c0 --- /dev/null +++ b/test/unit/helpers/coments_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class ComentsHelperTest < ActionView::TestCase +end diff --git a/test/unit/helpers/sites_helper_test.rb b/test/unit/helpers/sites_helper_test.rb new file mode 100644 index 0000000..0e92edf --- /dev/null +++ b/test/unit/helpers/sites_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SitesHelperTest < ActionView::TestCase +end diff --git a/test/unit/helpers/trips_helper_test.rb b/test/unit/helpers/trips_helper_test.rb new file mode 100644 index 0000000..dcfddff --- /dev/null +++ b/test/unit/helpers/trips_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class TripsHelperTest < ActionView::TestCase +end diff --git a/test/unit/helpers/visits_helper_test.rb b/test/unit/helpers/visits_helper_test.rb new file mode 100644 index 0000000..6f1596c --- /dev/null +++ b/test/unit/helpers/visits_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class VisitsHelperTest < ActionView::TestCase +end diff --git a/test/unit/site_test.rb b/test/unit/site_test.rb new file mode 100644 index 0000000..2826c6a --- /dev/null +++ b/test/unit/site_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' + +class SiteTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end + + # site creado sin atributos es invalido y genera errores + test "Site attributes must not be empty" do + site = Site.new + assert site.invalid? # Test pasa si validacin no pasa + assert site.errors[:name].any? + assert not(site.errors[:description].any?) + assert site.errors[:type_id].any? + # assert site.errors[:image_url].any? not used with paperclip + end +end \ No newline at end of file diff --git a/test/unit/trip_test.rb b/test/unit/trip_test.rb new file mode 100644 index 0000000..1ed8ca6 --- /dev/null +++ b/test/unit/trip_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class TripTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/type_test.rb b/test/unit/type_test.rb index 0ce1172..f777ffb 100644 --- a/test/unit/type_test.rb +++ b/test/unit/type_test.rb @@ -4,4 +4,12 @@ class TypeTest < ActiveSupport::TestCase # test "the truth" do # assert true # end -end + + # type creado sin atributos es invalido y genera errores + test "Type attributes must not be empty" do + type = Type.new + assert type.invalid? # Test pasa si validacin no pasa + assert type.errors[:name].any? + assert type.errors[:description].any? + end +end \ No newline at end of file diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb new file mode 100644 index 0000000..82f61e0 --- /dev/null +++ b/test/unit/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/visit_test.rb b/test/unit/visit_test.rb new file mode 100644 index 0000000..a34aa33 --- /dev/null +++ b/test/unit/visit_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class VisitTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end