voidtools 0.2.9 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58317def67a48164232061dceea6b6c53bda8d01
4
+ data.tar.gz: cfafac618982b4a0fac16124b0a0f9e0bed1b817
5
+ SHA512:
6
+ metadata.gz: 9ae21b8dbaccec570dce75f76f9cc5e55bf622dba95a58328fd135cb4f8e8edfdca38aaa36756283be9fa0381cce24771b1d5f091651e3f68aae13404a96cc16
7
+ data.tar.gz: 5d8ef89c310cdd5152cbd8ccc98202564327c40d405729cbae5de668b73f55c0f486baf32e20edf97895084827d9a52e2f7e1432ebbbf571066ade7929b88e2d
data/Readme.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Voidtools
2
- #### growing toolset for Rails 3 and Sinatra with DataMapper and HAML class and helper modules
2
+ #### handy toolset for Sinatra with DataMapper and HAML
3
3
 
4
4
  ---
5
5
 
@@ -14,23 +14,93 @@
14
14
  - pagination
15
15
 
16
16
  ### Sinatra
17
+ - seo tracking
17
18
  - view helpers
18
19
  - link_to
19
- - image tag
20
+ - image_tag
20
21
  - include_assets (include_js, include_css)
21
-
22
+ - body_class
23
+
22
24
  note: ruby 1.9 required
23
25
 
26
+ ## Usage:
27
+
24
28
  ## DataMapper
25
29
  ### error_messages_for
26
30
 
27
31
  in your form view:
28
32
 
29
- `error_messages_for :resource`
33
+ error_messages_for :resource
30
34
 
31
35
  or
32
36
 
33
- `error_messages_for @resource`
37
+ error_messages_for @resource
38
+
39
+ ### name url
40
+
41
+ example: in your DM model add a name_url property
42
+
43
+ property :name_url, String, length: 255
44
+
45
+ before :create do
46
+ self.name_url = generate_url_from_name name
47
+ end
48
+
49
+ before create, the name_url will be generated to make your urls seo-friendly
50
+
51
+
52
+ ## Sinatra
53
+
54
+ helpers examples:
55
+
56
+ link_to "Label", "/your/link"
57
+
58
+ image_tag "/image/file.png"
59
+
60
+ include_js "antani" #=> <script src='/js/antani.js' ...>
61
+ include_css "antani" #=> <link href='/css/antani.css' ...>
62
+
63
+
64
+ %body{ class: body_class } #=> "/" -> home, "/posts/1" -> "posts", etc.
65
+
66
+
67
+ ### Paginable
68
+
69
+ Usage:
70
+
71
+ in your model add:
72
+
73
+ require 'voidtools/dm/paginable'
74
+ include Voidtools::Paginable
75
+
76
+ in a controller (or similar):
77
+
78
+ Model.paginate(page: params[:page])
79
+
80
+ in your view:
81
+
82
+ .pagination
83
+ pag:
84
+ - Model.pages.times do |i|
85
+ %a{ :href => "/path?page=#{i}" }= i+1
86
+
87
+ (optional) in your model:
88
+
89
+ def self.per_page
90
+ 20
91
+ end
92
+
93
+ a simple stylesheet (sass):
94
+
95
+ .pagination
96
+ margin: 10px 20px
97
+ a
98
+ padding: 3px 6px
99
+ background: #DDD
100
+ a:hover
101
+ background: #FFF
102
+
103
+ ## Development
34
104
 
35
105
  ### Build & install
36
106
 
@@ -42,5 +112,6 @@ or
42
112
 
43
113
  ### Changelog
44
114
 
115
+ v0.3.1 - remove unnecessary files
45
116
  v0.2.9 - added datamapper module autoload if DataMapper is defined
46
117
  v0.2.3 - first stable version, autoloads modules for sinatra and rails
@@ -1,5 +1,7 @@
1
1
  module Voidtools
2
2
 
3
+ # TODO: consider to remove rails support
4
+
3
5
  # namespace our plugin and inherit from Rails::Railtie
4
6
  # to get our plugin into the initialization process
5
7
  if defined?(Rails)
@@ -14,7 +16,7 @@ module Voidtools
14
16
  # event = ActiveSupport::Notifications::Event.new(*args)
15
17
  # puts "Voidrails - got notification: #{event.inspect}"
16
18
  # end
17
- require 'voidtools/dm/form_helpers'
19
+ require 'voidtools/dm/datamapper'
18
20
  require 'voidtools/sinatra/tracking'
19
21
  ActiveSupport.on_load(:action_view) do
20
22
  module ApplicationHelper
@@ -22,8 +24,6 @@ module Voidtools
22
24
  include Voidtools::Tracking
23
25
  end
24
26
  end
25
- # require 'voidtools/dm/name_url'
26
- # require 'voidtools/dm/paginable'
27
27
  end
28
28
  end
29
29
  end
@@ -1,16 +1,9 @@
1
1
  module Voidtools
2
2
  module NameUrl
3
- def generate_url_from_name
4
- name.gsub(/\./, '').gsub(/'|"/, ' ').gsub(/\s+/, '_').gsub(/_-_/, '_').downcase
3
+ def generate_url_from_name(name)
4
+ name.gsub(/\./, '').gsub(/['"\/]/, ' ').gsub(/\s+/, '_').gsub(/_-_/, '_').downcase
5
5
  end
6
-
7
- # TODO: try to embed this into the model
8
-
9
- # before :create do
10
- # self.name_url = generate_url_from_name
11
- # end
12
-
13
-
6
+
14
7
  def generate_name_url
15
8
  nurl = generate_url_from_name
16
9
  update(name_url: nurl)
@@ -15,6 +15,7 @@
15
15
  # #{crazyegg}
16
16
  # #{gauges("id")}
17
17
 
18
+ # oh, and don't track users too much, it's not very good and it slows down web pages
18
19
 
19
20
  module Voidtools
20
21
  module Tracking
@@ -1,24 +1,18 @@
1
1
  module Voidtools
2
2
  module Sinatra
3
3
  module ViewHelpers
4
-
5
- # require 'voidtools/sinatra/tracking'
6
- # include Voidtools::Tracking
7
-
4
+
8
5
  def link_to(label, path="javascript:void(0)", options={})
9
- # haml_tag :a, { href: path } do
10
- # haml_concat label
11
- # end
12
6
  options = options.map do |key, value|
13
7
  " #{key}='#{value}'"
14
8
  end.join(" ")
15
9
  haml_concat "<a href='#{path}'#{options}>#{label}</a>"
16
10
  end
17
-
11
+
18
12
  def image_tag(url, options={})
19
13
  haml_tag :img, options.merge(src: url)
20
14
  end
21
-
15
+
22
16
  def include_assets(type, assets)
23
17
  type_js = type == "js"
24
18
  tag = type_js ? "script" : "link"
@@ -31,15 +25,15 @@ module Voidtools
31
25
  haml_tag tag, options
32
26
  end
33
27
  end
34
-
28
+
35
29
  def include_js(assets)
36
30
  include_assets "js", assets
37
31
  end
38
-
32
+
39
33
  def include_css(assets)
40
34
  include_assets "css", assets
41
35
  end
42
-
36
+
43
37
  def body_class
44
38
  path = request.path.split("/")[1..2]
45
39
  path = path.join(" ") unless path.nil?
@@ -1,3 +1,3 @@
1
1
  module Voidtools
2
- VERSION = "0.2.9"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voidtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Francesco 'makevoid' Canessa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-26 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! 'handy toolset for sinatra and datamapper - sinatra modules: tracking,
13
+ description: 'handy toolset for sinatra and datamapper - sinatra modules: tracking,
15
14
  view_helpers - datamapper modules: form_helpers, name_url, paginable'
16
15
  email: makevoid@gmail.com
17
16
  executables: []
@@ -19,39 +18,36 @@ extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
20
  - Readme.md
22
- - lib/voidtools/cap/deploy.rb
21
+ - lib/voidtools.rb
23
22
  - lib/voidtools/dm/datamapper.rb
24
23
  - lib/voidtools/dm/form_helpers.rb
25
24
  - lib/voidtools/dm/name_url.rb
26
25
  - lib/voidtools/dm/paginable.rb
27
- - lib/voidtools/rails/app_mixin.rb
28
26
  - lib/voidtools/sinatra/sinatra.rb
29
27
  - lib/voidtools/sinatra/tracking.rb
30
28
  - lib/voidtools/sinatra/view_helpers.rb
31
29
  - lib/voidtools/version.rb
32
- - lib/voidtools.rb
33
30
  homepage: http://www.makevoid.com
34
31
  licenses: []
32
+ metadata: {}
35
33
  post_install_message:
36
34
  rdoc_options: []
37
35
  require_paths:
38
36
  - lib
39
37
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
38
  requirements:
42
- - - ! '>='
39
+ - - ">="
43
40
  - !ruby/object:Gem::Version
44
41
  version: '0'
45
42
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
43
  requirements:
48
- - - ! '>='
44
+ - - ">="
49
45
  - !ruby/object:Gem::Version
50
46
  version: '0'
51
47
  requirements: []
52
48
  rubyforge_project: voidtools
53
- rubygems_version: 1.8.10
49
+ rubygems_version: 2.3.0
54
50
  signing_key:
55
- specification_version: 3
51
+ specification_version: 4
56
52
  summary: handy toolset for sinatra and datamapper
57
53
  test_files: []
@@ -1,152 +0,0 @@
1
-
2
- set :application, "thorrents"
3
-
4
- #set :domain, "krikri.makevoid.com"
5
- set :domain, "ovh.makevoid.com"
6
-
7
- # git
8
-
9
- # #set :repository, "svn://#{domain}/svn/#{application}"
10
- # #default_run_options[:pty] = true # Must be set for the password prompt from git to work
11
- set :repository, "git://github.com/makevoid/thorrents.git" # public
12
-
13
- set :scm, "git"
14
- set :branch, "master"
15
- set :deploy_via, :remote_cache
16
-
17
- set :password, File.read("/Users/makevoid/.password").strip.gsub(/33/, '')
18
-
19
-
20
- set :user, "www-data"
21
-
22
- set :use_sudo, false
23
- set :deploy_to, "/www/#{application}"
24
-
25
-
26
-
27
- # set :scm_username, "makevoid"
28
- # set :scm_password, File.read("/home/www-data/.password").strip
29
-
30
- role :app, domain
31
- role :web, domain
32
- role :db, domain, :primary => true
33
-
34
-
35
-
36
-
37
- after :deploy, "deploy:cleanup"
38
- #after :deploy, "db:seeds"
39
-
40
- namespace :deploy do
41
-
42
- desc "Restart Application"
43
- task :restart, :roles => :app do
44
- run "touch #{current_path}/tmp/restart.txt"
45
- end
46
-
47
- end
48
-
49
- namespace :bundle do
50
- desc "Install gems with bundler"
51
- task :install do
52
- run "cd #{current_path}; bundle install --relock"
53
- end
54
-
55
- desc "Commit, deploy and install"
56
- task :installscom do
57
- `svn commit -m ''`
58
- `cap deploy`
59
- `cap bundle:install`
60
- end
61
- end
62
-
63
- # ...
64
-
65
- namespace :bundler do
66
- task :create_symlink, :roles => :app do
67
- shared_dir = File.join(shared_path, 'bundle')
68
- release_dir = File.join(current_release, '.bundle')
69
- run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
70
- end
71
-
72
- task :bundle_new_release, :roles => :app do
73
- bundler.create_symlink
74
- run "cd #{release_path} && bundle install --without test"
75
- end
76
-
77
- task :lock, :roles => :app do
78
- run "cd #{current_release} && bundle lock;"
79
- end
80
-
81
- task :unlock, :roles => :app do
82
- run "cd #{current_release} && bundle unlock;"
83
- end
84
- end
85
-
86
- # HOOKS
87
- after "deploy:update_code" do
88
- bundler.bundle_new_release
89
- # ...
90
- end
91
-
92
- R_ENV = "RACK_ENV"
93
-
94
- namespace :scraper do
95
- desc "Run the scraper"
96
- task :scrape do
97
- run "cd #{current_path}; #{R_ENV}=production bundle exec rake scraper:scrape --trace"
98
- end
99
- end
100
-
101
-
102
- namespace :db do
103
- desc "Create database"
104
- task :create do
105
- run "mysql -u root --password=#{password} -e 'CREATE DATABASE IF NOT EXISTS #{application}_production;'"
106
- end
107
-
108
- desc "Seed database"
109
- task :seeds do
110
- run "cd #{current_path}; #{R_ENV}=production rake db:seeds"
111
- end
112
-
113
- desc "Migrate database"
114
- task :automigrate do
115
- run "cd #{current_path}; #{R_ENV}=production rake db:automigrate --trace"
116
- end
117
-
118
- desc "Send the local db to production server"
119
- task :toprod do
120
- # `rake db:seeds`
121
- `mysqldump -u root #{application}_development > db/#{application}_development.sql`
122
- upload "db/#{application}_development.sql", "#{current_path}/db", :via => :scp
123
- run "mysql -u root --password=#{password} #{application}_production < #{current_path}/db/#{application}_development.sql"
124
- end
125
-
126
- desc "Get the remote copy of production db"
127
- task :todev do
128
- run "mysqldump -u root --password=#{password} #{application}_production > #{current_path}/db/#{application}_production.sql"
129
- download "#{current_path}/db/#{application}_production.sql", "db/#{application}_production.sql"
130
- local_path = `pwd`.strip
131
- `mysql -u root #{application}_development < #{local_path}/db/#{application}_production.sql`
132
-
133
-
134
- desc "Get the remote copy of production db [option: BACKUP]"
135
- task :todev do
136
- run "mysqldump -u root --password=#{password} #{application}_production > #{current_path}/db/#{application}_production.sql"
137
- download "#{current_path}/db/#{application}_production.sql", "db/#{application}_production.sql"
138
- local_path = `pwd`.strip
139
- `mysql -u root #{application}_development < #{local_path}/db/#{application}_production.sql`
140
-
141
- t = Time.now
142
- file = "#{application}_production_#{t.strftime("%Y_%m_%d")}.sql"
143
- `mv db/#{application}_production.sql db/#{file}`
144
-
145
- if ENV["BACKUP"] != "" || ENV["BACKUP"].nil?
146
- `cp db/#{file} ~/db_backups/`
147
- puts "Backup saved on ~/db_backups/#{file}"
148
- end
149
- end
150
- end
151
- end
152
-
@@ -1,8 +0,0 @@
1
- module Voidtools
2
- module AppMixin
3
- def not_found
4
- #render template: "exceptions/not_found", status: :not_found
5
- render file: "/public/404.html", layout: false, status: 404
6
- end
7
- end
8
- end