rails-readable-xml 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3c7b8800066bbc07686e87de85d70f3247586ad
4
+ data.tar.gz: e1b2aede9a4ca3b4bbb2b6a88ef0f430f72fffa6
5
+ SHA512:
6
+ metadata.gz: 6c331d2b35d9befdb386346a6827de18aca9ee5a15d100778467264c9bd4c86f954238beec4802e0a8d5996c264a99de686cf0a40158cdf69f937f05cac11395
7
+ data.tar.gz: d5311f2025bcaa4240a6ed9030ff5c5f7f7e20759a2f2914cadd93ddb5d419711d384451f668b999d04934da572fc45d4ab9bf7bc18e8d0d6578319a393b2b5c
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Chris Mytton
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Readable XML jQuery Plug-in for Rails
2
+
3
+ Rails wrapping for https://github.com/SimonChong/jQuery-Readable-XML-Plug-in
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Readable XML jQuery Plug-in
3
+ *
4
+ * Copyright (c) 2011, Simon Chong <simons.mail@gmail.com>
5
+ *
6
+ * Licensed under The MIT License which can be obtained from <http://www.opensource.org>
7
+ *
8
+ */
9
+ (function ($) {
10
+
11
+ function encode (xml) {
12
+ return xml.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
13
+ }
14
+
15
+ function convert (xml, collapsed) {
16
+
17
+ var closedClass = '';
18
+ if (collapsed) {
19
+ closedClass = 'r-close';
20
+ }
21
+
22
+ /*
23
+ * I got a lot of practice using REGEX... I could have done it by parsing XML but it seemed to strip some code away depending on what I used.
24
+ */
25
+
26
+ // A tag block
27
+ xml = xml.replace(/(<[^\/!][^>]*?\/>)/mg, "----blockTagL----$1----blockTagR----");
28
+
29
+ // CDATA tags
30
+ xml = xml.replace(/(<!\[CDATA\[)/mg, "----openCDataL----$1----openCDataR----");
31
+ xml = xml.replace(/(\]\]>)/mg, "----closeCDataL----$1----closeCDataR----");
32
+
33
+ // All tag elements
34
+ xml = xml.replace(/(<[^?\/!][^<>]*?[^\/]>)/mg, "----openTagL----$1----openTagR----");
35
+ // Tag elements with attributes
36
+ xml = xml.replace(/(<[^?\/!][^<>\/]*?)\s([^<>]*?)(\/?>)/mg, "$1 ----openAttrL----$2----openAttrR----$3");
37
+ // Tag element attributes values
38
+ xml = xml.replace(/=(["'].*?["'])/mg, "----openAttrValL----$1----openAttrValR----");
39
+
40
+ // Single character tags like <p>
41
+ xml = xml.replace(/(<[^?\/!<>]>)/mg, "----openTagL----$1----openTagR----");
42
+
43
+ // All tag contents and Close tags
44
+ xml = xml.replace(/(<[\/].*?>)/mg, "----closeTagL----$1----closeTagR----");
45
+
46
+ xml = encode(xml);
47
+
48
+ // The xml header
49
+ xml = xml.replace(/(&lt;\?[^?]*\?&gt;)/mg, "<span class='r-oTag'>$1</span>");
50
+
51
+ // Replace all place holders
52
+ // It must be done this way because when you encode '<' or '>' it
53
+ // turns into
54
+ // 3 characters which is harder to match.
55
+
56
+ xml = xml.replace(/----openCDataL----/mg, "<div class='r-cdata'><div class='r-cdoTag'>");
57
+ xml = xml.replace(/----openCDataR----/mg, "</div>");
58
+
59
+ xml = xml.replace(/----closeCDataL----/mg, "<div class='r-cdcTag'>");
60
+ xml = xml.replace(/----closeCDataR----/mg, "</div></div>");
61
+
62
+ xml = xml.replace(/----openAttrL----/mg, "<span class='r-attr'>");
63
+ xml = xml.replace(/----openAttrR----/mg, "</span>");
64
+
65
+ xml = xml.replace(/----openAttrValL----/mg, "<span class='r-attrVal'>");
66
+ xml = xml.replace(/----openAttrValR----/mg, "</span>");
67
+
68
+ xml = xml.replace(/----openTagL----/mg, "<div class='r-cont " + closedClass + "'><div class='r-minus'></div><div class='r-element'><span class='r-oTag'>");
69
+ xml = xml.replace(/----openTagR----/mg, "</span><span class='r-content'>");
70
+
71
+ xml = xml.replace(/----closeTagL----/mg, "</span><span class='r-cTag'>");
72
+ xml = xml.replace(/----closeTagR----/mg, "</span></div></div>");
73
+
74
+ xml = xml.replace(/----blockTagL----/mg, "<div class='r-element'><div class='r-oTag'>");
75
+ xml = xml.replace(/----blockTagR----/mg, "</div></div>");
76
+
77
+ xml = xml.replace(/<\/div>([^<]+?)<\/span>/mg, "</div><div class='r-loose'>$1</div></span>");
78
+ xml = xml.replace(/<\/div>([^<]+?)<div/mg, "</div><div class='r-loose'>$1</div><div");
79
+
80
+ return xml;
81
+ }
82
+
83
+ $.fn.readableXML = function (XML, newOptions) {
84
+
85
+ var options = {
86
+ collapsed : false,
87
+ onClose : function () {
88
+ },
89
+ onOpen : function () {
90
+ }
91
+ };
92
+
93
+ if (options && typeof options == "object") {
94
+ $.extend(options, newOptions);
95
+ }
96
+
97
+ var newXML = convert(XML, options.collapsed);
98
+
99
+ // Clear all the elments ready for the XML
100
+ $(this).each(function () {
101
+ $(this).empty();
102
+ $(this).html('<div class="r-main"><div class="r-mainPad">' + newXML + '</div><div class="r-clear"></div></div>');
103
+ });
104
+
105
+ // Bind the collapse event on the minus plus symbols
106
+ $(this).find('.r-minus').click(function () {
107
+ var $element = $(this);
108
+
109
+ if ($element.parent().hasClass('r-close')) {
110
+ $element.parent().removeClass('r-close');
111
+ options.onOpen($element.parent());
112
+ } else {
113
+ $element.parent().addClass('r-close');
114
+ options.onClose($element.parent());
115
+ }
116
+ });
117
+
118
+ // Bind the collapse event on the opening tag
119
+ $(this).find('.r-oTag').click(function () {
120
+ var $element = $(this);
121
+
122
+ if ($element.parent().parent().hasClass('r-close')) {
123
+ $element.parent().parent().removeClass('r-close');
124
+ options.onOpen($element.parent().parent());
125
+ } else {
126
+ $element.parent().parent().addClass('r-close');
127
+ options.onClose($element.parent().parent());
128
+ }
129
+ });
130
+
131
+ };
132
+
133
+ })(jQuery);
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Readable XML jQuery Plug-in CSS
3
+ *
4
+ * Copyright (c) 2011, Simon Chong <simons.mail@gmail.com>
5
+ *
6
+ * Licensed under The MIT License which can be obtained from <http://www.opensource.org>
7
+ *
8
+ */
9
+ .r-main {
10
+ width: 100%;
11
+ margin: 20px auto;
12
+ font-size: 11px;
13
+ font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono,
14
+ DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace,
15
+ serif;
16
+ }
17
+
18
+ .r-mainPad {
19
+ padding: 10px 10px 10px 16px;
20
+ }
21
+
22
+ .r-oTag {
23
+ cursor: pointer;
24
+ margin-left: -0px;
25
+ }
26
+
27
+ .r-oTag,.r-cTag {
28
+ color: #881280;
29
+ word-wrap: break-word;
30
+ }
31
+
32
+ .r-cTag {
33
+ padding-left: 0px;
34
+ }
35
+
36
+ .r-content {
37
+ word-wrap: break-word;
38
+ }
39
+
40
+ .r-close .r-content,.r-close .r-cTag {
41
+ display: none;
42
+ }
43
+
44
+ .r-element {
45
+ line-height: 16px;
46
+ word-wrap: break-word;
47
+ margin-left: 16px;
48
+ }
49
+
50
+ .r-attr {
51
+ color: #994500;
52
+ }
53
+
54
+ .r-attrVal {
55
+ color: #1A1AA6;
56
+ }
57
+
58
+ .r-loose {
59
+ margin-left: 16px;
60
+ color: black;
61
+ }
62
+
63
+ .r-new {
64
+ padding-left: 0px;
65
+ }
66
+
67
+ .r-minus {
68
+ display: block;
69
+ background-image: url(../assets/jquery.readableXML.png);
70
+ background-repeat: no-repeat;
71
+ text-indent: -99999px;
72
+ overflow: hidden;
73
+ width: 16px;
74
+ height: 16px;
75
+ cursor: pointer;
76
+ background-position: -16px 5px;
77
+ float: left;
78
+ }
79
+
80
+ .r-close .r-minus {
81
+ background-position: 0px 5px;
82
+ }
83
+
84
+ .r-cdoTag,.r-cdcTag {
85
+ color: #C80000;
86
+ }
87
+
88
+ /*
89
+ .r-cdata div,.r-cdata span {
90
+ display: inline;
91
+ padding: 0;
92
+ background: none;
93
+ float: none;
94
+ margin: 0;
95
+ text-indent: 0;
96
+ word-wrap: break-word;
97
+ }*/
98
+ .
99
+ r-cdata {
100
+ clear: both;
101
+ padding-left: 20px;
102
+ }
103
+
104
+ .r-clear {
105
+ clear: both;
106
+ }
@@ -0,0 +1,3 @@
1
+ if defined? Rails && Rails.application.config.try(:assets).try(:compile)
2
+ require 'fancybox2/rails'
3
+ end
@@ -0,0 +1,3 @@
1
+ if defined? Rails && Rails.application.config.try(:assets).try(:compile)
2
+ require 'rails-readable-xml/rails'
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'rails-readable-xml/rails/engine'
2
+ require 'rails-readable-xml/rails/version'
@@ -0,0 +1,2 @@
1
+ require 'fancybox2/rails/engine'
2
+ require 'fancybox2/rails/version'
@@ -0,0 +1,6 @@
1
+ module ReadableXML
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Fancybox2
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module ReadableXML
2
+ module Rails
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Fancybox2
2
+ module Rails
3
+ VERSION = "0.2.8"
4
+ FANCYBOX_VERSION = "2.1.5"
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-readable-xml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - James Lin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.1.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.1'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '3.1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: jquery-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: This gem provides jQuery Readable XML for Rails >= 3.1 application.
62
+ email:
63
+ - linjunhalida@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - Gemfile
69
+ - MIT-LICENSE
70
+ - README.md
71
+ - app/assets/images/jquery.readableXML.minus.png
72
+ - app/assets/images/jquery.readableXML.plus.png
73
+ - app/assets/images/jquery.readableXML.png
74
+ - app/assets/javascripts/jquery.readableXML.js
75
+ - app/assets/stylesheets/jquery.readableXML.css
76
+ - lib/fancybox2-rails.rb~
77
+ - lib/rails-readable-xml.rb
78
+ - lib/rails-readable-xml/rails.rb
79
+ - lib/rails-readable-xml/rails.rb~
80
+ - lib/rails-readable-xml/rails/engine.rb
81
+ - lib/rails-readable-xml/rails/engine.rb~
82
+ - lib/rails-readable-xml/rails/version.rb
83
+ - lib/rails-readable-xml/rails/version.rb~
84
+ homepage: https://github.com/halida/rails-readable-xml
85
+ licenses:
86
+ - MIT
87
+ - Creative Commons by-nc
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.4
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Use jQuery Readable XML with Rails >= 3.1
109
+ test_files: []
110
+ has_rdoc: