dryml-firemarker 0.0.8

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.
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## Eclipse
22
+ .loadpath
23
+ .project
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 by Barquin International
2
+ Designed and developed by Domizio Demichelis
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # Dryml FireMarker
2
+
3
+ Adds DRYML markers viewable with FireMarker (a Firefox/Firebug extension)
4
+
5
+ ## Overview
6
+
7
+ Dryml FireMarker is a tool composed by 2 components:
8
+
9
+ 1. "FireMarker": a Firebug extension that graphically shows special markers embedded in any HTML page.
10
+ 2. "dryml-firemarker": a gem to use with Dryml/Hobo that simply marks (with FireMarker markers),
11
+ specific parts of HTML with their related metainfo.
12
+
13
+ ## 1. FireMarker (FF extension)
14
+
15
+ FireMarker is an extension for Firebug that graphically shows special markers embedded in any HTML page. Its main
16
+ benefit is that you can easily read the metainfo related to any specific part of the HTML by just hovering the
17
+ mouse on the page-item. It also adds a few interactive features to Firebug and an inline file viewer/editor.
18
+
19
+ ### 1.1 Requirements
20
+
21
+ - Recent Firefox >= 3.6
22
+ - Recent Firebug (I use the 1.7.1 but it might work on older versions too)
23
+
24
+ ### 1.2 Installation
25
+
26
+ Download the latest compiled extension from:
27
+
28
+ https://github.com/ddnexus/firemarker/downloads
29
+
30
+ Install in Firefox with Tools > Add-ons > Install Add-on From File...
31
+
32
+ ## 2. Dryml FireMarker (gem)
33
+
34
+ Dryml FireMarker is a ruby gem, so you can istall it as usual:
35
+
36
+ $ [sudo] gem install dryml-firemarker
37
+
38
+ Since Dryml is implemented in 3 different ways in Hobo 1.0.x, Dryml 1.1.x and Dryml >= 1.3,
39
+ you must setup your app consistently with the dryml version it uses.
40
+
41
+ ### 2.1 Hobo 1.0.x and Hobo/Dryml 1.1.x
42
+
43
+ #### Setup
44
+
45
+ In the `environment.rb` file:
46
+
47
+ config.gem 'dryml-firemarker', :lib => 'dryml<version>-firemarker'
48
+
49
+ \<version\> is '10' for Hobo 1.0.x or '11' for Hobo/Dryml 1.1.x
50
+
51
+ If you use the `rapid` taglib (i.e. Hobo) you have also to add a tag in the `views/auto/taglibs/application.dryml` file:
52
+
53
+ <include plugin="dryml-firemarker"/>
54
+
55
+ Notice that you must add it after the inclusion of the `rapid` taglib.
56
+
57
+ #### Notes
58
+
59
+ If your app uses the `rapid` taglib, the gem for the 1.0.x and 1.1.x should be loaded in the regular `environment.rb`
60
+ (i.e. not just in `development.rb`), since it fixes a few consolidated bugs coded in that taglib. Besides,
61
+ you can safely load it in all environments, because - by default - it will add the matainfo to the page only in
62
+ development mode, and will keep the fixes consistent in all environments.
63
+
64
+ You can also force the inclusion or the skipping of the metainfo in the page, by setting the `DRYML_METAINFO`
65
+ boolean constant just before the `config.gem 'dryml-firemarker',...` statement.
66
+
67
+ If your application needs to override one of `hobo-rapid-javascripts`, `part-contexts-javascripts` or
68
+ `page-scripts` helpers/tags, you must take into account that the tags that your application uses are defined in
69
+ the `dryml-firemarker.dryml` taglib included in this gem (and not the same tags defined in the regular rapid taglib).
70
+
71
+ ### 2.2. Hobo/Dryml >= 1.3
72
+
73
+ Add just one line to the `Gemfile` file:
74
+
75
+ gem 'dryml-firemarker', :require => 'dryml13-firemarker', :group => :development
76
+
77
+ There are no bugs to fix in the Hobo/Dryml >= 1.3.0 version, so you can add or skip the metainfo by just
78
+ adding or commenting out the previous statement (and restart the app).
79
+
80
+ ## Mini Tutorial
81
+
82
+ ### Check list
83
+
84
+ 1. Install and setup the FF Extension component and the gem
85
+ 2. Start/restart the app
86
+ 3. Render any page in Firefox
87
+ 4. Open Firebug (F12)
88
+ 5. Select the "HTML" tab
89
+ 6. Uncheck "Show Comments" in the HTML tab menu
90
+ 7. Select the "Markers" tab in the Firebug HTML side panel
91
+ 8. Check "dryml" option in the Markers tab menu Usage
92
+
93
+ ### Usage
94
+
95
+ Select any node in the HTML panel or click on the Firebug's inspect icon and hover the mouse on any part of the page,
96
+ then click on it to select the node: the Markers panel will be populated with all the markers that include that
97
+ specific node. They are listed from close to far. The closest are the most specific markers that wrap the selected
98
+ node: e.g. an \<a\> tag that produces a specific link; the farest are the most general: e.g. a \<page\> tag that wraps
99
+ the whole page (including the \<a\> tag listed at the beginning).
100
+
101
+ Hovering up and down in the Markers list may be useful to understand what specific dryml statement is creating the
102
+ specific highlighted part in the page and HTML source, and eventually helps to chose what to override. (Notice that
103
+ invisible page-parts are highlighted only in the source and have a dimmed color.)
104
+
105
+ You can open any dryml file (at the right line) by clicking on the path listed in the marker's table. You can close
106
+ it by clicking on it again. If you hold the "Ctrl" or the "Alt" key while you click on a path,
107
+ you will open the file in a new FF tab instead: that might be useful when you need to explore a large file.
108
+
109
+ The green paths (with an ending "+") are editable because they are application files,
110
+ while the blue paths are just viewable, because they are libraries or auto-generated files that doesn't make sense to
111
+ edit.
112
+
113
+ If you want to save an edited file, just close it and FireMarker will ask if you want to save it.
114
+
115
+ ## TO DO
116
+
117
+ Add "edit in external editor" feature to allow to open the dryml file in your preferred IDE.
118
+
119
+ ## Copyright
120
+
121
+ Copyright (c) 2011 by Barquin International<br>
122
+ Designed and developed by Domizio Demichelis<br>
123
+ See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ name = 'dryml-firemarker'
2
+
3
+ def ensure_clean(action, force=false)
4
+ if !force && ! `git status -s`.empty?
5
+ puts <<-EOS.gsub(/^ {6}/, '')
6
+ Rake task aborted: the working tree is dirty!
7
+ If you know what you are doing you can use \`rake #{action}[force]\`"
8
+ EOS
9
+ exit(1)
10
+ end
11
+ end
12
+
13
+ desc "Install the gem"
14
+ task :install, :force do |t, args|
15
+ ensure_clean(:install, args.force)
16
+ orig_version = version = File.read('VERSION').strip
17
+ begin
18
+ commit_id = `git log -1 --format="%h" HEAD`.strip
19
+ version = "#{orig_version}.#{commit_id}"
20
+ File.open('VERSION', 'w') {|f| f.puts version }
21
+ gem_name = "#{name}-#{version}.gem"
22
+ sh %(gem build #{name}.gemspec)
23
+ sh %(gem install #{gem_name} --local --no-rdoc --no-ri)
24
+ puts <<-EOS.gsub(/^ {6}/, '')
25
+
26
+ *******************************************************************************
27
+ * NOTICE *
28
+ *******************************************************************************
29
+ * The version id of locally installed gems is comparable to a --pre version: *
30
+ * i.e. it is alphabetically ordered (not numerically ordered), besides it *
31
+ * includes the sah1 commit id which is not aphabetically ordered, so be sure *
32
+ * your application picks the version you really intend to use *
33
+ *******************************************************************************
34
+
35
+ EOS
36
+ ensure
37
+ remove_entry_secure gem_name, true
38
+ File.open('VERSION', 'w') {|f| f.puts orig_version }
39
+ end
40
+ end
41
+
42
+ desc %(Remove all the "#{name}" installed gems and executables and install this version)
43
+ task :clean_install, :force do |t, args|
44
+ ensure_clean(:install, args.force)
45
+ sh %(gem uninstall #{name} --all --ignore-dependencies --executables)
46
+ Rake::Task['install'].invoke(args.force)
47
+ end
48
+
49
+ desc "Push the gem to rubygems.org"
50
+ task :push, :force do |t, args|
51
+ begin
52
+ ensure_clean(:push, args.force)
53
+ version = File.read('VERSION').strip
54
+ gem_name = "#{name}-#{version}.gem"
55
+ sh %(gem build #{name}.gemspec)
56
+ sh %(gem push #{gem_name})
57
+ ensure
58
+ remove_entry_secure gem_name, true
59
+ end
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.8
@@ -0,0 +1,25 @@
1
+ name = File.basename( __FILE__, '.gemspec' )
2
+ version = File.read(File.expand_path('../VERSION', __FILE__)).strip
3
+ require 'date'
4
+
5
+ Gem::Specification.new do |s|
6
+
7
+ s.summary = 'Adds DRYML markers viewable with FireMarker'
8
+ s.description = 'Dryml FireMarker annotates the output of Hobo and Rails apps that use the DRYML templating system.',
9
+ s.authors = ["Domizio Demichelis"]
10
+ s.email = 'dd.nexus@gmail.com'
11
+ s.homepage = "http://github.com/ddnexus/#{name}"
12
+
13
+ s.files = `git ls-files -z`.split("\0")
14
+
15
+ s.name = name
16
+ s.version = version
17
+ s.date = Date.today.to_s
18
+
19
+ s.required_rubygems_version = ">= 1.3.6"
20
+ s.rdoc_options = ["--charset=UTF-8"]
21
+ s.extra_rdoc_files = ["README.md"]
22
+ s.require_paths = ["lib"]
23
+
24
+ end
25
+
@@ -0,0 +1,40 @@
1
+ <!-- overrides rapid_core.dryml -->
2
+ <!-- Renders some standard JavaScript code that various features of the Rapid library rely on. This tag would typicallu be called from your `<page>` tag. The default Rapid pages include this already. -->
3
+ <def tag="hobo-rapid-javascripts">
4
+ <script type="text/javascript" param="default"><%=
5
+ res = 'var hoboParts = {};'
6
+ # FIXME: This should interrogate the model-router - not the models
7
+ unless Hobo::Model.all_models.empty?
8
+ # Tell JS code how to pluralize names, unless they follow the simple rule
9
+ names = Hobo::Model.all_models.map do |m|
10
+ m = m.name.underscore
11
+ "#{m}: '#{m.pluralize}'" unless m.pluralize == m + 's'
12
+ end.compact
13
+ res << "var pluralisations = {#{names * ', '}}; "
14
+ end
15
+ base = [base_url, subsite].compact.join("/")
16
+ res << "urlBase = '#{base}'; hoboPagePath = '#{view_name}'"
17
+ if protect_against_forgery?
18
+ res << "; formAuthToken = { name: '#{request_forgery_protection_token}', value: '#{form_authenticity_token}' }"
19
+ end
20
+ res
21
+ %></script>
22
+ </def>
23
+
24
+ <!-- adds tag in place of (undefined) method -->
25
+ <def tag="part-contexts-javascripts">
26
+ <% unless (storage = part_contexts_storage).blank? %>
27
+ <script type="text/javascript"><%=
28
+ storage
29
+ %></script>
30
+ <% end %>
31
+ </def>
32
+
33
+ <!-- overrides rapid_pages.dryml -->
34
+ <!-- Renderes dynamically generated JavaScript required by `hobo-rapid.js`, including the information required to perform automatic part updates -->
35
+ <def tag="page-scripts">
36
+ <do param="default">
37
+ <hobo-rapid-javascripts/>
38
+ <part-contexts-javascripts/>
39
+ </do>
40
+ </def>
@@ -0,0 +1,45 @@
1
+ require 'pathname'
2
+ require 'rbconfig'
3
+
4
+ module DrymlFireMarker
5
+
6
+ VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
7
+
8
+ WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw32|windows/i
9
+
10
+ def self.metadata_to_json(template_path, kind, name, line, *args)
11
+ keys = [ ] # we need to keep track of the key order for ruby 1.8.x unordered hashes
12
+ metadata = { }
13
+ metadata[kind] = name
14
+ keys.push(kind)
15
+ path = Pathname.new(template_path).realpath.to_s
16
+ writeable = path.match(/^#{Regexp.quote(rails_root)}\//) &&
17
+ ( auto_path.blank? ||! path.match(/^#{Regexp.quote(auto_path)}\//) )
18
+ path.gsub!(%r{/}, '\\\\\\\\') if WINDOZE # ridiculous escaping needed !!!
19
+ unless args.empty?
20
+ metadata['args'] = args.join(' | ')
21
+ keys.push('args')
22
+ end
23
+ metadata['path'] = path + ':' + line.to_s + (writeable ? '+' : '')
24
+ keys.push('path')
25
+ "{#{ keys.map{|k| k.inspect + ':' + metadata[k].inspect}.join(',') }}"
26
+ end
27
+
28
+ private
29
+
30
+ def self.auto_path
31
+ if @auto_path.nil?
32
+ @auto_path = Object.const_defined?(:Dryml) ?
33
+ Dryml::DrymlGenerator.output_directory.to_s :
34
+ Hobo::Dryml::DrymlGenerator::OUTPUT.to_s
35
+ else
36
+ @auto_path
37
+ end
38
+ end
39
+
40
+ def self.rails_root
41
+ @rails_root ||= Object.const_defined?(:Rails) ? Rails.root.to_s : RAILS_ROOT
42
+ end
43
+
44
+ end
45
+
@@ -0,0 +1,32 @@
1
+ DRYML_METAINFO = RAILS_ENV == "development" unless Object.const_defined?( :DRYML_METAINFO )
2
+
3
+ module DrymlRootModule
4
+
5
+ class TemplateEnvironment
6
+ undef_method :part_contexts_javascripts
7
+ end
8
+
9
+ if DRYML_METAINFO
10
+ class Template
11
+ def wrap_source_with_metadata(content, kind, name, line, *args)
12
+ return content if name.in?(NO_METADATA_TAGS)
13
+ json = DrymlFireMarker.metadata_to_json(@template_path, kind, name, line, *args)
14
+ "<!--[dryml]#{json}-->" + content + "<!--[/dryml]-->"
15
+ end
16
+ end
17
+ end
18
+
19
+ class Taglib
20
+ class << self
21
+ def taglib_filename_with_firemarker(options)
22
+ if options[:plugin] == "dryml-firemarker"
23
+ File.expand_path('../dryml-firemarker.dryml', __FILE__)
24
+ else
25
+ taglib_filename_without_firemarker(options)
26
+ end
27
+ end
28
+ alias_method_chain :taglib_filename, :firemarker
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'hobo/dryml/template_environment'
2
+ require 'hobo/dryml/template'
3
+ require 'hobo/dryml/taglib'
4
+ require 'dryml-firemarker'
5
+
6
+ DrymlRootModule = Hobo::Dryml
7
+
8
+ require 'dryml-overrides'
@@ -0,0 +1,10 @@
1
+ require 'dryml'
2
+ require 'dryml/template_environment'
3
+ require 'dryml/template'
4
+ require 'dryml/taglib'
5
+ require 'dryml-firemarker'
6
+
7
+ DrymlRootModule = Dryml
8
+
9
+ require 'dryml-overrides'
10
+
@@ -0,0 +1,14 @@
1
+ require 'dryml/template'
2
+ require 'dryml-firemarker'
3
+
4
+ module Dryml
5
+ class Template
6
+
7
+ def wrap_source_with_metadata(content, kind, name, line, *args)
8
+ return content if name.in?(NO_METADATA_TAGS)
9
+ json = DrymlFireMarker.metadata_to_json(@template_path, kind, name, line, *args)
10
+ "<% safe_concat(%(<!--[dryml]#{json}-->)) %>" + content + "<% safe_concat(%(<!--[/dryml]-->)) %>"
11
+ end
12
+
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dryml-firemarker
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.8
6
+ platform: ruby
7
+ authors:
8
+ - Domizio Demichelis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-06 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: "[\"Dryml FireMarker annotates the output of Hobo and Rails apps that use the DRYML templating system.\", [\"Domizio Demichelis\"]]"
18
+ email: dd.nexus@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - README.md
25
+ files:
26
+ - .gitignore
27
+ - LICENSE
28
+ - README.md
29
+ - Rakefile
30
+ - VERSION
31
+ - dryml-firemarker.gemspec
32
+ - lib/dryml-firemarker.dryml
33
+ - lib/dryml-firemarker.rb
34
+ - lib/dryml-overrides.rb
35
+ - lib/dryml10-firemarker.rb
36
+ - lib/dryml11_firemarker.rb
37
+ - lib/dryml13-firemarker.rb
38
+ has_rdoc: true
39
+ homepage: http://github.com/ddnexus/dryml-firemarker
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 1.3.6
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.5.0
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Adds DRYML markers viewable with FireMarker
66
+ test_files: []
67
+