pah 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.gitignore +17 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +55 -0
  6. data/Rakefile +1 -0
  7. data/bin/pah +4 -0
  8. data/lib/pah/README.md +53 -0
  9. data/lib/pah/build +17 -0
  10. data/lib/pah/files/.gitignore +17 -0
  11. data/lib/pah/files/.rvmrc +48 -0
  12. data/lib/pah/files/Gemfile +52 -0
  13. data/lib/pah/files/Procfile +1 -0
  14. data/lib/pah/files/app/assets/stylesheets/reset.css +40 -0
  15. data/lib/pah/files/app/controllers/admin/contents_controller.rb +2 -0
  16. data/lib/pah/files/app/helpers/typus_helper.rb +32 -0
  17. data/lib/pah/files/app/models/content.rb +27 -0
  18. data/lib/pah/files/app/views/admin/dashboard/_sidebar.html.erb +0 -0
  19. data/lib/pah/files/app/views/layouts/application.html.haml +68 -0
  20. data/lib/pah/files/config/database.yml +22 -0
  21. data/lib/pah/files/config/initializers/omniauth.rb +4 -0
  22. data/lib/pah/files/config/initializers/requires.rb +1 -0
  23. data/lib/pah/files/config/locales/pt-BR.app.yml +16 -0
  24. data/lib/pah/files/config/locales/pt-BR.content.yml +12 -0
  25. data/lib/pah/files/config/locales/pt-BR.typus.yml +15 -0
  26. data/lib/pah/files/config/locales/pt-BR.yml +207 -0
  27. data/lib/pah/files/config/typus/content.yml +8 -0
  28. data/lib/pah/files/config/typus/content_roles.yml +4 -0
  29. data/lib/pah/files/config/unicorn.rb +27 -0
  30. data/lib/pah/files/db/migrate/20120605205337_create_contents.rb +11 -0
  31. data/lib/pah/files/db/seeds.rb +10 -0
  32. data/lib/pah/files/lib/tasks/integration.rake +14 -0
  33. data/lib/pah/files/public/index.html +1 -0
  34. data/lib/pah/files/spec/acceptance/dummy_spec.rb +9 -0
  35. data/lib/pah/files/spec/controllers/admin/contents_controller_spec.rb +5 -0
  36. data/lib/pah/files/spec/factories/content.rb +8 -0
  37. data/lib/pah/files/spec/helpers/typus_helper_spec.rb +71 -0
  38. data/lib/pah/files/spec/models/content_spec.rb +64 -0
  39. data/lib/pah/files/spec/spec_helper.rb +47 -0
  40. data/lib/pah/files/spec/support/README +1 -0
  41. data/lib/pah/files/spec/support/acceptance_helpers.rb +26 -0
  42. data/lib/pah/files/spec/support/acceptance_macros.rb +16 -0
  43. data/lib/pah/files/spec/support/capybara.rb +8 -0
  44. data/lib/pah/files/spec/support/deferred_garbage_collection.rb +35 -0
  45. data/lib/pah/files/spec/support/http_basic_auth.rb +26 -0
  46. data/lib/pah/files/spec/support/matchers.rb +5 -0
  47. data/lib/pah/files/spec/support/omniauth.rb +27 -0
  48. data/lib/pah/files/spec/support/paperclip.rb +4 -0
  49. data/lib/pah/files/spec/support/shared_connection.rb +12 -0
  50. data/lib/pah/files/spec/support/suppress_log.rb +5 -0
  51. data/lib/pah/files/spec/support/uploaded_file.rb +19 -0
  52. data/lib/pah/files/spec/support/vcr.rb +7 -0
  53. data/lib/pah/partials/_canonical_host.rb +14 -0
  54. data/lib/pah/partials/_capybara.rb +11 -0
  55. data/lib/pah/partials/_cleanup.rb +20 -0
  56. data/lib/pah/partials/_database.rb +6 -0
  57. data/lib/pah/partials/_default.rb +26 -0
  58. data/lib/pah/partials/_finish.rb +8 -0
  59. data/lib/pah/partials/_gems.rb +7 -0
  60. data/lib/pah/partials/_generators.rb +37 -0
  61. data/lib/pah/partials/_git.rb +7 -0
  62. data/lib/pah/partials/_heroku.rb +51 -0
  63. data/lib/pah/partials/_omniauth.rb +13 -0
  64. data/lib/pah/partials/_rspec.rb +13 -0
  65. data/lib/pah/partials/_rvm.rb +43 -0
  66. data/lib/pah/partials/_secure_headers.rb +12 -0
  67. data/lib/pah/setup.rb +17 -0
  68. data/lib/pah/template.rb +91 -0
  69. data/lib/pah/version.rb +3 -0
  70. data/pah.gemspec +27 -0
  71. metadata +205 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@pah --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pah.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mauro George
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Pah
2
+
3
+ A rails application template which born from [Startup DEV][startupdev] and now is used to start most projects at [HE:labs][helabs].
4
+
5
+ ## Instalation
6
+
7
+ Only install the Pah gem:
8
+
9
+ gem install pah
10
+
11
+ ## Usage
12
+
13
+ Run:
14
+
15
+ pah projectname
16
+
17
+ This will create a Rails 3.2 app in `projectname`. This script creates a new git repository. It is not meant to be used against an existing repo.
18
+
19
+ Be sure to set your canonical domain on Heroku:
20
+ ```shell
21
+ heroku config:add CANONICAL_HOST=yourdomain.com #or www.yourdomain.com
22
+ ```
23
+
24
+ ## Dependencies
25
+
26
+ ### heroku toolbelt
27
+
28
+ So Install this from https://toolbelt.heroku.com/
29
+
30
+ ### phantomjs
31
+
32
+ On OSX install with:
33
+
34
+ ```shell
35
+ brew install phantomjs
36
+ ```
37
+
38
+ ## Versioning
39
+
40
+ Pah follow the [Semantic Versioning](http://semver.org/).
41
+
42
+ ## Issues
43
+
44
+ If you have problems, please create a [Github Issue](https://github.com/Helabs/rails-template/issues).
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
53
+
54
+ [startupdev]: http://startupdev.com.br
55
+ [helabs]: http://helabs.com.br
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/pah ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ template_rb = File.expand_path(File.join('..', 'lib', 'pah', 'template.rb'), File.dirname(__FILE__))
4
+ exec "rails new #{ARGV[0]} -m #{template_rb}"
data/lib/pah/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Rails Template
2
+
3
+ A rails application template which born from [Startup DEV][startupdev] and now is used to start most projects at [HE:labs][helabs].
4
+
5
+ ## Usage
6
+
7
+ 1. Install heroku toolbelt.
8
+ ```shell
9
+ https://toolbelt.heroku.com/
10
+ ```
11
+
12
+ 2. Install phantomjs.
13
+ ```shell
14
+ brew install phantomjs
15
+ ```
16
+
17
+ 3. Clone rails-template to your home directory.
18
+ ```shell
19
+ git clone git://github.com/Helabs/rails-template.git
20
+ ```
21
+
22
+ 4. Run rails new app command using this template.
23
+ ```shell
24
+ rails new app_name -m ~/rails-template/template.rb
25
+ ```
26
+
27
+ 5. Be sure to set your canonical domain on Heroku:
28
+ ```shell
29
+ heroku config:add CANONICAL_HOST=yourdomain.com #or www.yourdomain.com
30
+ ```
31
+
32
+ 6. That's it! Everything should be in place.
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
41
+
42
+ ## Development cycle
43
+
44
+ 1. Make modifications
45
+ 2. Run build
46
+ ```
47
+ ./build
48
+ ```
49
+ 4. It should open your browser on heroku app with message "Profit!"
50
+ 5. Profit!
51
+
52
+ [startupdev]: http://startupdev.com.br
53
+ [helabs]: http://helabs.com.br
data/lib/pah/build ADDED
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ rvm gemset use rails-template --create
4
+ bundle
5
+ rm -Rf ../rails_template_test123
6
+ cd ..
7
+ rvm gemset use rails-template
8
+ RAILS_TEMPLATE_TEST=true rails new rails_template_test123 -m rails-template/template.rb
9
+ read -p "Check the build. Do you want to delete temporary files and Heroku app? [Yn]" -n 1 -r
10
+ if [[ ! $REPLY =~ ^[Nn]$ ]]
11
+ then
12
+ heroku destroy railstemplatetest123 --confirm railstemplatetest123
13
+ heroku destroy railstemplatetest123-staging --confirm railstemplatetest123-staging
14
+ rm -Rf ../rails_template_test123
15
+ # Do not delete gemset to speed up compilation
16
+ # run << "rvm gemset delete test_app --force"
17
+ fi
@@ -0,0 +1,17 @@
1
+ .DS_store
2
+ *.rbc
3
+ *.sassc
4
+ .sass-cache
5
+ capybara-*.html
6
+ .rspec
7
+ /.bundle
8
+ /vendor/bundle
9
+ /log/*
10
+ /tmp/*
11
+ /db/*.sqlite3
12
+ /public/system/*
13
+ /coverage/
14
+ /spec/tmp/*
15
+ **.orig
16
+ rerun.txt
17
+ pickle-email-*.html
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.2" > .rvmrc
9
+ environment_id="RUBYVERSION@PROJECT"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ rvmrc_rvm_version="1.14.3 ()" # 1.10.1 seams as a safe start
13
+ eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ return 1
16
+ }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,52 @@
1
+ source 'https://rubygems.org'
2
+ ruby "1.9.3"
3
+
4
+ gem 'rails', '3.2.13'
5
+ gem 'unicorn', '4.6.2'
6
+ gem 'secure_headers', '0.3.0'
7
+ gem 'jquery-rails', '2.2.1'
8
+ gem 'haml-rails', '0.4'
9
+ gem 'pg', '0.15.0'
10
+ gem 'rack-canonical-host', '0.0.8'
11
+ # gem 'paperclip', '3.4.1'
12
+ # gem 'aws-sdk', '1.8.5'
13
+ # gem 'paranoia', '1.2.0'
14
+ # gem 'omniauth', '1.1.3'
15
+ # gem 'omniauth-facebook', '1.4.1'
16
+ # gem 'kaminari', '0.14.1'
17
+ # gem 'acts_as_hashed', '1.0.0'
18
+
19
+ group :assets do
20
+ gem 'sass-rails', '3.2.6'
21
+ gem 'coffee-rails', '3.2.2'
22
+ gem 'uglifier', '1.3.0'
23
+ end
24
+
25
+ group :development do
26
+ gem "letter_opener", '1.1.0'
27
+ gem 'foreman', '0.62.0'
28
+ gem 'integration', git: 'git://github.com/mergulhao/integration.git'
29
+ gem 'heroku-deploy', '~> 0.0.4'
30
+ gem 'better_errors', '0.9.0'
31
+ gem 'binding_of_caller', '0.7.2'
32
+ end
33
+
34
+ group :test do
35
+ gem 'webmock', '1.11.0'
36
+ gem 'shoulda-matchers', '1.5.6'
37
+ gem 'timecop', '0.6.1'
38
+ gem 'simplecov', '0.7.1', require: false
39
+ gem 'capybara', '2.0.3'
40
+ gem 'poltergeist', '1.1.0'
41
+ gem 'valid_attribute', '1.3.1'
42
+ gem 'email_spec', '1.4.0'
43
+ end
44
+
45
+ group :development, :test do
46
+ gem 'rspec-rails', '2.13.0'
47
+ gem 'factory_girl_rails', '4.2.1'
48
+ gem 'pry-rails', '0.2.2'
49
+ gem 'dotenv-rails', '0.8.0'
50
+ gem 'awesome_print', '1.1.0'
51
+ # gem 'guard-rspec', '2.5.2'
52
+ end
@@ -0,0 +1 @@
1
+ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@@ -0,0 +1,40 @@
1
+ /* Reset */
2
+
3
+ html, body, div, h1, h2, h3, h4, ul, ol, li, form, fieldset, select, input, textarea, p {
4
+ margin: 0;
5
+ padding: 0;
6
+ font-size: 100%;
7
+ background: transparent;
8
+ }
9
+
10
+ a, ins { text-decoration: none; }
11
+
12
+ del { text-decoration: line-through; }
13
+
14
+ hr { display: none; }
15
+
16
+ ul, ol { list-style: none; }
17
+
18
+ img, fieldset { border: none; }
19
+
20
+ h1, h2, h3, h4 { font-weight: normal; }
21
+
22
+ em { font-style: italic; }
23
+
24
+ strong { font-weight: bold; }
25
+
26
+ table {
27
+ border-collapse: collapse;
28
+ border-spacing: 0;
29
+ }
30
+
31
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
32
+
33
+ abbr[title], dfn[title]{
34
+ cursor: help;
35
+ border-bottom: 1px dotted;
36
+ }
37
+
38
+ pre, code {
39
+ font-family: monospace;
40
+ }
@@ -0,0 +1,2 @@
1
+ class Admin::ContentsController < Admin::ResourcesController
2
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module TypusHelper
3
+ def display_text(item, attribute)
4
+ if attribute == 'log'
5
+ content_tag :pre, item.send(attribute)
6
+ else
7
+ super
8
+ end
9
+ end
10
+ def display_paperclip(item, attribute)
11
+ if item.send(attribute).content_type =~ /^image\/.+/
12
+ image_tag paperclip_file_url(item, attribute)
13
+ else
14
+ link_to item.send("#{attribute}_file_name"), paperclip_file_url(item, attribute)
15
+ end
16
+ end
17
+ def display_string(item, attribute)
18
+ if attribute == 'hashed_code'
19
+ item.hashed_code.nil? ? "Ainda não gerado." : link_to(item)
20
+ else
21
+ super
22
+ end
23
+ end
24
+ def table_paperclip_field(attribute, item)
25
+ link_to item.send("#{attribute}_file_name"), paperclip_file_url(item, attribute)
26
+ end
27
+
28
+ private
29
+ def paperclip_file_url(item, attribute)
30
+ (item.send(attribute).s3_permissions == :private) ? item.send(attribute).expiring_url(10.minutes) : item.send(attribute).url
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ class Content < ActiveRecord::Base
2
+ attr_accessible :text, as: :admin
3
+ validates :name, :slug, :text, presence: true
4
+ def self.markdown(slug)
5
+ RDiscount.new(content(slug).text).to_html.html_safe
6
+ rescue
7
+ nil
8
+ end
9
+ def self.raw(slug)
10
+ content(slug).text
11
+ rescue
12
+ nil
13
+ end
14
+ def self.ensure(slug, name, text)
15
+ return unless content(slug).nil?
16
+ content = new
17
+ content.slug = slug.to_s
18
+ content.name = name
19
+ content.text = text
20
+ content.save!
21
+ end
22
+
23
+ private
24
+ def self.content(slug)
25
+ where(slug: slug.to_s).first
26
+ end
27
+ end
@@ -0,0 +1,68 @@
1
+ !!! 5
2
+ %html{:lang => "pt"}
3
+ %head
4
+ %meta{:charset => "utf-8"}
5
+ %meta{:name => "keywords", :content => ""}
6
+ %meta{:name => "description", :content => ""}
7
+
8
+ %title= yield(:title) + "Titulo aqui"
9
+
10
+ %link{:href => "/favicon.ico", :rel => "shortcut icon"}
11
+ = yield(:header_tags)
12
+
13
+ = stylesheet_link_tag "application", :type => nil, :media => "all"
14
+ = javascript_include_tag "application", :type => nil
15
+ = csrf_meta_tags
16
+
17
+ /[if lt IE 9]
18
+ %script{:src => "http://html5shim.googlecode.com/svn/trunk/html5.js"}
19
+
20
+ :plain
21
+ <script type="text/javascript">
22
+
23
+ var _gaq = _gaq || [];
24
+ _gaq.push(['_setAccount', 'XXXXX-XXXX']);
25
+ _gaq.push(['_trackPageview']);
26
+
27
+ (function() {
28
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
29
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
30
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
31
+ })();
32
+
33
+ </script>
34
+
35
+ %body{:id => controller.controller_name}
36
+ #wrap
37
+ %header
38
+ #masthead
39
+ /- if current_user
40
+ / %p
41
+ / = "Bem-vindo <strong>#{current_user.name}</strong> &bull; ".html_safe
42
+ / = link_to "Sair", logout_path
43
+ /- else
44
+ / %p
45
+ / = link_to "Acesse com Facebook", "/auth/facebook", :id => "facebook-connect"
46
+
47
+ #logo<
48
+ = link_to "Logo", root_url
49
+
50
+ - if notice
51
+ %p.notice
52
+ = notice
53
+ - if alert
54
+ %p.alert
55
+ = alert
56
+
57
+ %hr
58
+ #container
59
+ %section{:role => "main"}
60
+ = yield
61
+
62
+ - if content_for?(:sidebar)
63
+ %aside
64
+ = yield(:sidebar)
65
+ %hr
66
+ %footer
67
+ %p
68
+ = "Copyright &copy; #{Time.zone.now.year} App".html_safe