centering_helper 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a7383b24d8c4dc0d5926988335e099132ba7b313
4
+ data.tar.gz: ecc80212ed13a545912ec70a871e31cee52cb218
5
+ SHA512:
6
+ metadata.gz: 810885dc605cf6095612379fc9157f0ab637fa530ad7c2e3db5ff5b63ff2ca7fffcafc328760b9a51129fa77bffdb02eb530270fbdfb0dc945e42e4575cbba56
7
+ data.tar.gz: 806ebee05c773f6273e8dfed6b2423bbaa391586e0049021df727bf83466dedfbe6bf8510e1c087e759bef6d5c71f5d9c67181cb985930fd793df68ea6bdd54a
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 'Liane Allen'
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.
@@ -0,0 +1,89 @@
1
+ # CenteringHelper
2
+ A bit of css and a view helper to make it easy to center content in a view with
3
+ just two lines of code.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'centering_helper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install centering-helper
18
+
19
+ ## Usage
20
+ Once the gem is installed, it's super simple.
21
+
22
+ ### Include the CSS file
23
+ Add the following to your app/stylesheets/application.css:
24
+
25
+ *= require centering_helper
26
+
27
+ ... somewhere above:
28
+
29
+ *= require tree .
30
+
31
+ ### Add Two Lines of Code to Your View
32
+ In the view code, find the content you want to center. For example, if you want
33
+ to center an image:
34
+
35
+ <%= image_tag @project.image_url(:standard_size) %>
36
+
37
+ Wrap the content with the centering commands:
38
+
39
+ <% start_centering %>
40
+ <%= image_tag @project.image_url(:standard_size) %>
41
+ <% end_centering %>
42
+
43
+ That's it!
44
+
45
+ This will automatically wrap the content with divs that will center the content.
46
+
47
+
48
+ #### Caveat
49
+ The content will be centered within whatever contains it.
50
+
51
+ ##### What this means:
52
+
53
+ Let's say you have a page with 2 columns of non-centered data:
54
+
55
+ |Col 1| |Col 2|
56
+ | | | |
57
+ | . | | |
58
+ | | | |
59
+ | | | |
60
+
61
+ And you place the start and end commands inside the div tags for the left hand
62
+ column - this will center the data within that enclosing div:
63
+
64
+ |Col 1| |Col 2|
65
+ | | | |
66
+ | . | | |
67
+ | | | |
68
+ | | | |
69
+
70
+ It will not center the data within the page:
71
+
72
+ |Col 1| |Col 2|
73
+ | | | |
74
+ | |.| |
75
+ | | | |
76
+ | | | |
77
+
78
+ So if the content ends up centered someplace other than you expected, take a
79
+ look at the enclosing divs or any divs in between the commands. You may want to
80
+ move the <% start_centering %> and <% end_centering %> commands to outside the
81
+ enclosing divs, or to inside nested divs, etc.
82
+
83
+ ## Contributing
84
+
85
+ 1. Fork it ( https://github.com/[my-github-username]/centering-helper/fork )
86
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
87
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
88
+ 4. Push to the branch (`git push origin my-new-feature`)
89
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,16 @@
1
+ .outer_wrapper {
2
+ position: relative;
3
+ overflow: hidden;
4
+ }
5
+
6
+ .centering_wrapper {
7
+ position: relative;
8
+ float: left;
9
+ left: 50%;
10
+ }
11
+
12
+ .center_element {
13
+ position: relative;
14
+ float: left;
15
+ left: -50%;
16
+ }
@@ -0,0 +1 @@
1
+ require "centering_helper"
@@ -0,0 +1,15 @@
1
+ module CenteringHelper
2
+ def start_centering
3
+ raw('<div class="outer_wrapper">
4
+ <div class="centering_wrapper">
5
+ <div class="center_element">'
6
+ )
7
+ end
8
+
9
+ def end_centering
10
+ raw(' </div>
11
+ </div>
12
+ </div>'
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'centering_helper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "centering_helper"
8
+ spec.version = CenteringHelper::VERSION
9
+ spec.authors = ["Liane Allen"]
10
+ spec.email = ["liantics.antics@gmail.com"]
11
+ spec.summary = %q{Automatically place divs for centering an image or other content into your html.}
12
+ spec.description = %q{A view helper to make centering images and other content easy.}
13
+ spec.homepage = "http://www.github.com/liantics/centering_helper"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.6"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ end
@@ -0,0 +1,6 @@
1
+ require "centering_helper/version"
2
+
3
+ module CenteringHelper
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module CenteringHelper
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module CenteringHelper
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: centering_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Liane Allen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A view helper to make centering images and other content easy.
42
+ email:
43
+ - liantics.antics@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/stylesheets/centering_helper.css
54
+ - app/assets/stylesheets/index.css
55
+ - app/helpers/centering_helper.rb
56
+ - centering_helper.gemspec
57
+ - lib/centering_helper.rb
58
+ - lib/centering_helper/engine.rb
59
+ - lib/centering_helper/version.rb
60
+ homepage: http://www.github.com/liantics/centering_helper
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Automatically place divs for centering an image or other content into your
84
+ html.
85
+ test_files: []