File tree 11 files changed +153
-0
lines changed
11 files changed +153
-0
lines changed Original file line number Diff line number Diff line change
1
+ source 'https://rubygems.org'
2
+ ruby '2.2.4'
3
+
4
+ gem 'sinatra'
5
+ gem 'sequel'
6
+ gem 'pg'
Original file line number Diff line number Diff line change
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ pg (0.18.4 )
5
+ rack (1.6.4 )
6
+ rack-protection (1.5.3 )
7
+ rack
8
+ sequel (4.31.0 )
9
+ sinatra (1.4.6 )
10
+ rack (~> 1.4 )
11
+ rack-protection (~> 1.4 )
12
+ tilt (>= 1.3 , < 3 )
13
+ tilt (2.0.1 )
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ pg
20
+ sequel
21
+ sinatra
22
+
23
+ BUNDLED WITH
24
+ 1.11.2
Original file line number Diff line number Diff line change
1
+ web : bundle exec ruby ogp.rb -p $PORT
Original file line number Diff line number Diff line change
1
+ require 'sequel'
2
+
3
+ namespace :db do
4
+ desc "Create database"
5
+ task :create do
6
+ puts 'Creating database'
7
+ DB = Sequel . connect ( ENV [ 'DATABASE_URL' ] || 'postgres://localhost:5432/ogp' )
8
+
9
+ puts 'Creating surveys table'
10
+ DB . create_table :surveys do
11
+ primary_key :id
12
+ String :name
13
+ String :organization
14
+ String :sector
15
+ String :country
16
+ String :comments
17
+ end
18
+ end
19
+ end
20
+
21
+ task :console do
22
+ require 'irb'
23
+ require 'irb/completion'
24
+ require_relative 'ogp.rb'
25
+ ARGV . clear
26
+ IRB . start
27
+ end
Original file line number Diff line number Diff line change
1
+ require './ogp'
2
+ run Sinatra ::Application
Original file line number Diff line number Diff line change
1
+ # encoding: utf-8
2
+ require 'sequel'
3
+ DB = Sequel . connect ( ENV [ 'DATABASE_URL' ] || 'postgres://localhost:5432/ogp' )
4
+ DB << "SET CLIENT_ENCODING TO 'UTF8';"
5
+
6
+ require_relative 'survey.rb'
Original file line number Diff line number Diff line change
1
+ class Survey < Sequel ::Model
2
+ plugin :csv_serializer
3
+ end
Original file line number Diff line number Diff line change
1
+ # coding: utf-8
2
+ require 'sinatra'
3
+ require 'sequel'
4
+ require 'csv'
5
+ require_relative 'models/init.rb'
6
+
7
+ get '/' do
8
+ erb :index
9
+ end
10
+
11
+ post '/enviar' do
12
+ Survey . create (
13
+ name : params [ :name ] ,
14
+ organization : params [ :organization ] ,
15
+ sector : params [ :sector ] ,
16
+ country : params [ :country ] ,
17
+ comments : params [ :comments ]
18
+ )
19
+ erb :thanks
20
+ end
21
+
22
+ get '/resultados' do
23
+ Sequel ::Plugins ::CsvSerializer . configure (
24
+ Survey ,
25
+ col_sep : ';' ,
26
+ encoding : 'UTF-8'
27
+ )
28
+ content_type 'application/csv'
29
+ attachment 'resultados_ogp.csv'
30
+ csv = "Nombre;Organización;Sector;País;Comentarios\n "
31
+ Survey . each do |survey |
32
+ csv << survey . to_csv ( except : :id )
33
+ end
34
+ csv
35
+ end
Original file line number Diff line number Diff line change
1
+ < h1 > ENCUENTRO REGIONAL DE LAS AMÉRICAS DE LA ALIANZA PARA EL GOBIERNO ABIERTO</ h1 >
2
+ < h2 > 31.05 al 02.06 DE 2016 MONTEVIDEO URUGUAY</ h2 >
3
+
4
+ < form action ="/enviar " method ="post ">
5
+ < p >
6
+ < label for ="nombre "> Nombre</ label >
7
+ < input type ='text ' name ="name " id ="name ">
8
+ </ p >
9
+ < p >
10
+ < label for ="organizacion "> Organización</ label >
11
+ < input type ='text ' name ="organization " id ="organization ">
12
+ </ p >
13
+ < p >
14
+ < label for ="sector "> Sector</ label >
15
+ < input type ='text ' name ="sector " id ="sector ">
16
+ </ p >
17
+ < p >
18
+ < label for ="pais "> País</ label >
19
+ < input type ='text ' name ="country " id ="country ">
20
+ </ p >
21
+ < p >
22
+ < label for ="comments "> Comentarios</ label >
23
+ < textarea name ="comments " id ="comments "> </ textarea >
24
+ </ p >
25
+ < p >
26
+ Temas de mi interés:
27
+ < ul >
28
+ < li >
29
+ < label >
30
+ < input type ="checkbox " id ="innovacion_sector_publico " value ="innovacion_sector_publico ">
31
+ Innovación en el sector público
32
+ </ label >
33
+ </ li >
34
+ < li >
35
+ < label >
36
+ < input type ="checkbox " id ="plata_emprendedor " value ="plata_emprendedor ">
37
+ Hacer plata con mi startup porque soy un emprendedor
38
+ </ label >
39
+ </ li >
40
+ < li >
41
+ < label >
42
+ < input type ="checkbox " id ="facilitador " value ="facilitador ">
43
+ Deseo ser facilitador
44
+ </ label >
45
+ </ li >
46
+ </ ul >
47
+ < button type ="submit "> Enviar</ button >
48
+ </ form >
Original file line number Diff line number Diff line change
1
+ Gracias por coso.
You can’t perform that action at this time.
0 commit comments