script_helpers 0.0.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,23 @@
|
|
1
|
+
module ScriptHelpers
|
2
|
+
class InstallGenerator < ::Rails::Generators::Base
|
3
|
+
def create_database
|
4
|
+
application_layout = "app/views/layouts/application.html.erb"
|
5
|
+
return unless File.exist?(application_layout)
|
6
|
+
application_layout_contents = File.read application_layout
|
7
|
+
modified_application_layout = false
|
8
|
+
|
9
|
+
unless application_layout_contents.include?("<%= script_contents %>") || application_layout_contents.include?("<%= script_tag_contents %>")
|
10
|
+
gsub_file application_layout, /<\/body>/, "<%= script_tag_contents %>\n<%= script_contents %>\n</body>"
|
11
|
+
modified_application_layout = true
|
12
|
+
end
|
13
|
+
|
14
|
+
unless application_layout_contents.include?("<%= css_contents %>") || application_layout_contents.include?("<%= css_tag_contents %>")
|
15
|
+
gsub_file application_layout, /<\/head>/, " <%= css_tag_contents %>\n <%= css_contents %>\n</head>"
|
16
|
+
modified_application_layout = true
|
17
|
+
end
|
18
|
+
|
19
|
+
# Since gsub_file doesn't ask the user, just inform user that the file was overwritten.
|
20
|
+
puts " force #{application_layout}" if modified_application_layout
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module ScriptHelpers
|
2
|
+
module HelperAdditions
|
3
|
+
def script(options = {}, &block)
|
4
|
+
if options.include? :src
|
5
|
+
content_for :script_tags, "\n#{javascript_include_tag options[:src]}".html_safe
|
6
|
+
end
|
7
|
+
|
8
|
+
if block
|
9
|
+
return javascript_tag &block if options[:inline]
|
10
|
+
content_for :script, "\n#{capture &block}".html_safe
|
11
|
+
end
|
12
|
+
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def script_tag_contents
|
17
|
+
content_for :script_tags
|
18
|
+
end
|
19
|
+
|
20
|
+
def script_contents
|
21
|
+
javascript_tag do
|
22
|
+
content_for :script
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def css(options = {}, &block)
|
27
|
+
if options.include? :src
|
28
|
+
content_for :css_tags, "\n#{stylesheet_link_tag options[:src]}".html_safe
|
29
|
+
end
|
30
|
+
|
31
|
+
if block
|
32
|
+
content_for :css, "\n#{capture &block}".html_safe
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def css_tag_contents
|
37
|
+
content_for :css_tags
|
38
|
+
end
|
39
|
+
|
40
|
+
def css_contents
|
41
|
+
contents = content_for :css
|
42
|
+
|
43
|
+
if contents
|
44
|
+
"<style type=\"text/css\">#{contents}</style>".html_safe
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module ApplicationHelper
|
51
|
+
include ScriptHelpers::HelperAdditions
|
52
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "script_helpers/helper_additions"
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: script_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Stone
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-11 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
description: A Rails 3 gem that allows easy inlining of css and JavaScript
|
16
|
+
email: stonemj@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/generators/script_helpers/install/install_generator.rb
|
22
|
+
- lib/script_helpers.rb
|
23
|
+
- lib/script_helpers/helper_additions.rb
|
24
|
+
has_rdoc: true
|
25
|
+
homepage: https://github.com/mikestone/Script-Helpers
|
26
|
+
licenses: []
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.6.2
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: Script Helpers
|
49
|
+
test_files: []
|