frontie 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Frontie
2
2
 
3
- TODO: Write a gem description
3
+ Frontie is a suite of helpers for building Rails front-ends.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,69 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Active State Helpers
22
+
23
+ A few simple helpers to set the active state for navigational components. The helper will match against controller and actions names and return `class="active"` or nothing.
24
+
25
+ # active_for_controller will return 'active' if paramater matches controller_name
26
+ %li= link_to "Products", products_path, class: "products #{active_for_controller("products"}"
27
+
28
+ # active_for will return 'active' if paramter matches action_name
29
+ %li= link_to "Edit", edit_product_path(@product), class: "product #{active_for("edit")}"
30
+
31
+ # active_for_controller_and_action returns 'active' if matches controller and action
32
+ %li= link_to "Drafts", draft_products_path, class: active_for_controller_and_action("admin/products", "drafts")
33
+
34
+ # active_for_controllers will return 'active' if matches any controllers passed in aray
35
+ %li= link_to "Products", products_path, class: active_for_controllers(["products", "categories", "tags"])
36
+
37
+
38
+ ### Body Class Helper
39
+
40
+ Simple get and set methods for <body> class. By default, the helper will define the body classes based on the controller and action names. You can simple add to your body tag:
41
+
42
+ # Default controller and action names
43
+ %body{class: body_class} #=> <body class="application application-index">
44
+
45
+ You can add additional body classes by using the `set_body_class` method in your views:
46
+
47
+ # views/application/index.html.haml
48
+ - set_body_class "homepage dark-background"
49
+ #=> <body class="application application-index homepage dark-background">
50
+
51
+
52
+ ### Date Helpers
53
+
54
+ There are a few date format helpers, these were based on some recurring needs we had but feel free to customize. See the date_time_helper.rb for more details.
55
+
56
+
57
+ ### Link Helpers
58
+
59
+ A nice link helper for creating icon buttons. It plays nice with bootstrap.
60
+
61
+ # Create a simple icon with link
62
+ = icon_link_to "New Product", new_products_path, "icon-product" #=> <a href="/products/new"><i class="icon-product">New Product</a>
63
+
64
+ # Pass any parameters as usual
65
+ = icon_link_to "Delete Product", product_path(@product), "icon-trash", confirm: "Are you sure?", method: :delete
66
+ #=> <a href="products/5" confirm="Are you sure?" method="delete">Delete Product</a>
67
+
68
+
69
+ ### Map Helper
70
+
71
+ Easily create Google map links and images
72
+
73
+ # Simple map link
74
+ = map_link "800 W. Huron St. Chicago, IL 60642", "Visit our office"
75
+
76
+ # Map Image
77
+ # pass an object with longitude and latitude attributes
78
+ = map_image @office_location, width: "250", height: "275"
79
+
80
+
81
+
82
+ ... more to come.
83
+
22
84
 
23
85
  ## Contributing
24
86
 
@@ -4,7 +4,7 @@ module DateTimeHelper
4
4
  def timeago time, options = {}
5
5
  options[:title] = options[:title] == false ? nil : l(time)
6
6
  options[:datetime] = time.to_s
7
- content_tag(tag, "#{time_ago_in_words(time).capitalize} ago", options)
7
+ content_tag(:abbr, "#{time_ago_in_words(time).capitalize} ago", options) if time
8
8
  end
9
9
 
10
10
  # Facny date
@@ -1,3 +1,3 @@
1
1
  module Frontie
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-18 00:00:00.000000000 Z
12
+ date: 2013-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler