wakizashi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/README.md +54 -0
- data/Rakefile +24 -0
- data/app/app_delegate.rb +9 -0
- data/lib/wakizashi/base.rb +13 -0
- data/lib/wakizashi/version.rb +3 -0
- data/lib/wakizashi/xml_document.rb +148 -0
- data/lib/wakizashi/xml_element.rb +45 -0
- data/lib/wakizashi/xml_node.rb +5 -0
- data/lib/wakizashi.rb +15 -0
- data/spec/wakizashi_spec.rb +28 -0
- data/spec/xml_document_spec.rb +24 -0
- data/spec/xml_element_spec.rb +16 -0
- data/spec/xml_node_spec.rb +2 -0
- data/vendor/Podfile.lock +5 -0
- data/vendor/Pods/GDataXML-HTML/.gitignore +13 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML-HTML-Info.plist +38 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML-HTML-Prefix.pch +14 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLAppDelegate.h +28 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLAppDelegate.m +82 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLViewController.h +29 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/GDataXML_HTMLViewController.m +89 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/GDataXML_HTMLViewController.xib +351 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/InfoPlist.strings +2 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/en.lproj/MainWindow.xib +444 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/html.html +34 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/lib/GDataXMLNode.h +229 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/lib/GDataXMLNode.m +1910 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/main.m +24 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML/xml.xml +15 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML.xcodeproj/project.pbxproj +317 -0
- data/vendor/Pods/GDataXML-HTML/GDataXML-HTML.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/vendor/Pods/GDataXML-HTML/README.markdown +55 -0
- data/vendor/Pods/Headers/GDataXML-HTML/GDataXMLNode.h +229 -0
- data/vendor/Pods/Pods-prefix.pch +3 -0
- data/vendor/Pods/Pods-resources.sh +15 -0
- data/vendor/Pods/Pods.bridgesupport +231 -0
- data/vendor/Pods/Pods.xcconfig +4 -0
- data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
- data/wakizashi.gemspec +18 -0
- metadata +124 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# wakizashi - HTML/XML Parser for RubyMoton
|
2
|
+
|
3
|
+
HTML/XML parser for RubyMotion, based on [GDataXML-HTML](https://github.com/graetzer/GDataXML-HTML).
|
4
|
+
|
5
|
+
Goal: Nokogiri style interface HTML parsing and building for RubyMotion.
|
6
|
+
|
7
|
+
Status: basic search, read and write working
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
Install the gem
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem install wakizashi
|
15
|
+
```
|
16
|
+
|
17
|
+
Add the gem to your RubyMotion Rakefile
|
18
|
+
|
19
|
+
``` ruby
|
20
|
+
$:.unshift("/Library/RubyMotion/lib")
|
21
|
+
require 'motion/project'
|
22
|
+
require 'motion-cocoapods'
|
23
|
+
require 'wakizashi'
|
24
|
+
|
25
|
+
Motion::Project::App.setup do |app|
|
26
|
+
app.name = 'myapp'
|
27
|
+
|
28
|
+
# Only needed if you have not already specifying a pods dependency
|
29
|
+
app.pods do
|
30
|
+
dependency 'GDataXML-HTML'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Parsing
|
38
|
+
|
39
|
+
Search nodes with XPath
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
doc = Wakizashi::HTML("<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href='http://www.google.com'>Google</a></body></html>")
|
43
|
+
doc.xpath("//p")
|
44
|
+
```
|
45
|
+
|
46
|
+
Modify nodes
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
link = doc.xpath("//a").first
|
50
|
+
link["href"] # => "http://www.google.com"
|
51
|
+
link["href"] = "http://wikipedia.org"
|
52
|
+
link.stringValue = "Wiki"
|
53
|
+
link.to_html => # "<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href='http://wikipedia.org'>Wiki</a></body></html>"
|
54
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project'
|
4
|
+
require 'motion-redgreen'
|
5
|
+
require 'motion-cocoapods'
|
6
|
+
|
7
|
+
Motion::Project::App.setup do |app|
|
8
|
+
# Use `rake config' to see complete project settings.
|
9
|
+
app.name = 'wakizashi'
|
10
|
+
Dir.glob("lib/wakizashi/**/*.rb").each do |f|
|
11
|
+
app.files.unshift(f)
|
12
|
+
end
|
13
|
+
|
14
|
+
app.pods do
|
15
|
+
dependency 'GDataXML-HTML'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Build the gem"
|
20
|
+
task :gem do
|
21
|
+
sh "bundle exec gem build wakizashi.gemspec"
|
22
|
+
sh "mkdir -p pkg"
|
23
|
+
sh "mv *.gem pkg/"
|
24
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
module Wakizashi
|
2
|
+
module Document
|
3
|
+
module Options
|
4
|
+
HTML_PARSE_RECOVER = 1 # Relaxed parsing
|
5
|
+
HTML_PARSE_NODEFDTD = 4 # do not default a doctype if not found
|
6
|
+
HTML_PARSE_NOERROR = 32 # suppress error reports
|
7
|
+
HTML_PARSE_NOWARNING = 64 # suppress warning reports
|
8
|
+
HTML_PARSE_PEDANTIC = 128 # pedantic error reporting
|
9
|
+
HTML_PARSE_NOBLANKS = 256 # remove blank nodes
|
10
|
+
HTML_PARSE_NONET = 2048 # Forbid network access
|
11
|
+
HTML_PARSE_NOIMPLIED = 8192 # Do not add implied html/body... elements
|
12
|
+
HTML_PARSE_COMPACT = 65536 # compact small text nodes
|
13
|
+
HTML_PARSE_IGNORE_ENC = 2097152 # ignore internal document encoding hint
|
14
|
+
HTML_PARSE_OPTIONS = {
|
15
|
+
:recover => HTML_PARSE_RECOVER,
|
16
|
+
:nodefdtd => HTML_PARSE_NODEFDTD,
|
17
|
+
:noerror => HTML_PARSE_NOERROR,
|
18
|
+
:nowarning => HTML_PARSE_NOWARNING,
|
19
|
+
:pedantic => HTML_PARSE_PEDANTIC,
|
20
|
+
:noblanks => HTML_PARSE_NOBLANKS,
|
21
|
+
:nonet => HTML_PARSE_NONET,
|
22
|
+
:noimplied => HTML_PARSE_NOIMPLIED,
|
23
|
+
:compact => HTML_PARSE_COMPACT,
|
24
|
+
:ignore_enc => HTML_PARSE_IGNORE_ENC
|
25
|
+
}
|
26
|
+
DEFAULT_HTML_OPTIONS = [:nowarning, :noerror]
|
27
|
+
|
28
|
+
XML_PARSE_RECOVER = 1 # recover on errors
|
29
|
+
XML_PARSE_NOENT = 2 # substitute entities
|
30
|
+
XML_PARSE_DTDLOAD = 4 # load the external subset
|
31
|
+
XML_PARSE_DTDATTR = 8 # default DTD attributes
|
32
|
+
XML_PARSE_DTDVALID = 16 # validate with the DTD
|
33
|
+
XML_PARSE_NOERROR = 32 # suppress error reports
|
34
|
+
XML_PARSE_NOWARNING = 64 # suppress warning reports
|
35
|
+
XML_PARSE_PEDANTIC = 128 # pedantic error reporting
|
36
|
+
XML_PARSE_NOBLANKS = 256 # remove blank nodes
|
37
|
+
XML_PARSE_SAX1 = 512 # use the SAX1 interface internally
|
38
|
+
XML_PARSE_XINCLUDE = 1024 # Implement XInclude substitition
|
39
|
+
XML_PARSE_NONET = 2048 # Forbid network access
|
40
|
+
XML_PARSE_NODICT = 4096 # Do not reuse the context dictionnary
|
41
|
+
XML_PARSE_NSCLEAN = 8192 # remove redundant namespaces declarations
|
42
|
+
XML_PARSE_NOCDATA = 16384 # merge CDATA as text nodes
|
43
|
+
XML_PARSE_NOXINCNODE = 32768 # do not generate XINCLUDE START/END nodes
|
44
|
+
XML_PARSE_COMPACT = 65536 # compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
|
45
|
+
XML_PARSE_OLD10 = 131072 # parse using XML-1.0 before update 5
|
46
|
+
XML_PARSE_NOBASEFIX = 262144 # do not fixup XINCLUDE xml:base uris
|
47
|
+
XML_PARSE_HUGE = 524288 # relax any hardcoded limit from the parser
|
48
|
+
XML_PARSE_OLDSAX = 1048576 # parse using SAX2 interface before 2.7.0
|
49
|
+
XML_PARSE_IGNORE_ENC = 2097152 # ignore internal document encoding hint
|
50
|
+
XML_PARSE_OPTIONS = {
|
51
|
+
:recover => XML_PARSE_RECOVER,
|
52
|
+
:noent => XML_PARSE_NOENT,
|
53
|
+
:dtdload => XML_PARSE_DTDLOAD,
|
54
|
+
:dtdattr => XML_PARSE_DTDATTR,
|
55
|
+
:dtdvalid => XML_PARSE_DTDVALID,
|
56
|
+
:noerror => XML_PARSE_NOERROR,
|
57
|
+
:nowarning => XML_PARSE_NOWARNING,
|
58
|
+
:pedantic => XML_PARSE_PEDANTIC,
|
59
|
+
:noblanks => XML_PARSE_NOBLANKS,
|
60
|
+
:sax1 => XML_PARSE_SAX1,
|
61
|
+
:xinclude => XML_PARSE_XINCLUDE,
|
62
|
+
:nonet => XML_PARSE_NONET,
|
63
|
+
:nodict => XML_PARSE_NODICT,
|
64
|
+
:nsclean => XML_PARSE_NSCLEAN,
|
65
|
+
:nocdata => XML_PARSE_NOCDATA,
|
66
|
+
:noxincnode => XML_PARSE_NOXINCNODE,
|
67
|
+
:compact => XML_PARSE_COMPACT,
|
68
|
+
:old10 => XML_PARSE_OLD10,
|
69
|
+
:nobasefix => XML_PARSE_NOBASEFIX,
|
70
|
+
:huge => XML_PARSE_HUGE,
|
71
|
+
:oldsax => XML_PARSE_OLDSAX,
|
72
|
+
:ignore_enc => XML_PARSE_IGNORE_ENC
|
73
|
+
}
|
74
|
+
|
75
|
+
DEFAULT_XML_OPTIONS = [:nocdata, :noblanks]
|
76
|
+
end
|
77
|
+
|
78
|
+
module CreationMethods
|
79
|
+
include Options
|
80
|
+
|
81
|
+
def with_html(html, *options)
|
82
|
+
if options.size == 1 && options[0].is_a?(Fixnum)
|
83
|
+
options_mask = options[0]
|
84
|
+
else
|
85
|
+
options = DEFAULT_HTML_OPTIONS if options.size == 0
|
86
|
+
options_mask = option_to_mask(options, HTML_PARSE_OPTIONS)
|
87
|
+
end
|
88
|
+
error_ptr = Pointer.new(:id)
|
89
|
+
if html.is_a?(NSData)
|
90
|
+
elem = self.alloc.initWithHTMLData(html, options:options_mask, error:error_ptr)
|
91
|
+
else
|
92
|
+
elem = self.alloc.initWithHTMLString(html, options:options_mask, error:error_ptr)
|
93
|
+
end
|
94
|
+
raise Wakizashi::ParseError, error_ptr[0].description if error_ptr[0]
|
95
|
+
elem
|
96
|
+
end
|
97
|
+
|
98
|
+
def with_xml(xml, *options)
|
99
|
+
if options.size == 1 && options[0].is_a?(Fixnum)
|
100
|
+
options_mask = options[0]
|
101
|
+
else
|
102
|
+
options = DEFAULT_XML_OPTIONS if options.size == 0
|
103
|
+
options_mask = option_to_mask(options, XML_PARSE_OPTIONS)
|
104
|
+
end
|
105
|
+
error_ptr = Pointer.new(:id)
|
106
|
+
if xml.is_a?(NSData)
|
107
|
+
elem = self.alloc.initWithData(xml, options:options_mask, error:error_ptr)
|
108
|
+
else
|
109
|
+
elem = self.alloc.initWithXMLString(xml, options:options_mask, error:error_ptr)
|
110
|
+
end
|
111
|
+
raise Wakizashi::ParseError, error_ptr[0].description if error_ptr[0]
|
112
|
+
elem
|
113
|
+
end
|
114
|
+
|
115
|
+
protected
|
116
|
+
# TODO fix me with proper mask
|
117
|
+
def option_to_mask(options, all_options)
|
118
|
+
mask = 0
|
119
|
+
options.each do |key|
|
120
|
+
if all_options.keys.include?(key)
|
121
|
+
mask = mask | all_options[key]
|
122
|
+
else
|
123
|
+
raise "option not supported: #{key}. must be one of: #{all_options.keys}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
mask
|
127
|
+
end
|
128
|
+
end # CreationMethods
|
129
|
+
|
130
|
+
module InstanceMethods
|
131
|
+
def xpath(xpath, options={})
|
132
|
+
error_ptr = Pointer.new(:id)
|
133
|
+
if options.empty?
|
134
|
+
result = self.nodesForXPath(xpath, error:error_ptr)
|
135
|
+
else
|
136
|
+
result = self.nodesForXPath(xpath, namespaces:options, error:error_ptr)
|
137
|
+
end
|
138
|
+
raise Wakizashi::ParseError, error_ptr[0].description if error_ptr[0]
|
139
|
+
result
|
140
|
+
end
|
141
|
+
end # InstanceMethods
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
class GDataXMLDocument
|
146
|
+
extend Wakizashi::Document::CreationMethods
|
147
|
+
include Wakizashi::Document::InstanceMethods
|
148
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Wakizashi
|
2
|
+
module Element
|
3
|
+
module CreationMethods
|
4
|
+
def with_html(html)
|
5
|
+
error_ptr = Pointer.new(:id)
|
6
|
+
elem = self.alloc.initWithHTMLString(html, error:error_ptr)
|
7
|
+
raise Wakizashi::ParseError, error_ptr[0].description if error_ptr[0]
|
8
|
+
elem
|
9
|
+
end
|
10
|
+
|
11
|
+
def with_xml(xml)
|
12
|
+
error_ptr = Pointer.new(:id)
|
13
|
+
elem = self.alloc.initWithXMLString(xml, error:error_ptr)
|
14
|
+
raise Wakizashi::ParseError, error_ptr[0].description if error_ptr[0]
|
15
|
+
elem
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def []=(key, val)
|
21
|
+
attr = self.attributeForName(key)
|
22
|
+
if attr
|
23
|
+
attr.stringValue = val
|
24
|
+
else
|
25
|
+
attr = self.addAttribute(GDataXMLNode.attributeWithName(key, stringValue:val))
|
26
|
+
end
|
27
|
+
val
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](key)
|
31
|
+
attr = self.attributeForName(key)
|
32
|
+
if attr
|
33
|
+
attr.stringValue
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class GDataXMLElement
|
43
|
+
extend Wakizashi::Element::CreationMethods
|
44
|
+
include Wakizashi::Element::InstanceMethods
|
45
|
+
end
|
data/lib/wakizashi.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "wakizashi/version"
|
2
|
+
require 'motion-cocoapods'
|
3
|
+
|
4
|
+
unless defined?(Motion::Project::Config)
|
5
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
6
|
+
end
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'wakizashi/*.rb')).each do |file|
|
10
|
+
app.files.unshift(file)
|
11
|
+
end
|
12
|
+
|
13
|
+
app.pods ||= Motion::Project::CocoaPods.new(app)
|
14
|
+
app.pods.dependency 'GDataXML-HTML'
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
describe "Wakizashi" do
|
2
|
+
it "should parse html" do
|
3
|
+
doc = Wakizashi.HTML("<p>Hello World</p>")
|
4
|
+
doc.is_a?(GDataXMLDocument).should.be.true
|
5
|
+
doc.rootElement.to_xml.should == "<html><body><p>Hello World</p></body></html>"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should parse xml" do
|
9
|
+
doc = Wakizashi.XML("<p>Hello World</p>")
|
10
|
+
doc.is_a?(GDataXMLDocument).should.be.true
|
11
|
+
doc.rootElement.to_xml.should == "<p>Hello World</p>"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should search document and modify content" do
|
15
|
+
html = "<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href='http://www.google.com'>Google</a></body></html>"
|
16
|
+
doc = Wakizashi.HTML(html)
|
17
|
+
|
18
|
+
link = doc.xpath("//a").first
|
19
|
+
link["href"].should == "http://www.google.com"
|
20
|
+
link.stringValue.should == "Google"
|
21
|
+
|
22
|
+
link["href"] = "http://wikipedia.org"
|
23
|
+
link.stringValue = "Wiki"
|
24
|
+
|
25
|
+
link.to_html.should == "<html><body><h1>Hello World</h1><p>Welcome</p><p>Foo</p><a href=\"http://wikipedia.org\">Wiki</a></body></html>"
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe "GDataXMLDocument" do
|
2
|
+
it "should parse html document" do
|
3
|
+
doc = GDataXMLDocument.with_html("<ul><li>Hello World</li></ul>")
|
4
|
+
doc.rootElement.name.should == "html"
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should parse xml document" do
|
8
|
+
doc = GDataXMLDocument.with_xml("<table><tr><td>Hi</td></tr></table>")
|
9
|
+
doc.rootElement.name.should == "table"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise ParseError on invalid XML" do
|
13
|
+
lambda { GDataXMLDocument.with_xml("<table><tr><td>Hi</td></tr>", :noerror, :nowarning) }.
|
14
|
+
should.raise(Wakizashi::ParseError).
|
15
|
+
message.should.match(/com.google.GDataXML error -1/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "search elment with xpath" do
|
19
|
+
doc = GDataXMLDocument.with_html("<ul><li><p>Hello World</p></li><li>Boom</li></ul>")
|
20
|
+
nodes = doc.xpath("//li")
|
21
|
+
nodes.size.should == 2
|
22
|
+
nodes.first.class.should == GDataXMLElement
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "GDataXMLElement" do
|
2
|
+
it "should create html node" do
|
3
|
+
element = GDataXMLElement.with_html("<div><p>Hello World</p></div>")
|
4
|
+
element.to_s.should == "Hello World"
|
5
|
+
element.childCount.should == 1
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should read and write attribute and value" do
|
9
|
+
element = GDataXMLElement.with_xml("<a href='http://www.google.com'>Google</a>")
|
10
|
+
element["href"].should == "http://www.google.com"
|
11
|
+
|
12
|
+
element["href"] = "http://wikipedia.org"
|
13
|
+
element.stringValue = "Wikipedia"
|
14
|
+
element.to_xml.should == '<a href="http://wikipedia.org">Wikipedia</a>'
|
15
|
+
end
|
16
|
+
end
|
data/vendor/Podfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>en</string>
|
7
|
+
<key>CFBundleDisplayName</key>
|
8
|
+
<string>${PRODUCT_NAME}</string>
|
9
|
+
<key>CFBundleExecutable</key>
|
10
|
+
<string>${EXECUTABLE_NAME}</string>
|
11
|
+
<key>CFBundleIconFile</key>
|
12
|
+
<string></string>
|
13
|
+
<key>CFBundleIdentifier</key>
|
14
|
+
<string>org.graetzer.${PRODUCT_NAME:rfc1034identifier}</string>
|
15
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
16
|
+
<string>6.0</string>
|
17
|
+
<key>CFBundleName</key>
|
18
|
+
<string>${PRODUCT_NAME}</string>
|
19
|
+
<key>CFBundlePackageType</key>
|
20
|
+
<string>APPL</string>
|
21
|
+
<key>CFBundleShortVersionString</key>
|
22
|
+
<string>1.0</string>
|
23
|
+
<key>CFBundleSignature</key>
|
24
|
+
<string>????</string>
|
25
|
+
<key>CFBundleVersion</key>
|
26
|
+
<string>1.0</string>
|
27
|
+
<key>LSRequiresIPhoneOS</key>
|
28
|
+
<true/>
|
29
|
+
<key>NSMainNibFile</key>
|
30
|
+
<string>MainWindow</string>
|
31
|
+
<key>UISupportedInterfaceOrientations</key>
|
32
|
+
<array>
|
33
|
+
<string>UIInterfaceOrientationPortrait</string>
|
34
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
35
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
36
|
+
</array>
|
37
|
+
</dict>
|
38
|
+
</plist>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
//
|
2
|
+
// Prefix header for all source files of the 'GDataXML-HTML' target in the 'GDataXML-HTML' project
|
3
|
+
//
|
4
|
+
|
5
|
+
#import <Availability.h>
|
6
|
+
|
7
|
+
#ifndef __IPHONE_3_0
|
8
|
+
#warning "This project uses features only available in iPhone SDK 3.0 and later."
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#ifdef __OBJC__
|
12
|
+
#import <UIKit/UIKit.h>
|
13
|
+
#import <Foundation/Foundation.h>
|
14
|
+
#endif
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/* Copyright (c) 2011 Simon Grätzer simon@graetzer.org
|
2
|
+
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
* you may not use this file except in compliance with the License.
|
5
|
+
* You may obtain a copy of the License at
|
6
|
+
*
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
*
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
* See the License for the specific language governing permissions and
|
13
|
+
* limitations under the License.
|
14
|
+
*/
|
15
|
+
|
16
|
+
#import <UIKit/UIKit.h>
|
17
|
+
|
18
|
+
@class GDataXML_HTMLViewController;
|
19
|
+
|
20
|
+
@interface GDataXML_HTMLAppDelegate : NSObject <UIApplicationDelegate> {
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
25
|
+
|
26
|
+
@property (nonatomic, retain) IBOutlet GDataXML_HTMLViewController *viewController;
|
27
|
+
|
28
|
+
@end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/* Copyright (c) 2011 Simon Grätzer simon@graetzer.org
|
2
|
+
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
* you may not use this file except in compliance with the License.
|
5
|
+
* You may obtain a copy of the License at
|
6
|
+
*
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
*
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
* See the License for the specific language governing permissions and
|
13
|
+
* limitations under the License.
|
14
|
+
*/
|
15
|
+
|
16
|
+
#import "GDataXML_HTMLAppDelegate.h"
|
17
|
+
|
18
|
+
#import "GDataXML_HTMLViewController.h"
|
19
|
+
|
20
|
+
@implementation GDataXML_HTMLAppDelegate
|
21
|
+
|
22
|
+
|
23
|
+
@synthesize window=_window;
|
24
|
+
|
25
|
+
@synthesize viewController=_viewController;
|
26
|
+
|
27
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
28
|
+
{
|
29
|
+
// Override point for customization after application launch.
|
30
|
+
|
31
|
+
self.window.rootViewController = self.viewController;
|
32
|
+
[self.window makeKeyAndVisible];
|
33
|
+
return YES;
|
34
|
+
}
|
35
|
+
|
36
|
+
- (void)applicationWillResignActive:(UIApplication *)application
|
37
|
+
{
|
38
|
+
/*
|
39
|
+
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
40
|
+
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
41
|
+
*/
|
42
|
+
}
|
43
|
+
|
44
|
+
- (void)applicationDidEnterBackground:(UIApplication *)application
|
45
|
+
{
|
46
|
+
/*
|
47
|
+
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
48
|
+
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
49
|
+
*/
|
50
|
+
}
|
51
|
+
|
52
|
+
- (void)applicationWillEnterForeground:(UIApplication *)application
|
53
|
+
{
|
54
|
+
/*
|
55
|
+
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
56
|
+
*/
|
57
|
+
}
|
58
|
+
|
59
|
+
- (void)applicationDidBecomeActive:(UIApplication *)application
|
60
|
+
{
|
61
|
+
/*
|
62
|
+
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
63
|
+
*/
|
64
|
+
}
|
65
|
+
|
66
|
+
- (void)applicationWillTerminate:(UIApplication *)application
|
67
|
+
{
|
68
|
+
/*
|
69
|
+
Called when the application is about to terminate.
|
70
|
+
Save data if appropriate.
|
71
|
+
See also applicationDidEnterBackground:.
|
72
|
+
*/
|
73
|
+
}
|
74
|
+
|
75
|
+
- (void)dealloc
|
76
|
+
{
|
77
|
+
[_window release];
|
78
|
+
[_viewController release];
|
79
|
+
[super dealloc];
|
80
|
+
}
|
81
|
+
|
82
|
+
@end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/* Copyright (c) 2011 Simon Grätzer simon@graetzer.org
|
2
|
+
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
* you may not use this file except in compliance with the License.
|
5
|
+
* You may obtain a copy of the License at
|
6
|
+
*
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
*
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
* See the License for the specific language governing permissions and
|
13
|
+
* limitations under the License.
|
14
|
+
*/
|
15
|
+
|
16
|
+
|
17
|
+
#import <UIKit/UIKit.h>
|
18
|
+
|
19
|
+
@interface GDataXML_HTMLViewController : UIViewController {
|
20
|
+
|
21
|
+
UITextView *textView;
|
22
|
+
}
|
23
|
+
|
24
|
+
@property (nonatomic, retain) IBOutlet UITextView *textView;
|
25
|
+
|
26
|
+
- (IBAction)startXMLParsing:(id)sender;
|
27
|
+
- (IBAction)startHTMLParsing;
|
28
|
+
|
29
|
+
@end
|