22 | The Ikhoyo Samples application shows you how to use the Ikhoyo libraries to make many iOS related tasks easy. You can download all our libraries and sample applications at Github. You can also visit our blog.
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoWebViewContext.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoWebAppContext.m
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoWebViewContext.h"
22 |
23 |
24 | @implementation IkhoyoWebViewContext
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoDelegate.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 | @protocol IkhoyoDelegate
24 | - (Boolean) isIkhoyoReady;
25 | @end
26 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoTableViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // IkhoyoTableViewController.h
3 | // ikhoyo-ui
4 | //
5 | // Created by William Donahue on 6/9/11.
6 | // Copyright 2011 Ikhoyo. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "IkhoyoViewController.h"
11 | #import "IkhoyoAddItemViewController.h"
12 |
13 | @interface IkhoyoTableViewController : IkhoyoViewController {
14 | IBOutlet UITableView* tableView;
15 | IBOutlet IkhoyoAddItemViewController* addItemViewController;
16 | }
17 | @property (nonatomic,retain) UITableView* tableView;
18 | @property (nonatomic, retain) IkhoyoAddItemViewController* addItemViewController;
19 |
20 | - (IBAction) addAction:(id) sender;
21 | - (IBAction) editAction:(id) sender;
22 | - (IBAction) addItemDone:(id) sender;
23 | - (IBAction) addItemCancel:(id) sender;
24 |
25 | - (void) addItem:(IkhoyoAddItemViewController*) ctlr;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoWebViewContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoWebViewContext.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 |
24 | @interface IkhoyoWebViewContext : NSObject {
25 |
26 | }
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/RootViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // RootViewController.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 | @class DetailViewController;
24 | @interface RootViewController : UITabBarController {
25 | }
26 |
27 | @property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SampleWebViewContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // SampleWebAppContext.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoWebViewContext.h"
23 |
24 | @interface SampleWebViewContext : IkhoyoWebViewContext {
25 | NSMutableArray* listOfItems;
26 | }
27 | @property (nonatomic,retain) NSMutableArray* listOfItems;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SampleWebView.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // SampleWebApp.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoWebViewController.h"
23 | #import "IkhoyoDynamicTabViewController.h"
24 |
25 | @interface SampleWebView : IkhoyoDynamicTabViewController {
26 | IBOutlet IkhoyoWebViewController* webAppController;
27 | }
28 | @property (nonatomic,retain) IkhoyoWebViewController* webAppController;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoDynamicTabViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoDynamicTabViewController.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 | @interface IkhoyoDynamicTabViewController : UIViewController {
24 | NSString* name;
25 | IBOutlet UIViewController* root;
26 | }
27 | @property (nonatomic,retain) NSString* name;
28 | @property (nonatomic,retain) UIViewController* root;
29 |
30 | - (void) start:(id) obj;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/xcode-resources/webviews/sample-web-view/sample.xsl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
20 |
Welcome to the Ikhoyo Sample Web View
21 |
22 | The Ikhoyo Sample Web View shows you how to create web applications using the Ikhoyo libraries, xml, and xsl. It's a very streamlined and efficient way to create local web applications that run on the iPad.
23 |
24 |
Here is the list taken from the context:
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/DetailViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // DetailViewController.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "RootViewController.h"
23 | #import "IkhoyoDynamicTabBarController.h"
24 |
25 | @interface DetailViewController : IkhoyoDynamicTabBarController {
26 | RootViewController* rootViewController;
27 | }
28 | @property (nonatomic,retain) RootViewController* rootViewController;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoAddItemViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // IkhoyoAddItemViewController.m
3 | // ikhoyo-ui
4 | //
5 | // Created by William Donahue on 6/10/11.
6 | // Copyright 2011 Ikhoyo. All rights reserved.
7 | //
8 |
9 | #import "IkhoyoAddItemViewController.h"
10 |
11 |
12 | @implementation IkhoyoAddItemViewController
13 |
14 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
15 | {
16 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
17 | if (self) {
18 | // Custom initialization
19 | }
20 | return self;
21 | }
22 |
23 | - (void)dealloc
24 | {
25 | [super dealloc];
26 | }
27 |
28 | - (void)didReceiveMemoryWarning
29 | {
30 | [super didReceiveMemoryWarning];
31 | }
32 |
33 | #pragma mark - View lifecycle
34 |
35 | - (void)viewDidLoad
36 | {
37 | [super viewDidLoad];
38 | [self applyBackgroundGradient];
39 | }
40 |
41 | - (void)viewDidUnload
42 | {
43 | [super viewDidUnload];
44 | }
45 |
46 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
47 | {
48 | return (interfaceOrientation == UIInterfaceOrientationPortrait);
49 | }
50 |
51 | - (IBAction) textFieldDidEndOnExit:(id) sender {
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoViewController.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoDelegate.h"
23 |
24 | @interface IkhoyoViewController : UIViewController {
25 | Boolean ready;
26 | IBOutlet id app;
27 | UIColor* backgroundGradientColor;
28 | }
29 | @property (nonatomic) Boolean ready;
30 | @property (nonatomic,retain) id app;
31 | @property (nonatomic,retain) UIColor* backgroundGradientColor;
32 |
33 | - (void) applyBackgroundGradient;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoDynamicTabBarController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoDynamicTabBarController.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 | @class IkhoyoDynamicTabViewController;
24 | @interface IkhoyoDynamicTabBarController : UITabBarController {
25 | NSMutableArray* tabs;
26 | }
27 | @property (nonatomic,retain) NSMutableArray* tabs;
28 |
29 | - (void) removeTab:(IkhoyoDynamicTabViewController*) ctlr;
30 | - (IkhoyoDynamicTabViewController*) addTab:(NSString*) name withClass:(NSString*) c andImage:(UIImage*) image andParam:(id) param;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheError.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheError.h"
24 |
25 |
26 | NSString* const GRMustacheErrorDomain = @"GRMustacheErrorDomain";
27 | NSString* const GRMustacheErrorLine = @"GRMustacheErrorLine";
28 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SocrataViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SocrataViewController.m
3 | // ikhoyo-top
4 | //
5 | // Created by William Donahue on 6/27/11.
6 | // Copyright 2011 Ikhoyo. All rights reserved.
7 | //
8 |
9 | #import "SocrataViewController.h"
10 |
11 |
12 | @implementation SocrataViewController
13 |
14 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
15 | {
16 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
17 | if (self) {
18 | // Custom initialization
19 | }
20 | return self;
21 | }
22 |
23 | - (void)dealloc
24 | {
25 | [super dealloc];
26 | }
27 |
28 | - (void)didReceiveMemoryWarning
29 | {
30 | // Releases the view if it doesn't have a superview.
31 | [super didReceiveMemoryWarning];
32 |
33 | // Release any cached data, images, etc that aren't in use.
34 | }
35 |
36 | #pragma mark - View lifecycle
37 |
38 | - (void)viewDidLoad
39 | {
40 | [super viewDidLoad];
41 | // Do any additional setup after loading the view from its nib.
42 | }
43 |
44 | - (void)viewDidUnload
45 | {
46 | [super viewDidUnload];
47 | // Release any retained subviews of the main view.
48 | // e.g. self.myOutlet = nil;
49 | }
50 |
51 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
52 | {
53 | // Return YES for supported orientations
54 | return YES;
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplate_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplate.h"
24 |
25 |
26 | @interface GRMustacheTemplate()
27 | @property (nonatomic, retain) NSArray *elems;
28 | + (id)templateWithElements:(NSArray *)elems;
29 | @end
30 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTextElement_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | @interface GRMustacheTextElement: NSObject {
27 | @private
28 | NSString *text;
29 | }
30 | + (id)textElementWithString:(NSString *)string;
31 | @end
32 |
33 |
34 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoWebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoWebViewController.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoWebViewContext.h"
23 |
24 | @interface IkhoyoWebViewController : UIViewController {
25 | NSURL* url;
26 | NSURL* baseUrl;
27 | NSString* baseDir;
28 | IBOutlet UIWebView* webView;
29 | IBOutlet IkhoyoWebViewContext* context;
30 | }
31 | @property (nonatomic,retain) NSURL* url;
32 | @property (nonatomic,retain) NSURL* baseUrl;
33 | @property (nonatomic,retain) NSString* baseDir;
34 | @property (nonatomic,retain) UIWebView* webView;
35 | @property (nonatomic,retain) IkhoyoWebViewContext* context;
36 |
37 | - (void) start:(NSString*) dir;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheSection_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheSection.h"
24 |
25 |
26 | @interface GRMustacheSection()
27 | + (id)sectionElementWithName:(NSString *)name string:(NSString *)templateString inverted:(BOOL)inverted elements:(NSArray *)elems;
28 | @end
29 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/NSArray+TKCategory.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+TKCategory.h
3 | // Created by Devin Ross on 11/9/10.
4 | //
5 | /*
6 |
7 | tapku.com || http://github.com/devinross/tapkulibrary
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 |
30 | */
31 |
32 | #import
33 |
34 | @interface NSArray (TKCategory)
35 |
36 | - (id) firstObject;
37 |
38 | - (id) randomObject;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheVariableElement_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | @interface GRMustacheVariableElement: NSObject {
27 | @private
28 | NSString *name;
29 | BOOL raw;
30 | }
31 | + (id)variableElementWithName:(NSString *)name raw:(BOOL)raw;
32 | @end
33 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheSection.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | @interface GRMustacheSection: NSObject {
27 | @private
28 | NSString *name;
29 | NSString *templateString;
30 | BOOL inverted;
31 | NSArray *elems;
32 | }
33 | @property (nonatomic, retain, readonly) NSString *templateString;
34 | @end
35 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheVersion.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheVersion.h"
24 |
25 |
26 | @implementation GRMustache(Version)
27 |
28 | + (GRMustacheVersion)version {
29 | return (GRMustacheVersion){
30 | .major = GRMUSTACHE_MAJOR_VERSION,
31 | .minor = GRMUSTACHE_MINOR_VERSION,
32 | .patch = GRMUSTACHE_PATCH_VERSION };
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/NSString+TKCategory.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSStringAddition.h
3 | // Created by Devin Ross on 10/26/09.
4 | //
5 | /*
6 |
7 | tapku.com || http://github.com/devinross/tapkulibrary
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 |
30 | */
31 |
32 | #import
33 |
34 | @interface NSString (TKCategory)
35 |
36 | - (BOOL) isEmail;
37 | - (NSString*) URLEncode;
38 | - (NSString *) escapeHTML;
39 | - (NSString *) unescapeHTML;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheBundleTemplateLoader_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplateLoader_private.h"
24 |
25 |
26 | @interface GRMustacheBundleTemplateLoader: GRMustacheTemplateLoader {
27 | @private
28 | NSBundle *bundle;
29 | }
30 | - (id)initWithBundle:(NSBundle *)bundle extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
31 | @end
32 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheContext.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 |
24 | @interface GRMustacheContext: NSObject {
25 | @private
26 | id object;
27 | GRMustacheContext *parent;
28 | }
29 | + (id)contextWithObject:(id)object;
30 | + (id)contextWithObjects:(id)object, ...;
31 | - (GRMustacheContext *)contextByAddingObject:(id)object;
32 | - (id)valueForKey:(NSString *)key;
33 | @end
34 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/IkhoyoHomeTableViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoHomeTableViewController.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoViewController.h"
23 | #import "DetailViewController.h"
24 | #import "IkhoyoWebViewController.h"
25 |
26 | @interface IkhoyoHomeTableViewController : IkhoyoViewController {
27 | NSMutableArray* rows;
28 | NSMutableArray* webAppDictionaries;
29 | IBOutlet IkhoyoWebViewController* webAppController;
30 | IBOutlet DetailViewController* detailViewController;
31 | }
32 | @property (nonatomic,retain) NSMutableArray* rows;
33 | @property (nonatomic,retain) NSMutableArray* webAppDictionaries;
34 | @property (nonatomic,retain) IkhoyoWebViewController* webAppController;
35 | @property (nonatomic,retain) DetailViewController* detailViewController;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheRendering_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheRendering.h"
24 | #import "GRMustacheTemplate_private.h"
25 |
26 |
27 | @class GRMustacheContext;
28 |
29 | @protocol GRMustacheRenderingElement
30 | @required
31 | - (NSString *)renderContext:(GRMustacheContext *)context;
32 | @end
33 |
34 | @interface GRMustacheTemplate(PrivateRendering)
35 | @end
36 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/NSArray+TKCategory.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+TKCategory.m
3 | // Created by Devin Ross on 11/9/10.
4 | //
5 | /*
6 |
7 | tapku.com || http://github.com/devinross/tapkulibrary
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 |
30 | */
31 |
32 | #import "NSArray+TKCategory.h"
33 |
34 | @implementation NSArray (TKCategory)
35 |
36 | - (id) firstObject{
37 | return [self objectAtIndex:0];
38 | }
39 |
40 | - (id) randomObject{
41 | return [self objectAtIndex:arc4random() % [self count]];
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustache_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustache.h"
24 |
25 |
26 | typedef enum {
27 | GRMustacheObjectKindTrueValue,
28 | GRMustacheObjectKindFalseValue,
29 | GRMustacheObjectKindEnumerable,
30 | GRMustacheObjectKindLambda,
31 | } GRMustacheObjectKind;
32 |
33 |
34 | @interface GRMustache()
35 | + (BOOL)objectIsFalseValue:(id)object;
36 | + (GRMustacheObjectKind)objectKind:(id)object;
37 | @end
38 |
39 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplateLoader_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplateLoader_protected.h"
24 |
25 |
26 | @interface GRMustacheTemplateLoader()
27 | + (id)templateLoaderWithCurrentWorkingDirectory;
28 | - (GRMustacheTemplate *)parseTemplateNamed:(NSString *)name relativeToTemplateId:(id)templateId error:(NSError **)outError;
29 | - (void)setTemplate:(GRMustacheTemplate *)template forTemplateId:(id)templateId;
30 | @end
31 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheDirectoryTemplateLoader_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplateLoader_private.h"
24 |
25 |
26 | @interface GRMustacheDirectoryTemplateLoader: GRMustacheTemplateLoader {
27 | @private
28 | NSURL *url;
29 | }
30 | - (id)initWithURL:(NSURL *)url extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
31 | - (GRMustacheTemplate *)parseContentsOfURL:(NSURL *)templateURL error:(NSError **)outError;
32 | @end
33 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/ikhoyo-top-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | Ikhoyo
9 | CFBundleDocumentTypes
10 |
11 | CFBundleExecutable
12 | ${EXECUTABLE_NAME}
13 | CFBundleIconFile
14 |
15 | CFBundleIconFiles
16 |
17 | dove-1.png
18 | ikhoyo.png
19 |
20 | CFBundleIdentifier
21 | ikhoyo.com.${PRODUCT_NAME:rfc1034identifier}
22 | CFBundleInfoDictionaryVersion
23 | 6.0
24 | CFBundleName
25 | ${PRODUCT_NAME}
26 | CFBundlePackageType
27 | APPL
28 | CFBundleShortVersionString
29 | 1.0
30 | CFBundleSignature
31 | ????
32 | CFBundleURLTypes
33 |
34 | CFBundleVersion
35 | 1.0
36 | LSRequiresIPhoneOS
37 |
38 | NSMainNibFile
39 | MainWindow
40 | UISupportedInterfaceOrientations~ipad
41 |
42 | UIInterfaceOrientationPortrait
43 | UIInterfaceOrientationPortraitUpsideDown
44 |
45 | UTExportedTypeDeclarations
46 |
47 | UTImportedTypeDeclarations
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheLambda_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheLambda.h"
24 | #import "GRMustacheSection.h"
25 |
26 | @interface GRMustacheLambdaWrapper: NSObject
27 | - (NSString *)renderObject:(id)context withSection:(GRMustacheSection *)section;
28 | @end
29 |
30 | @interface GRMustacheLambdaSelectorWrapper: GRMustacheLambdaWrapper {
31 | SEL renderingSelector;
32 | id object;
33 | }
34 | + (id)helperWithObject:(id)object selector:(SEL)renderingSelector;
35 | @end
36 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SampleWebView.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // SampleWebApp.m
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "SampleWebView.h"
22 |
23 |
24 | @implementation SampleWebView
25 | @synthesize webAppController;
26 |
27 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
28 | {
29 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
30 | if (self) {
31 | }
32 | return self;
33 | }
34 |
35 | - (void)dealloc
36 | {
37 | [super dealloc];
38 | }
39 |
40 | - (void)didReceiveMemoryWarning
41 | {
42 | [super didReceiveMemoryWarning];
43 | }
44 |
45 | #pragma mark - View lifecycle
46 |
47 | - (void)viewDidLoad
48 | {
49 | [super viewDidLoad];
50 | }
51 |
52 | - (void)viewDidUnload
53 | {
54 | [super viewDidUnload];
55 | }
56 |
57 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
58 | {
59 | return YES;
60 | }
61 |
62 | - (void) start:(id) obj {
63 | [self.webAppController start:obj];
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoDynamicTabViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoDynamicTabViewController.m
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoDynamicTabViewController.h"
22 |
23 | @implementation IkhoyoDynamicTabViewController
24 | @synthesize name;
25 | @synthesize root;
26 |
27 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
28 | {
29 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
30 | if (self) {
31 | }
32 | return self;
33 | }
34 |
35 | - (void)dealloc
36 | {
37 | [super dealloc];
38 | }
39 |
40 | - (void)didReceiveMemoryWarning
41 | {
42 | [super didReceiveMemoryWarning];
43 | }
44 |
45 | - (void) start:(id)obj {
46 |
47 | }
48 |
49 | #pragma mark - View lifecycle
50 |
51 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
52 | - (void)viewDidLoad
53 | {
54 | [super viewDidLoad];
55 | }
56 |
57 | - (void)viewDidUnload
58 | {
59 | [super viewDidUnload];
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/projects/ikhoyo-sqlite/ikhoyo-sqlite/IkhoyoThread.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoThread.h
15 | // ikhoyo-sqlite
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 |
23 | @interface IkhoyoError : NSObject {
24 | NSString* msg;
25 | }
26 | @property (nonatomic,retain) NSString* msg;
27 |
28 | - (id) initWithFormat:(NSString*) fmt, ...;
29 |
30 | @end
31 |
32 |
33 | typedef void (^IkhoyoBlock)(id obj);
34 |
35 | @interface IkhoyoTask : NSObject {
36 | id obj;
37 | Boolean main;
38 | IkhoyoBlock task;
39 | }
40 | @property (nonatomic) Boolean main;
41 | @property (nonatomic,retain) id obj;
42 | @property (nonatomic,copy) IkhoyoBlock task;
43 | @end
44 |
45 | @interface IkhoyoThread : NSObject {
46 | NSThread* worker;
47 | }
48 | @property (nonatomic,retain) NSThread* worker;
49 |
50 |
51 | - (void) start;
52 | - (void) performBlock:(IkhoyoBlock)task;
53 | - (void) performBlockOnMainThread:(IkhoyoBlock)task;
54 | - (void) performBlock:(IkhoyoBlock)task withObject:(id)obj;
55 | - (void) performBlockOnMainThread:(IkhoyoBlock)task withObject:(id)obj;
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheLambda.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheSection.h"
24 | #import "GRMustacheContext.h"
25 |
26 | #if NS_BLOCKS_AVAILABLE
27 | typedef NSString *(^GRMustacheRenderingBlock)(GRMustacheSection*, GRMustacheContext*);
28 | id GRMustacheLambdaBlockMake(GRMustacheRenderingBlock block);
29 |
30 | typedef NSString *(^GRMustacheRenderer)(id object) __attribute__((deprecated));
31 | typedef id GRMustacheLambda __attribute__((deprecated));
32 | GRMustacheLambda GRMustacheLambdaMake(NSString *(^block)(NSString *(^)(id object), id, NSString *)) __attribute__((deprecated));
33 | #endif
34 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/IkhoyoAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoAppDelegate.h
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoDelegate.h"
23 | #import "IkhoyoSocrata.h"
24 | #import "IkhoyoDatabase.h"
25 |
26 | @class IkhoyoURLManager;
27 | @class RootViewController;
28 | @class DetailViewController;
29 | @interface IkhoyoAppDelegate : NSObject {
30 | Boolean ready;
31 | IkhoyoDatabase* db;
32 | IkhoyoSocrata* socrata;
33 | IkhoyoURLManager* urlManager;
34 | }
35 |
36 | @property (nonatomic) Boolean ready;
37 | @property (nonatomic, retain) IkhoyoDatabase* db;
38 | @property (nonatomic, retain) IkhoyoSocrata* socrata;
39 | @property (nonatomic, retain) IkhoyoURLManager* urlManager;
40 |
41 | @property (nonatomic, retain) IBOutlet UIWindow *window;
42 | @property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
43 | @property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
44 | @property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTextElement.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTextElement_private.h"
24 |
25 |
26 | @interface GRMustacheTextElement()
27 | @property (nonatomic, retain) NSString *text;
28 | - (id)initWithString:(NSString *)theText;
29 | @end
30 |
31 |
32 | @implementation GRMustacheTextElement
33 | @synthesize text;
34 |
35 | + (id)textElementWithString:(NSString *)text {
36 | return [[[self alloc] initWithString:text] autorelease];
37 | }
38 |
39 | - (id)initWithString:(NSString *)theText {
40 | if ((self = [self init])) {
41 | self.text = theText;
42 | }
43 | return self;
44 | }
45 |
46 | - (void)dealloc {
47 | [text release];
48 | [super dealloc];
49 | }
50 | @end
51 |
52 |
53 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplateParser_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import "GRMustacheTokenizer_private.h"
25 |
26 |
27 | @class GRMustacheTemplateLoader;
28 | @class GRMustacheTemplate;
29 |
30 | @interface GRMustacheTemplateParser : NSObject {
31 | @private
32 | NSError *error;
33 | GRMustacheTemplateLoader *templateLoader;
34 | id templateId;
35 | NSMutableArray *elementsStack;
36 | NSMutableArray *sectionOpeningTokenStack;
37 | NSMutableArray *currentElements;
38 | GRMustacheToken *currentSectionOpeningToken;
39 | }
40 | - (id)initWithTemplateLoader:(GRMustacheTemplateLoader *)templateLoader templateId:(id)templateId;
41 | - (GRMustacheTemplate *)templateReturningError:(NSError **)outError;
42 | @end
43 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/RootViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // RootViewController.m
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "RootViewController.h"
22 | #import "DetailViewController.h"
23 |
24 | @implementation RootViewController
25 | @synthesize detailViewController;
26 |
27 | - (void)viewDidLoad
28 | {
29 | [super viewDidLoad];
30 | }
31 |
32 |
33 | - (void)viewWillAppear:(BOOL)animated
34 | {
35 | [super viewWillAppear:animated];
36 | }
37 |
38 | - (void)viewDidAppear:(BOOL)animated
39 | {
40 | [super viewDidAppear:animated];
41 | }
42 |
43 | - (void)viewWillDisappear:(BOOL)animated
44 | {
45 | [super viewWillDisappear:animated];
46 | }
47 |
48 | - (void)viewDidDisappear:(BOOL)animated
49 | {
50 | [super viewDidDisappear:animated];
51 | }
52 |
53 | - (void)didReceiveMemoryWarning
54 | {
55 | [super didReceiveMemoryWarning];
56 | }
57 |
58 | - (void)viewDidUnload
59 | {
60 | }
61 |
62 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
63 | return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation==UIInterfaceOrientationLandscapeRight);
64 | }
65 |
66 | - (void)dealloc
67 | {
68 | [detailViewController release];
69 | [super dealloc];
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/projects/ikhoyo-socrata/ikhoyo-socrata/IkhoyoSocrata.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoSocrata.h
15 | // ikhoyo-socrata
16 | //
17 | // Created by William Donahue on 6/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoURLManager.h"
23 | #import "IkhoyoThread.h"
24 |
25 | @interface IkhoyoSocrata : NSObject {
26 | NSString* baseURL;
27 | NSString* viewURL;
28 | NSString* dataType;
29 | NSString* appTokenQS;
30 | NSMutableArray* tasks;
31 | IkhoyoURLManager* urlManager;
32 | }
33 | @property (nonatomic,retain) NSString* baseURL;
34 | @property (nonatomic,retain) NSString* viewURL;
35 | @property (nonatomic,retain) NSString* dataType;
36 | @property (nonatomic,retain) NSString* appTokenQS;
37 | @property (nonatomic,retain) NSMutableArray* tasks;
38 | @property (nonatomic,retain) IkhoyoURLManager* urlManager;
39 |
40 | - (id) initWithURLManager:(IkhoyoURLManager*) urlManager;
41 | - (id) initWithURLManager:(IkhoyoURLManager*) urlManager andApiKey:(NSString*) apiKey;
42 | - (id) initWithURLManager:(id) um andApiKey:(NSString*) apiKey andDataType:(NSString*) dt;
43 |
44 | - (void) get:(NSString*) ds withBlock:(IkhoyoBlock) block;
45 | - (void) getMeta:(NSString*) ds withBlock:(IkhoyoBlock) block;
46 | - (void) get:(NSString*) ds maxRows:(int)max withBlock:(IkhoyoBlock) block;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SampleWebViewContext.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // SampleWebAppContext.m
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "SampleWebViewContext.h"
22 |
23 | @interface Item : NSObject {
24 | NSString* name;
25 | }
26 | @property (nonatomic,retain) NSString* name;
27 |
28 | - (id) initWithName:(NSString*) name;
29 |
30 | @end
31 |
32 | @implementation Item
33 | @synthesize name;
34 |
35 | - (id) initWithName:(NSString*) n {
36 | self = [super init];
37 | if (self) {
38 | self.name = n;
39 | }
40 | return self;
41 |
42 | }
43 |
44 | @end
45 |
46 | @implementation SampleWebViewContext
47 | @synthesize listOfItems;
48 |
49 | - (id) init {
50 | self = [super init];
51 | if (self) {
52 | listOfItems = [[NSMutableArray alloc] init];
53 | [listOfItems addObject:[[[Item alloc] initWithName:@"List item 1"] autorelease]];
54 | [listOfItems addObject:[[[Item alloc] initWithName:@"List item 2"] autorelease]];
55 | [listOfItems addObject:[[[Item alloc] initWithName:@"List item 3"] autorelease]];
56 | [listOfItems addObject:[[[Item alloc] initWithName:@"List item 4"] autorelease]];
57 | [listOfItems addObject:[[[Item alloc] initWithName:@"List item 5"] autorelease]];
58 | }
59 | return self;
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheVariableElement.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheVariableElement_private.h"
24 |
25 |
26 | @interface GRMustacheVariableElement()
27 | @property (nonatomic, retain) NSString *name;
28 | @property (nonatomic) BOOL raw;
29 | - (id)initWithName:(NSString *)name raw:(BOOL)raw;
30 | @end
31 |
32 |
33 | @implementation GRMustacheVariableElement
34 | @synthesize name;
35 | @synthesize raw;
36 |
37 | + (id)variableElementWithName:(NSString *)name raw:(BOOL)raw {
38 | return [[[self alloc] initWithName:name raw:raw] autorelease];
39 | }
40 |
41 | - (id)initWithName:(NSString *)theName raw:(BOOL)theRaw {
42 | if ((self = [self init])) {
43 | self.name = theName;
44 | self.raw = theRaw;
45 | }
46 | return self;
47 | }
48 |
49 | - (void)dealloc {
50 | [name release];
51 | [super dealloc];
52 | }
53 |
54 | @end
55 |
56 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTokenizer_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import "GRMustacheToken_private.h"
25 |
26 |
27 | @class GRMustacheTokenizer;
28 |
29 | @protocol GRMustacheTokenizerDelegate
30 | @optional
31 | - (BOOL)tokenizerShouldStart:(GRMustacheTokenizer *)tokenizer;
32 | @required
33 | - (BOOL)tokenizer:(GRMustacheTokenizer *)tokenizer shouldContinueAfterParsingToken:(GRMustacheToken *)token;
34 | - (void)tokenizerDidFinish:(GRMustacheTokenizer *)tokenizer withError:(NSError *)error;
35 | @end
36 |
37 | @interface GRMustacheTokenizer : NSObject {
38 | @private
39 | id delegate;
40 | NSString *otag;
41 | NSString *ctag;
42 | }
43 | @property (nonatomic, assign) id delegate;
44 | - (void)parseTemplateString:(NSString *)templateString;
45 | @end
46 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheError.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | /**
27 | The domain of a GRMustache-generated NSError
28 |
29 | @since v1.0.0
30 | */
31 | extern NSString* const GRMustacheErrorDomain;
32 |
33 | /**
34 | When a GRMustache-generated NSError has the code GRMustacheErrorCodeParseError,
35 | its userInfo dictionary contains the line where the parse error occurred, at
36 | the key GRMustacheErrorLine.
37 |
38 | @since v1.0.0
39 | */
40 | extern NSString* const GRMustacheErrorLine;
41 |
42 | /**
43 | The codes of a GRMustache-generated NSError
44 |
45 | @since v1.0.0
46 | */
47 | typedef enum {
48 | /**
49 | The error code for parse errors.
50 |
51 | @since v1.0.0
52 | */
53 | GRMustacheErrorCodeParseError,
54 |
55 | /**
56 | The error code for not found templates and partials.
57 |
58 | @since v1.0.0
59 | */
60 | GRMustacheErrorCodeTemplateNotFound,
61 | } GRMustacheErrorCode;
62 |
63 |
64 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheBundleTemplateLoader.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheBundleTemplateLoader_private.h"
24 |
25 |
26 | @implementation GRMustacheBundleTemplateLoader
27 |
28 | - (id)initWithBundle:(NSBundle *)theBundle extension:(NSString *)ext encoding:(NSStringEncoding)encoding {
29 | if ((self = [self initWithExtension:ext encoding:encoding])) {
30 | if (theBundle == nil) {
31 | theBundle = [NSBundle mainBundle];
32 | }
33 | bundle = [theBundle retain];
34 | }
35 | return self;
36 | }
37 |
38 | - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseTemplateId {
39 | return [bundle URLForResource:name withExtension:self.extension];
40 | }
41 |
42 | - (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError {
43 | NSAssert([templateId isKindOfClass:[NSURL class]], nil);
44 | return [NSString stringWithContentsOfURL:(NSURL*)templateId
45 | encoding:self.encoding
46 | error:outError];
47 | }
48 |
49 | - (void)dealloc {
50 | [bundle release];
51 | [super dealloc];
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheToken_private.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | typedef enum {
27 | GRMustacheTokenTypeText,
28 | GRMustacheTokenTypeComment,
29 | GRMustacheTokenTypeEscapedVariable,
30 | GRMustacheTokenTypeUnescapedVariable,
31 | GRMustacheTokenTypeSectionOpening,
32 | GRMustacheTokenTypeInvertedSectionOpening,
33 | GRMustacheTokenTypeSectionClosing,
34 | GRMustacheTokenTypePartial,
35 | GRMustacheTokenTypeSetDelimiter,
36 | } GRMustacheTokenType;
37 |
38 | @interface GRMustacheToken : NSObject {
39 | GRMustacheTokenType type;
40 | NSString *content;
41 | NSString *templateString;
42 | NSUInteger line;
43 | NSRange range;
44 | }
45 | @property (nonatomic, readonly) GRMustacheTokenType type;
46 | @property (nonatomic, readonly, retain) NSString *content;
47 | @property (nonatomic, readonly, retain) NSString *templateString;
48 | @property (nonatomic, readonly) NSUInteger line;
49 | @property (nonatomic, readonly) NSRange range;
50 | + (id)tokenWithType:(GRMustacheTokenType)type content:(NSString *)content templateString:(NSString *)templateString line:(NSUInteger)line range:(NSRange)range;
51 | @end
52 |
--------------------------------------------------------------------------------
/projects/ikhoyo-net/ikhoyo-net/IkhoyoInputStream.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoInputStream.h
15 | // ikhoyo-net
16 | //
17 | #import
18 |
19 | #undef IKHOYO_NSSTREAM_DELEGATE
20 | #if (TARGET_OS_MAC && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \
21 | (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 40000))
22 | #define IKHOYO_NSSTREAM_DELEGATE
23 | #else
24 | #define IKHOYO_NSSTREAM_DELEGATE
25 | #endif
26 |
27 | /*!
28 | ICSInputStream - Implements an array of NSInputStreams that look like a single input stream. Allows for
29 | very efficient streaming of data from multiple sources without having to copy the data to one NSData instance,
30 | or to a temporary file. Used by the IkhoyoURLManager in the upload implementation.
31 | */
32 | @interface IkhoyoInputStream : NSInputStream IKHOYO_NSSTREAM_DELEGATE {
33 | NSMutableArray* inputs; /**< The NSInputStream array. */
34 | NSUInteger currentInput; /**< The current NSInputStream index. */
35 | unsigned long long length; /**< The total length of the input stream. Calculated as streams area added. */
36 |
37 | id delegate; /**< Placeholder for the delegate used by NSInputStream subclasses. */
38 | NSInputStream* lastStream; /**< The last input stream. Used by overridden NSInputStream methods. */
39 | }
40 | @property (nonatomic) unsigned long long length;
41 | @property (nonatomic,retain) NSMutableArray* inputs;
42 | @property (nonatomic,retain) NSInputStream* lastStream;
43 |
44 | /*!
45 | Initialize the IkhoyoInputStream
46 | */
47 | - (id) init;
48 |
49 | /*!
50 | Add data to the input stream. Can either be an NSData instance, or an NSString that is the name of a file.
51 | */
52 | - (void) add:(id) data;
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoViewController.m
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoViewController.h"
22 | #import
23 |
24 | @implementation IkhoyoViewController
25 | @synthesize app;
26 | @synthesize ready;
27 | @synthesize backgroundGradientColor;
28 |
29 | - (void) applyBackgroundGradient {
30 | CAGradientLayer *gradient = [CAGradientLayer layer];
31 | gradient.frame = self.view.bounds;
32 | gradient.colors = [NSArray arrayWithObjects:(id)[self.backgroundGradientColor CGColor], (id)[[UIColor whiteColor] CGColor], nil];
33 | [self.view.layer insertSublayer:gradient atIndex:0];
34 | }
35 |
36 | - (void)dealloc
37 | {
38 | [super dealloc];
39 | }
40 |
41 | - (void)didReceiveMemoryWarning
42 | {
43 | [super didReceiveMemoryWarning];
44 | }
45 |
46 | - (void) observeReady {
47 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationReady:) name:@"IkhoyoReady" object:nil];
48 | }
49 |
50 | - (void) onReady {
51 | }
52 |
53 | - (void) doOnReady {
54 | if (self.ready) return;
55 | self.ready = YES;
56 | [self onReady];
57 | }
58 |
59 | - (void) notificationReady: (NSNotification*) not {
60 | self.app = [not object];
61 | [self doOnReady];
62 | }
63 |
64 | - (void)viewDidLoad
65 | {
66 | [super viewDidLoad];
67 | if (!self.app)
68 | self.app = (id)[UIApplication sharedApplication].delegate;
69 | [self observeReady];
70 | if ([self.app isIkhoyoReady])
71 | [self doOnReady];
72 | }
73 |
74 | - (void)viewDidUnload
75 | {
76 | [super viewDidUnload];
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheToken.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheToken_private.h"
24 |
25 |
26 | @interface GRMustacheToken()
27 | @property (nonatomic, retain) NSString *content;
28 | - (id)initWithType:(GRMustacheTokenType)type content:(NSString *)content templateString:(NSString *)templateString line:(NSUInteger)line range:(NSRange)range;
29 | @end
30 |
31 | @implementation GRMustacheToken
32 | @synthesize type;
33 | @synthesize content;
34 | @synthesize templateString;
35 | @synthesize line;
36 | @synthesize range;
37 |
38 | + (id)tokenWithType:(GRMustacheTokenType)type content:(NSString *)content templateString:(NSString *)templateString line:(NSUInteger)line range:(NSRange)range {
39 | return [[[self alloc] initWithType:type content:content templateString:templateString line:line range:range] autorelease];
40 | }
41 |
42 | - (id)initWithType:(GRMustacheTokenType)theType content:(NSString *)theContent templateString:(NSString *)theTemplateString line:(NSUInteger)theLine range:(NSRange)theRange {
43 | if ((self = [self init])) {
44 | type = theType;
45 | content = [theContent retain];
46 | templateString = [theTemplateString retain];
47 | line = theLine;
48 | range = theRange;
49 | }
50 | return self;
51 | }
52 |
53 | - (void)dealloc {
54 | [content release];
55 | [templateString release];
56 | [super dealloc];
57 | }
58 |
59 | @end
60 |
61 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheVersion.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustache.h"
24 |
25 |
26 | /**
27 | The major component of GRMustache version
28 |
29 | @since v1.0.0
30 | */
31 | #define GRMUSTACHE_MAJOR_VERSION 1
32 |
33 | /**
34 | The minor component of GRMustache version
35 |
36 | @since v1.0.0
37 | */
38 | #define GRMUSTACHE_MINOR_VERSION 3
39 |
40 | /**
41 | The patch-level component of GRMustache version
42 |
43 | @since v1.0.0
44 | */
45 | #define GRMUSTACHE_PATCH_VERSION 2
46 |
47 |
48 | /**
49 | A C struct that hold GRMustache version information
50 |
51 | @since v1.0.0
52 | */
53 | typedef struct {
54 | int major; /**< The major component of the version. */
55 | int minor; /**< The minor component of the version. */
56 | int patch; /**< The patch-level component of the version. */
57 | } GRMustacheVersion;
58 |
59 | /**
60 | Adds version method to the GRMustache class.
61 |
62 | @since v1.0.0
63 | */
64 | @interface GRMustache(Version)
65 |
66 | //////////////////////////////////////////////////////////////////////////////////////////
67 | /// @name Getting the GRMustache version
68 | //////////////////////////////////////////////////////////////////////////////////////////
69 |
70 | /**
71 | @returns the version of GRMustache as a GRMustacheVersion.
72 |
73 | @since v1.0.0
74 | */
75 | + (GRMustacheVersion)version;
76 | @end
77 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustache.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustache_private.h"
24 | #import "GRMustacheLambda_private.h"
25 |
26 |
27 | static BOOL strictBooleanMode = NO;
28 |
29 | // support for deprecated [GRNo no];
30 | @interface GRNo()
31 | + (GRYes *)_no;
32 | @end
33 |
34 | @implementation GRMustache
35 |
36 | + (BOOL)strictBooleanMode {
37 | return strictBooleanMode;
38 | }
39 |
40 | + (void)setStrictBooleanMode:(BOOL)aBool {
41 | strictBooleanMode = aBool;
42 | }
43 |
44 | + (BOOL)objectIsFalseValue:(id)object {
45 | return (object == nil ||
46 | object == [NSNull null] ||
47 | object == [GRNo _no] ||
48 | (void *)object == (void *)kCFBooleanFalse ||
49 | ([object isKindOfClass:[NSString class]] && ((NSString*)object).length == 0));
50 | }
51 |
52 | + (GRMustacheObjectKind)objectKind:(id)object {
53 | if ([self objectIsFalseValue:object]) {
54 | return GRMustacheObjectKindFalseValue;
55 | }
56 |
57 | if ([object isKindOfClass:[NSDictionary class]])
58 | {
59 | return GRMustacheObjectKindTrueValue;
60 | }
61 |
62 | if ([object conformsToProtocol:@protocol(NSFastEnumeration)])
63 | {
64 | return GRMustacheObjectKindEnumerable;
65 | }
66 |
67 | if ([object isKindOfClass:[GRMustacheLambdaWrapper class]])
68 | {
69 | return GRMustacheObjectKindLambda;
70 | }
71 |
72 | return GRMustacheObjectKindTrueValue;
73 | }
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheSection.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheSection_private.h"
24 |
25 |
26 | @interface GRMustacheSection()
27 | @property (nonatomic, retain) NSString *name;
28 | @property (nonatomic, retain) NSString *templateString;
29 | @property (nonatomic) BOOL inverted;
30 | @property (nonatomic, retain) NSArray *elems;
31 | - (id)initWithName:(NSString *)name string:(NSString *)templateString inverted:(BOOL)inverted elements:(NSArray *)elems;
32 | @end
33 |
34 |
35 | @implementation GRMustacheSection
36 | @synthesize templateString;
37 | @synthesize name;
38 | @synthesize inverted;
39 | @synthesize elems;
40 |
41 | + (id)sectionElementWithName:(NSString *)name string:(NSString *)templateString inverted:(BOOL)inverted elements:(NSArray *)elems {
42 | return [[[self alloc] initWithName:name string:templateString inverted:inverted elements:elems] autorelease];
43 | }
44 |
45 | - (id)initWithName:(NSString *)theName string:(NSString *)theTemplateString inverted:(BOOL)theInverted elements:(NSArray *)theElems {
46 | if ((self = [self init])) {
47 | self.name = theName;
48 | self.templateString = theTemplateString;
49 | self.inverted = theInverted;
50 | self.elems = theElems;
51 | }
52 | return self;
53 | }
54 |
55 | - (void)dealloc {
56 | [name release];
57 | [templateString release];
58 | [elems release];
59 | [super dealloc];
60 | }
61 |
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/NSDate+TKCategory.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDateAdditions.h
3 | // Created by Devin Ross on 7/28/09.
4 | //
5 | /*
6 |
7 | tapku.com || http://github.com/devinross/tapkulibrary
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 |
30 | */
31 | #import
32 |
33 |
34 | @interface NSDate (TKCategory)
35 |
36 | struct TKDateInformation {
37 | int day;
38 | int month;
39 | int year;
40 |
41 | int weekday;
42 |
43 | int minute;
44 | int hour;
45 | int second;
46 |
47 | };
48 | typedef struct TKDateInformation TKDateInformation;
49 |
50 | - (TKDateInformation) dateInformation;
51 | - (TKDateInformation) dateInformationWithTimeZone:(NSTimeZone*)tz;
52 | + (NSDate*) dateFromDateInformation:(TKDateInformation)info;
53 | + (NSDate*) dateFromDateInformation:(TKDateInformation)info timeZone:(NSTimeZone*)tz;
54 |
55 |
56 |
57 |
58 |
59 | @property (readonly,nonatomic) NSString *month;
60 | @property (readonly,nonatomic) NSString *year;
61 | @property (readonly,nonatomic) int weekdayWithMondayFirst;
62 | @property (readonly,nonatomic) BOOL isToday;
63 |
64 |
65 | - (BOOL) isSameDay:(NSDate*)anotherDate;
66 | - (int) differenceInDaysTo:(NSDate *)toDate;
67 | - (int) differenceInMonthsTo:(NSDate *)toDate;
68 | - (int) daysBetweenDate:(NSDate*)d;
69 |
70 |
71 | - (NSString*) dateDescription;
72 | - (NSDate *) dateByAddingDays:(NSUInteger)days;
73 | + (NSDate *) dateWithDatePart:(NSDate *)aDate andTimePart:(NSDate *)aTime;
74 | + (NSString*) dateInformationDescriptionWithInformation:(TKDateInformation)info;
75 |
76 |
77 | + (NSDate*) yesterday;
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRBoolean.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | /**
26 | The GRYes class provides with a singleton which you can use as a true value
27 | when controlling Mustache boolean sections.
28 |
29 | This singleton object is safer and less ambiguous than [NSNumber numberWithBool:YES],
30 | which GRMustache essentially considers as the integer 1.
31 |
32 | @see GRYes#yes
33 | @see GRMustache#strictBooleanMode
34 | @see GRNo
35 | @since v1.0.0
36 | */
37 | @interface GRYes : NSObject
38 | /**
39 | @deprecated Use `[NSNumber numberWithBool:YES]` instead.
40 | @returns the GRYes singleton.
41 | @since v1.0.0
42 | */
43 | + (GRYes *)yes __attribute__((deprecated));
44 |
45 | /**
46 | @returns YES
47 | @since v1.1.0
48 | */
49 | - (BOOL)boolValue;
50 | @end
51 |
52 |
53 | /**
54 | The GRNo class provides with a singleton which you can use as a false value
55 | when controlling Mustache boolean sections.
56 |
57 | This singleton object is safer and less ambiguous than [NSNumber numberWithBool:NO],
58 | which GRMustache essentially considers as the integer 0, and not as a false
59 | value.
60 |
61 | @see GRNo#no
62 | @see GRMustache#strictBooleanMode
63 | @see GRYes
64 | @since v1.0.0
65 | */
66 | @interface GRNo : NSObject
67 | /**
68 | @deprecated Use `[NSNumber numberWithBool:NO]` instead.
69 | @returns the GRNo singleton.
70 | @since v1.0.0
71 | */
72 | + (GRNo *)no __attribute__((deprecated));
73 |
74 | /**
75 | @returns NO
76 | @since v1.1.0
77 | */
78 | - (BOOL)boolValue;
79 | @end
80 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/SocrataTableViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SocrataTableViewController.m
3 | // ikhoyo-top
4 | //
5 | // Created by William Donahue on 6/27/11.
6 | // Copyright 2011 Ikhoyo. All rights reserved.
7 | //
8 |
9 | #import "SocrataTableViewController.h"
10 | #import "IkhoyoAppDelegate.h"
11 |
12 | @interface Socrata : NSObject {
13 | NSString* name;
14 | }
15 | @property (nonatomic,retain) NSString* name;
16 | @end
17 |
18 | @implementation Socrata
19 | @synthesize name;
20 | @end
21 |
22 | @implementation SocrataTableViewController
23 | @synthesize rows;
24 |
25 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
26 | {
27 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
28 | if (self) {
29 | // Custom initialization
30 | }
31 | return self;
32 | }
33 |
34 | - (void)dealloc
35 | {
36 | [super dealloc];
37 | }
38 |
39 | - (void)didReceiveMemoryWarning
40 | {
41 | [super didReceiveMemoryWarning];
42 | }
43 |
44 | #pragma mark - View lifecycle
45 |
46 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
47 | - (void)viewDidLoad
48 | {
49 | self.rows = [[[NSMutableArray alloc] initWithCapacity:16] autorelease];
50 | [super viewDidLoad];
51 | }
52 |
53 | - (void)viewDidUnload
54 | {
55 | [super viewDidUnload];
56 | }
57 |
58 | - (void) observeReady {
59 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationReady:) name:@"IkhoyoSocrataReady" object:nil];
60 | }
61 |
62 | - (void) onReady {
63 | NSString* q = @"SELECT name FROM n5m4_msim";
64 | IkhoyoAppDelegate* d = (IkhoyoAppDelegate*) self.app;
65 | [d.db query:q usingClass:@"Socrata" withBlock:^(id obj) {
66 | NSMutableArray* names = (NSMutableArray*) obj;
67 | for (int i=0;i<[names count];i++) {
68 | Socrata* socrata = [names objectAtIndex:i];
69 | [self.rows addObject:socrata.name];
70 | }
71 | [self.tableView reloadData];
72 | }];
73 | }
74 |
75 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
76 | return 1;
77 | }
78 |
79 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
80 | return [self.rows count];
81 | }
82 |
83 | - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
84 | static NSString *CellIdentifier = @"Cell";
85 |
86 | UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
87 | if (cell == nil) {
88 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
89 | }
90 |
91 | cell.textLabel.text = [rows objectAtIndex:indexPath.row];
92 |
93 | return cell;
94 | }
95 |
96 |
97 | @end
98 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustache.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | /**
26 | The GRMustache class provides with global-level information and configuration
27 | of the GRMustache library.
28 | @since v1.0.0
29 | */
30 | @interface GRMustache: NSObject
31 |
32 | //////////////////////////////////////////////////////////////////////////////////////////
33 | /// @name Handling of boolean properties
34 | //////////////////////////////////////////////////////////////////////////////////////////
35 |
36 | /**
37 | A Boolean value that determines whether GRMustache renders templates in strict
38 | boolean mode.
39 |
40 | @returns YES if GRMustache renders templates in strict boolean mode,
41 | NO otherwise. The default value is NO.
42 |
43 | In strict boolean mode, properties of context objects that are declared as BOOL
44 | are interpreted as numbers, and can not be used for controlling Mustache
45 | boolean sections.
46 |
47 | In non-strict boolean mode, all properties declared as signed char (including
48 | those declared as BOOL), are interpreted as booleans, and can be used for
49 | controlling Mustache boolean sections.
50 |
51 | @see GRMustache#setStrictBooleanMode:
52 | @see GRYes
53 | @see GRNo
54 | @since v1.0.0
55 | */
56 | + (BOOL)strictBooleanMode;
57 |
58 | /**
59 | Sets the strict boolean mode of GMustache.
60 |
61 | @param aBool YES if GRMustache should render templates in strict boolean mode,
62 | NO otherwise.
63 |
64 | @see GRMustache#strictBooleanMode
65 | @since v1.0.0
66 | */
67 | + (void)setStrictBooleanMode:(BOOL)aBool;
68 | @end
69 |
70 | #import "GRMustacheVersion.h"
71 | #import "GRBoolean.h"
72 | #import "GRMustacheError.h"
73 | #import "GRMustacheRendering.h"
74 | #import "GRMustacheLambda.h"
75 | #import "GRMustacheTemplateLoader.h"
76 | #import "GRMustacheTemplate.h"
77 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/DetailViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // DetailViewController.m
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "DetailViewController.h"
22 | #import "RootViewController.h"
23 |
24 | @implementation DetailViewController
25 | @synthesize rootViewController;
26 |
27 | - (void) observeDetailNotifications {
28 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationAddTab:) name:@"IkhoyoDetailAddTab" object:nil];
29 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationRemoveTab:) name:@"IkhoyoDetailRemoveTab" object:nil];
30 | }
31 |
32 | - (void)viewWillAppear:(BOOL)animated
33 | {
34 | [super viewWillAppear:animated];
35 | }
36 |
37 | - (void)viewDidAppear:(BOOL)animated
38 | {
39 | [super viewDidAppear:animated];
40 | }
41 |
42 | - (void)viewWillDisappear:(BOOL)animated
43 | {
44 | [super viewWillDisappear:animated];
45 | }
46 |
47 | - (void)viewDidDisappear:(BOOL)animated
48 | {
49 | [super viewDidDisappear:animated];
50 | }
51 |
52 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
53 | return YES;
54 | }
55 |
56 | #pragma mark - Split view support
57 |
58 | - (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc
59 | {
60 | }
61 |
62 | // Called when the view is shown again in the split view, invalidating the button and popover controller.
63 | - (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
64 | {
65 | }
66 |
67 | /*
68 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
69 | - (void)viewDidLoad
70 | {
71 | [super viewDidLoad];
72 | }
73 | */
74 |
75 | - (void)viewDidUnload
76 | {
77 | [super viewDidUnload];
78 | }
79 |
80 | #pragma mark - Memory management
81 |
82 | - (void)didReceiveMemoryWarning
83 | {
84 | // Releases the view if it doesn't have a superview.
85 | [super didReceiveMemoryWarning];
86 |
87 | // Release any cached data, images, etc that aren't in use.
88 | }
89 |
90 | - (void)dealloc
91 | {
92 | [rootViewController release];
93 | [super dealloc];
94 | }
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoTableViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // IkhoyoTableViewController.m
3 | // ikhoyo-ui
4 | //
5 | // Created by William Donahue on 6/9/11.
6 | // Copyright 2011 Ikhoyo. All rights reserved.
7 | //
8 |
9 | #import "IkhoyoTableViewController.h"
10 |
11 | @implementation IkhoyoTableViewController
12 | @synthesize tableView;
13 | @synthesize addItemViewController;
14 |
15 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
16 | {
17 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
18 | if (self) {
19 | // Custom initialization
20 | }
21 | return self;
22 | }
23 |
24 | - (void)dealloc
25 | {
26 | [tableView release];
27 | [super dealloc];
28 | }
29 |
30 | - (void)didReceiveMemoryWarning
31 | {
32 | // Releases the view if it doesn't have a superview.
33 | [super didReceiveMemoryWarning];
34 |
35 | // Release any cached data, images, etc that aren't in use.
36 | }
37 |
38 | #pragma mark - View lifecycle
39 |
40 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
41 | - (void)viewDidLoad
42 | {
43 | [super viewDidLoad];
44 | self.tableView.backgroundView.alpha = 0; // Fixes a bug on the iPad
45 | self.tableView.backgroundColor = [UIColor clearColor]; // Fixes a bug on the iPhone
46 | [self applyBackgroundGradient];
47 | }
48 |
49 | - (void) addItem:(IkhoyoAddItemViewController*) ctlr {
50 |
51 | }
52 |
53 | - (IBAction) addAction:(id) sender {
54 | if (self.addItemViewController)
55 | [self.navigationController pushViewController:self.addItemViewController animated:YES];
56 | }
57 |
58 | - (IBAction) addItemDone:(id) sender {
59 | [self addItem:self.addItemViewController];
60 | [self.navigationController popViewControllerAnimated:YES];
61 | }
62 |
63 | - (IBAction) addItemCancel:(id) sender {
64 | [self.navigationController popViewControllerAnimated:YES];
65 | }
66 |
67 | - (IBAction) editAction:(id) sender {
68 | self.editing = !self.editing;
69 | [self setEditing:self.editing animated:YES];
70 | }
71 |
72 | - (void)viewDidUnload
73 | {
74 | [super viewDidUnload];
75 | // Release any retained subviews of the main view.
76 | // e.g. self.myOutlet = nil;
77 | }
78 |
79 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
80 | {
81 | return 0;
82 | }
83 |
84 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
85 | {
86 | return 0;
87 | }
88 |
89 | - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
90 | {
91 | static NSString *CellIdentifier = @"Cell";
92 |
93 | UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
94 | if (cell == nil) {
95 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
96 | }
97 |
98 | return cell;
99 | }
100 |
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/projects/ikhoyo-sqlite/ikhoyo-sqlite/IkhoyoDatabase.h:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoViewDatabase.h
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import
22 | #import "IkhoyoThread.h"
23 |
24 | @class IkhoyoDatabase;
25 | @interface IkhoyoStatement : NSObject {
26 | void* h;
27 | Class cls;
28 | NSMutableArray* rows;
29 | IkhoyoDatabase* database;
30 | }
31 | @property (nonatomic,retain) Class cls;
32 | @property (nonatomic,retain) NSMutableArray* rows;
33 | @property (nonatomic,retain) IkhoyoDatabase* database;
34 |
35 | + (NSDate*) toDate:(double) secs;
36 | + (double) fromDate:(NSDate*) date;
37 |
38 | - (id) count;
39 | - (Boolean) hasRowAtOffset:(NSUInteger) offset;
40 | - (Boolean) hasRowsAtOffset:(NSUInteger) offset andLimit:(NSUInteger) limit;
41 |
42 | @end
43 |
44 | @interface IkhoyoDatabase : NSObject {
45 | void* h;
46 | NSString* path;
47 | IkhoyoThread* worker;
48 | }
49 | @property (nonatomic) void* h;
50 | @property (nonatomic,retain) NSString* path;
51 | @property (nonatomic,retain) IkhoyoThread* worker;
52 |
53 | - (id) initWithPath:(NSString*)path;
54 | - (id) initWithPath:(NSString*)path usingThread:(IkhoyoThread*) thread;
55 |
56 | - (void) open:(IkhoyoBlock) block;
57 | - (void) close:(IkhoyoBlock) block;
58 | - (IkhoyoError*) sqliteError:(NSString*) msg;
59 | - (void) execOnMainThread:(IkhoyoBlock) block;
60 | - (void) execOnDatabaseThread:(IkhoyoBlock) block;
61 | - (void) insertOrUpdate:(NSString*) st withBlock:(IkhoyoBlock) block;
62 | - (void) count:(IkhoyoStatement*) stmt withBlock:(IkhoyoBlock) block;
63 | - (void) exec:(IkhoyoStatement*) select withBlock:(IkhoyoBlock) block;
64 | - (id) execFromDatabaseThread:(NSString*) sql withArgs:(NSArray*) args;
65 | - (void) count:(NSString*) sql args:(NSArray*) args withBlock:(IkhoyoBlock) block;
66 | - (void) exec:(NSString*) st withArgs:(NSArray*) args withBlock:(IkhoyoBlock) block;
67 | - (void) query:(NSString*) query usingClass:(NSString*) cls withBlock:(IkhoyoBlock) block;
68 | - (void) rebind:(IkhoyoStatement*) stmt args:(NSArray*) args withBlock:(IkhoyoBlock) block;
69 | - (void) insertOrUpdate:(NSString*) st withArgs:(NSArray*) args withBlock:(IkhoyoBlock) block;
70 | - (void) prepare:(NSString*) sql args:(NSArray*) args usingClass:(NSString*) cls withBlock:(IkhoyoBlock) block;
71 | - (void) select:(IkhoyoStatement*) select offset:(NSUInteger) offset limit:(NSUInteger) limit withBlock:(IkhoyoBlock) block;
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoDynamicTabBarController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoDynamicTabBarController.m
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoDynamicTabBarController.h"
22 | #import "IkhoyoDynamicTabViewController.h"
23 |
24 | @implementation IkhoyoDynamicTabBarController
25 | @synthesize tabs;
26 |
27 | - (void)dealloc
28 | {
29 | [tabs release];
30 | [super dealloc];
31 | }
32 |
33 | - (void)didReceiveMemoryWarning
34 | {
35 | [super didReceiveMemoryWarning];
36 | }
37 |
38 |
39 | - (IkhoyoDynamicTabViewController*) hasTab:(NSString*) name {
40 | IkhoyoDynamicTabViewController* tab;
41 | NSEnumerator* e = [self.tabs objectEnumerator];
42 | while ((tab=[e nextObject])) {
43 | if ([tab.name isEqualToString:name])
44 | return tab;
45 | }
46 | return nil;
47 | }
48 |
49 | - (IkhoyoDynamicTabViewController*) addTab:(NSString*) name withClass:(NSString*) c andImage:(UIImage*) image andParam:(id) param {
50 | IkhoyoDynamicTabViewController* ctlr = [self hasTab:name];
51 | if (!ctlr) {
52 | Class cls = NSClassFromString(c);
53 | ctlr = [[[cls alloc] initWithNibName:c bundle:nil] autorelease];
54 | ctlr.name = name;
55 | [ctlr view]; // Needed to force wiring in some cases
56 | ctlr.root.tabBarItem.title = name;
57 | if (image)
58 | ctlr.root.tabBarItem.image = image;
59 | NSMutableArray * vcs = [NSMutableArray arrayWithArray:[self viewControllers]];
60 | [tabs addObject:ctlr];
61 | [vcs addObject:ctlr.root];
62 | [self setViewControllers:vcs animated:NO];
63 | }
64 | [self setSelectedViewController:ctlr.root];
65 | [ctlr start:param];
66 | return ctlr;
67 | }
68 |
69 | - (void) removeTab:(IkhoyoDynamicTabViewController*) ctlr {
70 | NSMutableArray * vcs = [NSMutableArray arrayWithArray:[self viewControllers]];
71 | [vcs removeObject:ctlr];
72 | [self.tabs removeObject:ctlr];
73 | [self setViewControllers:vcs animated:NO];
74 | }
75 |
76 | #pragma mark - View lifecycle
77 |
78 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
79 | - (void)viewDidLoad
80 | {
81 | [super viewDidLoad];
82 | self.tabs = [[[NSMutableArray alloc] init] autorelease];
83 | }
84 |
85 | - (void)viewDidUnload
86 | {
87 | [super viewDidUnload];
88 | }
89 |
90 | @end
91 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplate.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplate_private.h"
24 | #import "GRMustacheContext.h"
25 | #import "GRMustacheTemplateLoader_private.h"
26 | #import "GRMustacheDirectoryTemplateLoader_private.h"
27 | #import "GRMustacheRendering_private.h"
28 |
29 |
30 | @interface GRMustacheTemplate()
31 | - (id)initWithElements:(NSArray *)theElems;
32 | @end
33 |
34 | @implementation GRMustacheTemplate
35 | @synthesize elems;
36 |
37 |
38 | + (id)parseString:(NSString *)templateString error:(NSError **)outError {
39 | return [[GRMustacheTemplateLoader templateLoaderWithBundle:[NSBundle mainBundle]]
40 | parseString:templateString
41 | error:outError];
42 | }
43 |
44 | + (id)parseContentsOfURL:(NSURL *)url error:(NSError **)outError {
45 | id loader = [GRMustacheTemplateLoader templateLoaderWithBaseURL:[url URLByDeletingLastPathComponent] extension:[url pathExtension]];
46 | NSAssert([loader isKindOfClass:[GRMustacheDirectoryTemplateLoader class]], nil);
47 | return [(GRMustacheDirectoryTemplateLoader *)loader parseContentsOfURL:url error:outError];
48 | }
49 |
50 | + (id)parseResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError {
51 | return [[GRMustacheTemplateLoader templateLoaderWithBundle:bundle]
52 | parseTemplateNamed:name
53 | error:outError];
54 | }
55 |
56 | + (id)parseResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError {
57 | return [[GRMustacheTemplateLoader templateLoaderWithBundle:bundle extension:ext]
58 | parseTemplateNamed:name
59 | error:outError];
60 | }
61 |
62 | + (id)templateWithElements:(NSArray *)elems {
63 | return [[[self alloc] initWithElements:elems] autorelease];
64 | }
65 |
66 | - (id)initWithElements:(NSArray *)theElems {
67 | if ((self = [self init])) {
68 | self.elems = theElems;
69 | }
70 | return self;
71 | }
72 |
73 | - (void)dealloc {
74 | [elems release];
75 | [super dealloc];
76 | }
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRBoolean.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRBoolean.h"
24 |
25 |
26 | static GRYes *yes = nil;
27 |
28 | @implementation GRYes
29 |
30 | + (GRYes *)_yes {
31 | if (yes == nil) {
32 | yes = [[super allocWithZone:NULL] init];
33 | }
34 | return yes;
35 | }
36 |
37 | + (GRYes *)yes {
38 | return [self _yes];
39 | }
40 |
41 | + (id)allocWithZone:(NSZone *)zone {
42 | return [[self _yes] retain];
43 | }
44 |
45 | - (id)copyWithZone:(NSZone *)zone {
46 | return self;
47 | }
48 |
49 | - (id)retain {
50 | return self;
51 | }
52 |
53 | - (NSUInteger)retainCount {
54 | return NSUIntegerMax; //denotes an object that cannot be released
55 | }
56 |
57 | - (void)release {
58 | //do nothing
59 | }
60 |
61 | - (id)autorelease {
62 | return self;
63 | }
64 |
65 | - (id)valueForKey:(NSString *)key {
66 | return nil;
67 | }
68 |
69 | - (BOOL)boolValue {
70 | return YES;
71 | }
72 |
73 | - (NSString *)description {
74 | return @"(yes)";
75 | }
76 |
77 | @end
78 |
79 | static GRNo *no = nil;
80 |
81 | @implementation GRNo
82 |
83 | + (GRNo *)_no {
84 | if (no == nil) {
85 | no = [[super allocWithZone:NULL] init];
86 | }
87 | return no;
88 | }
89 |
90 | + (GRNo *)no {
91 | return [self _no];
92 | }
93 |
94 | + (id)allocWithZone:(NSZone *)zone {
95 | return [[self _no] retain];
96 | }
97 |
98 | - (id)copyWithZone:(NSZone *)zone {
99 | return self;
100 | }
101 |
102 | - (id)retain {
103 | return self;
104 | }
105 |
106 | - (NSUInteger)retainCount {
107 | return NSUIntegerMax; //denotes an object that cannot be released
108 | }
109 |
110 | - (void)release {
111 | //do nothing
112 | }
113 |
114 | - (id)autorelease {
115 | return self;
116 | }
117 |
118 | - (id)valueForKey:(NSString *)key {
119 | return nil;
120 | }
121 |
122 | - (BOOL)boolValue {
123 | return NO;
124 | }
125 |
126 | - (NSString *)description {
127 | return @"(no)";
128 | }
129 |
130 | @end
131 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheDirectoryTemplateLoader.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheDirectoryTemplateLoader_private.h"
24 |
25 |
26 | @implementation GRMustacheDirectoryTemplateLoader
27 |
28 | - (id)initWithURL:(NSURL *)theURL extension:(NSString *)ext encoding:(NSStringEncoding)encoding {
29 | if ((self = [super initWithExtension:ext encoding:encoding])) {
30 | url = [theURL retain];
31 | }
32 | return self;
33 | }
34 |
35 | - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseTemplateId {
36 | if (baseTemplateId) {
37 | NSAssert([baseTemplateId isKindOfClass:[NSURL class]], nil);
38 | if (self.extension.length == 0) {
39 | return [[NSURL URLWithString:name relativeToURL:(NSURL *)baseTemplateId] URLByStandardizingPath];
40 | }
41 | return [[NSURL URLWithString:[name stringByAppendingPathExtension:self.extension] relativeToURL:(NSURL *)baseTemplateId] URLByStandardizingPath];
42 | }
43 | if (self.extension.length == 0) {
44 | return [[url URLByAppendingPathComponent:name] URLByStandardizingPath];
45 | }
46 | return [[[url URLByAppendingPathComponent:name] URLByAppendingPathExtension:self.extension] URLByStandardizingPath];
47 | }
48 |
49 | - (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError {
50 | NSAssert([templateId isKindOfClass:[NSURL class]], nil);
51 | return [NSString stringWithContentsOfURL:(NSURL*)templateId
52 | encoding:self.encoding
53 | error:outError];
54 | }
55 |
56 | - (GRMustacheTemplate *)parseContentsOfURL:(NSURL *)templateURL error:(NSError **)outError {
57 | NSString *templateString = [NSString stringWithContentsOfURL:templateURL encoding:self.encoding error:outError];
58 | if (!templateString) {
59 | return nil;
60 | }
61 | GRMustacheTemplate *template = [self parseString:templateString error:outError];
62 | if (!template) {
63 | return nil;
64 | }
65 | [self setTemplate:template forTemplateId:templateURL];
66 | return template;
67 | }
68 |
69 | - (void)dealloc {
70 | [url release];
71 | [super dealloc];
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/projects/ikhoyo-sqlite/ikhoyo-sqlite/IkhoyoThread.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoThread.m
15 | // ikhoyo-sqlite
16 | //
17 | // Created by William Donahue on 5/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoThread.h"
22 |
23 | @implementation IkhoyoError
24 | @synthesize msg;
25 |
26 | - (void)dealloc {
27 | [msg release];
28 | msg = nil;
29 | [super dealloc];
30 | }
31 |
32 | - (id) initWithFormat:(NSString*) fmt, ... {
33 | self = [super init];
34 | if (self) {
35 | va_list args;
36 | va_start(args,fmt);
37 | msg = [[NSString alloc] initWithFormat:fmt arguments:args];
38 | va_end(args);
39 | }
40 | return self;
41 | }
42 |
43 | @end
44 |
45 |
46 | @implementation IkhoyoTask
47 | @synthesize obj;
48 | @synthesize main;
49 | @synthesize task;
50 |
51 | - (void) dealloc {
52 | [task release];
53 | [super dealloc];
54 | }
55 |
56 | @end
57 |
58 | @implementation IkhoyoThread
59 | @synthesize worker;
60 |
61 | - (void) dealloc {
62 | [worker release];
63 | worker = nil;
64 | [super dealloc];
65 | }
66 |
67 | - (void) performBlock:(IkhoyoBlock)task withObject:(id) obj onMainThread:(Boolean) main {
68 | IkhoyoTask* tb = [[[IkhoyoTask alloc] init] autorelease];
69 | tb.obj = obj;
70 | tb.main = main;
71 | tb.task = task;
72 | NSThread* thread = main ? [NSThread mainThread] : self.worker;
73 | [self performSelector:@selector(startTask:) onThread:thread withObject:tb waitUntilDone:NO];
74 | }
75 |
76 | - (void) performBlock:(IkhoyoBlock)task {
77 | [self performBlock:task withObject:nil];
78 | }
79 |
80 | - (void) performBlockOnMainThread:(IkhoyoBlock)task {
81 | [self performBlockOnMainThread:task withObject:nil];
82 | }
83 |
84 | - (void) performBlock:(IkhoyoBlock)task withObject:(id) obj {
85 | [self performBlock:task withObject:obj onMainThread:NO];
86 | }
87 |
88 | - (void) performBlockOnMainThread:(IkhoyoBlock)task withObject:(id) obj {
89 | [self performBlock:task withObject:obj onMainThread:YES];
90 | }
91 |
92 | - (void) startTask:(IkhoyoTask*) tb {
93 | tb.task(tb.obj);
94 | }
95 |
96 | - (void) start {
97 | self.worker = [[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil];
98 | [self.worker start];
99 | }
100 |
101 | - (void) run {
102 | [self.worker setThreadPriority:0];
103 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
104 | [[NSRunLoop currentRunLoop] addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
105 | while(![self.worker isCancelled]) {
106 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
107 | [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
108 | [pool drain];
109 | }
110 | [pool drain];
111 | }
112 |
113 | @end
114 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/ikhoyo-ui/IkhoyoWebViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoWebViewController.m
15 | // ikhoyo-ui
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoWebViewController.h"
22 | #import "GRMustache.h"
23 |
24 | @implementation IkhoyoWebViewController
25 | @synthesize url;
26 | @synthesize baseUrl;
27 | @synthesize webView;
28 | @synthesize context;
29 | @synthesize baseDir;
30 |
31 | - (id)initWithNibName:(NSString*) nibNameOrNil bundle:(NSBundle*) nibBundleOrNil {
32 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
33 | if (self) {
34 | }
35 | return self;
36 | }
37 |
38 | - (void)dealloc {
39 | [url release];
40 | [context release];
41 | [baseDir release];
42 | [webView stopLoading];
43 | [webView release];
44 | [super dealloc];
45 | }
46 |
47 | - (void)didReceiveMemoryWarning
48 | {
49 | [super didReceiveMemoryWarning];
50 | }
51 |
52 | - (void)viewDidLoad
53 | {
54 | [super viewDidLoad];
55 | if (!self.context)
56 | self.context = [[[IkhoyoWebViewContext alloc] init] autorelease];
57 | }
58 |
59 | - (void)viewDidUnload
60 | {
61 | [super viewDidUnload];
62 | }
63 |
64 | - (NSString*) executeTemplate:(NSString*) path {
65 | NSError* error;
66 | NSStringEncoding enc;
67 | NSString* template = [NSString stringWithContentsOfFile:path usedEncoding:&enc error:&error];
68 | NSString* result = [GRMustacheTemplate renderObject:self.context fromString:template error:&error];
69 | return result;
70 | }
71 |
72 | - (NSString*) convert:(NSString*) p useBaseDirectory:(Boolean) useBase {
73 | NSString* file = useBase ? [self.baseDir stringByAppendingPathComponent:p] : p;
74 | return [self executeTemplate:file];
75 | }
76 |
77 | - (void) handle:(NSString*) path withMimeType:(NSString*) mime useBaseDirectory:(Boolean) usebase {
78 | NSString* ml = [self convert:path useBaseDirectory:usebase];
79 | NSData* data = [ml dataUsingEncoding:NSUTF8StringEncoding];
80 | [self.webView loadData:data MIMEType:mime textEncodingName:@"utf-8" baseURL:self.baseUrl];
81 | }
82 |
83 | - (void) start:(NSString*) dir{
84 | self.baseDir = dir;
85 | self.baseUrl = [NSURL fileURLWithPath:self.baseDir];
86 | [self handle:@"index.xml" withMimeType:@"text/xml" useBaseDirectory:YES];
87 | }
88 |
89 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
90 | }
91 |
92 | - (BOOL) webView:(UIWebView*) wv shouldStartLoadWithRequest:(NSURLRequest*) request navigationType:(UIWebViewNavigationType)navigationType {
93 | self.url = [request URL];
94 | if (navigationType==UIWebViewNavigationTypeLinkClicked) {
95 | if ([url isFileURL]) {
96 | NSString* path = [url path];
97 | NSString* selStr = [[@"handle_" stringByAppendingString: [path pathExtension]] stringByAppendingString:@":"];
98 | SEL selector = NSSelectorFromString(selStr);
99 | [self performSelector:selector withObject:path];
100 | return NO;
101 | }
102 | [[UIApplication sharedApplication] openURL:[request URL]];
103 | } else if ([url isFileURL])
104 | return YES;
105 | return NO;
106 | }
107 |
108 | - (void) handle_xml:(NSString*) path {
109 | [self handle:path withMimeType:@"text/xml" useBaseDirectory:NO];
110 | }
111 |
112 | - (void) handle_html:(NSString*) path {
113 | [self handle:path withMimeType:@"text/html" useBaseDirectory:NO];
114 | }
115 |
116 | @end
117 |
--------------------------------------------------------------------------------
/projects/ikhoyo-top/ikhoyo-top/IkhoyoHomeTableViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoHomeTableViewController.m
15 | // ikhoyo-top
16 | //
17 | // Created by William Donahue on 5/25/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoHomeTableViewController.h"
22 | #import "IkhoyoWebViewController.h"
23 |
24 | @implementation IkhoyoHomeTableViewController
25 | @synthesize rows;
26 | @synthesize webAppController;
27 | @synthesize webAppDictionaries;
28 | @synthesize detailViewController;
29 |
30 | - (void)dealloc
31 | {
32 | [rows release];
33 | [webAppDictionaries release];
34 | [detailViewController release];
35 | [super dealloc];
36 | }
37 |
38 | - (void)didReceiveMemoryWarning
39 | {
40 | [super didReceiveMemoryWarning];
41 | }
42 |
43 | #pragma mark - View lifecycle
44 |
45 | - (void)viewDidLoad
46 | {
47 | [super viewDidLoad];
48 | self.rows = [[[NSMutableArray alloc] init] autorelease];
49 | self.webAppDictionaries = [[[NSMutableArray alloc] init] autorelease];
50 |
51 | [self.rows addObject:@"Sample Web View"];
52 | [self.rows addObject:@"Socrata Table"];
53 | UIImage* image = [UIImage imageNamed:@"www.png"];
54 | NSString* dir = [[[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"xcode-resources"] stringByAppendingPathComponent:@"webviews"] stringByAppendingPathComponent:@"sample-web-view"];
55 | [self.webAppDictionaries addObject:[NSDictionary dictionaryWithObjectsAndKeys:dir,@"dir",image,@"image", nil]];
56 | }
57 |
58 | - (void) onReady {
59 | NSString* dir = [[[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"xcode-resources"] stringByAppendingPathComponent:@"webviews"] stringByAppendingPathComponent:@"home"];
60 | [self.webAppController start:dir];
61 | }
62 |
63 | - (void)viewDidUnload
64 | {
65 | [super viewDidUnload];
66 | }
67 |
68 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
69 | {
70 | return 1;
71 | }
72 |
73 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
74 | {
75 | return [self.rows count];
76 | }
77 |
78 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
79 | return @"Local Web Apps";
80 | }
81 |
82 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
83 | {
84 | static NSString *CellIdentifier = @"Cell";
85 |
86 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
87 | if (cell == nil) {
88 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
89 | }
90 |
91 | cell.textLabel.text = [self.rows objectAtIndex:indexPath.row];
92 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
93 |
94 | return cell;
95 | }
96 |
97 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
98 | int iweb = [self.webAppDictionaries count];
99 | if (indexPath.row
24 |
25 |
26 | /**
27 | The GRMustacheTemplate class provides with Mustache template rendering services.
28 |
29 | @since v1.0.0
30 | */
31 | @interface GRMustacheTemplate: NSObject {
32 | @private
33 | NSArray *elems;
34 | }
35 |
36 | //////////////////////////////////////////////////////////////////////////////////////////
37 | /// @name Parsing
38 | //////////////////////////////////////////////////////////////////////////////////////////
39 |
40 | /**
41 | Parses a template string, and returns a compiled template.
42 |
43 | @returns A GRMustacheTemplate instance
44 | @param templateString The template string
45 | @param outError If there is an error loading or parsing template and partials, upon return
46 | contains an NSError object that describes the problem.
47 |
48 | @since v1.0.0
49 | */
50 | + (id)parseString:(NSString *)templateString error:(NSError **)outError;
51 |
52 | /**
53 | Parses a template file, and returns a compiled template.
54 |
55 | @returns A GRMustacheTemplate instance
56 | @param url The URL of the template
57 | @param outError If there is an error loading or parsing template and partials, upon return
58 | contains an NSError object that describes the problem.
59 |
60 | The template at url must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
61 |
62 | @since v1.0.0
63 | */
64 | + (id)parseContentsOfURL:(NSURL *)url error:(NSError **)outError;
65 |
66 | /**
67 | Parses a bundle resource template, and returns a compiled template.
68 |
69 | @returns A GRMustacheTemplate instance
70 | @param name The name of a bundle resource of extension "mustache"
71 | @param bundle The bundle where to look for the template resource
72 | @param outError If there is an error loading or parsing template and partials, upon return
73 | contains an NSError object that describes the problem.
74 |
75 | If you provide nil as a bundle, the resource will be looked in the main bundle.
76 |
77 | The template resource must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
78 |
79 | @since v1.0.0
80 | */
81 | + (id)parseResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError;
82 |
83 | /**
84 | Parses a bundle resource template, and returns a compiled template.
85 |
86 | @returns A GRMustacheTemplate instance
87 | @param name The name of a bundle resource
88 | @param ext The extension of the bundle resource
89 | @param bundle The bundle where to look for the template resource
90 | @param outError If there is an error loading or parsing template and partials, upon return
91 | contains an NSError object that describes the problem.
92 |
93 | If you provide nil as a bundle, the resource will be looked in the main bundle.
94 |
95 | The template resource must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
96 |
97 | @since v1.0.0
98 | */
99 | + (id)parseResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError;
100 | @end
101 |
--------------------------------------------------------------------------------
/projects/ikhoyo-net/ikhoyo-net/IkhoyoInputStream.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoInputStream.m
15 | // ikhoyo-net
16 | //
17 |
18 | #import "IkhoyoInputStream.h"
19 |
20 | @implementation IkhoyoInputStream
21 | @synthesize inputs;
22 | @synthesize length;
23 | @synthesize lastStream;
24 |
25 | - (void) dealloc {
26 | [inputs release];
27 | [lastStream release];
28 | [super dealloc];
29 | }
30 |
31 | - (id) init {
32 | if ((self=[super init])) {
33 | length = 0;
34 | inputs = [[NSMutableArray alloc] init];
35 | [self setDelegate:self];
36 | }
37 | return self;
38 | }
39 |
40 | - (id) addData:(NSData*) data {
41 | NSInputStream* istr = [[NSInputStream alloc] initWithData:data];
42 | length += [data length];
43 | return istr;
44 | }
45 |
46 | - (id) addFile:(NSString*) file {
47 | NSInputStream* istr = [[NSInputStream alloc] initWithFileAtPath:file];
48 | NSDictionary* attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:file error:NULL];
49 | length += [[attrs valueForKey:NSFileSize] unsignedLongLongValue];
50 | return istr;
51 | }
52 |
53 | - (void) add:(id) data {
54 | NSInputStream* input = [data isKindOfClass:[NSData class]] ? [self addData:data] : [self addFile:data];
55 | [self.inputs addObject:input];
56 | self.lastStream = input;
57 | [input release];
58 | }
59 |
60 | - (BOOL) hasBytesAvailable {
61 | return [lastStream hasBytesAvailable];
62 | }
63 |
64 | - (BOOL) getBuffer:(uint8_t**) buffer length:(NSUInteger*)len {
65 | return NO;
66 | }
67 |
68 | - (NSInteger) read:(uint8_t*) buffer maxLength:(NSUInteger)len {
69 | NSInteger total = 0;
70 | while (total0) total += read;
74 | if (read<=0) currentInput++;
75 | }
76 | return total;
77 | }
78 |
79 | - (NSStreamStatus) streamStatus {
80 | return [lastStream streamStatus];
81 | }
82 |
83 | - (NSError*) streamError {
84 | return [lastStream streamError];
85 | }
86 |
87 | - (void) open {
88 | for (NSInputStream* input in inputs)
89 | [input open];
90 | }
91 |
92 | - (void) close {
93 | for (NSInputStream* input in inputs)
94 | [input close];
95 | }
96 |
97 | - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent {
98 | if (delegate!=self) {
99 | [delegate stream:self handleEvent:streamEvent];
100 | }
101 | }
102 |
103 | - (id) delegate {
104 | return delegate;
105 | }
106 |
107 | - (id) propertyForKey:(NSString*)key {
108 | return [lastStream propertyForKey:key];
109 | }
110 |
111 | - (BOOL) setProperty:(id)property forKey:(NSString*)key {
112 | return [lastStream setProperty:property forKey:key];
113 | }
114 |
115 | - (void) scheduleInRunLoop:(NSRunLoop*)runLoop forMode:(NSString*)mode {
116 | [lastStream scheduleInRunLoop:runLoop forMode:mode];
117 | }
118 |
119 | - (void) removeFromRunLoop:(NSRunLoop*)runLoop forMode:(NSString*)mode {
120 | [lastStream removeFromRunLoop:runLoop forMode:mode];
121 | }
122 |
123 | + (NSMethodSignature*)methodSignatureForSelector:(SEL)selector {
124 | return [NSInputStream methodSignatureForSelector:selector];
125 | }
126 |
127 | + (void)forwardInvocation:(NSInvocation*)invocation {
128 | [invocation invokeWithTarget:[NSInputStream class]];
129 | }
130 |
131 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
132 | {
133 | return [lastStream methodSignatureForSelector:aSelector];
134 | }
135 |
136 | - (void)forwardInvocation:(NSInvocation *)anInvocation
137 | {
138 | [anInvocation invokeWithTarget:lastStream];
139 | }
140 |
141 | - (void) setDelegate:(id) del {
142 | if (delegate==nil) {
143 | delegate = self;
144 | [lastStream setDelegate:nil];
145 | } else {
146 | delegate = del;
147 | [lastStream setDelegate:self];
148 | }
149 | }
150 |
151 | @end
152 |
--------------------------------------------------------------------------------
/projects/ikhoyo-socrata/ikhoyo-socrata/IkhoyoSocrata.m:
--------------------------------------------------------------------------------
1 | //
2 | // Licensed under the Apache License, Version 2.0 (the "License");
3 | // you may not use this file except in compliance with the License.
4 | // You may obtain a copy of the License at
5 | //
6 | // http://www.apache.org/licenses/LICENSE-2.0
7 | //
8 | // Unless required by applicable law or agreed to in writing, software
9 | // distributed under the License is distributed on an "AS IS" BASIS,
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | // See the License for the specific language governing permissions and
12 | // limitations under the License.
13 | //
14 | // IkhoyoSocrata.m
15 | // ikhoyo-socrata
16 | //
17 | // Created by William Donahue on 6/24/11.
18 | // Copyright 2011 Ikhoyo. All rights reserved.
19 | //
20 |
21 | #import "IkhoyoSocrata.h"
22 |
23 | @implementation IkhoyoSocrata
24 | @synthesize tasks;
25 | @synthesize baseURL;
26 | @synthesize viewURL;
27 | @synthesize dataType;
28 | @synthesize urlManager;
29 | @synthesize appTokenQS;
30 |
31 | - (id) initWithURLManager:(id) um {
32 | return [self initWithURLManager:um andApiKey:nil];
33 | }
34 |
35 | - (id) initWithURLManager:(id) um andApiKey:(NSString*) apiKey {
36 | return [self initWithURLManager:um andApiKey:nil andDataType:@"json"];
37 | }
38 |
39 | - (id) initWithURLManager:(id) um andApiKey:(NSString*) apiKey andDataType:(NSString*) dt {
40 | if ((self=[super init])) {
41 | self.dataType = dt;
42 | self.urlManager = um;
43 | if (apiKey)
44 | self.appTokenQS = [@"app_token=" stringByAppendingString:apiKey];
45 | self.baseURL = @"http://opendata.socrata.com/api";
46 | self.viewURL = [self.baseURL stringByAppendingString:@"/views/"];
47 | self.tasks = [[[NSMutableArray alloc] init] autorelease];
48 | }
49 | return self;
50 | }
51 |
52 | - (void) get:(NSString*) ds withBlock:(IkhoyoBlock) block {
53 | return [self get:ds maxRows:0 withBlock:block];
54 | }
55 |
56 | - (void) getMeta:(NSString*) ds withBlock:(IkhoyoBlock) block {
57 | NSString* sep = @"?";
58 | NSString* url = [[[viewURL stringByAppendingString:ds] stringByAppendingString:@"."] stringByAppendingString:self.dataType];
59 | if (self.appTokenQS) {
60 | url = [[url stringByAppendingString:sep] stringByAppendingString:ds];
61 | sep = @"&";
62 | }
63 |
64 | id task = [self.urlManager load:[NSURL URLWithString:url] delegate:self];
65 | IkhoyoTask* tb = [[IkhoyoTask alloc] init];
66 | tb.obj = task;
67 | tb.task = block;
68 | [self.tasks addObject:tb];
69 | }
70 |
71 | - (void) get:(NSString*) ds maxRows:(int)max withBlock:(IkhoyoBlock) block {
72 | NSString* sep = @"?";
73 | NSString* url = [[[viewURL stringByAppendingString:ds] stringByAppendingString:@"/rows."] stringByAppendingString:self.dataType];
74 | if (self.appTokenQS) {
75 | url = [[url stringByAppendingString:sep] stringByAppendingString:ds];
76 | sep = @"&";
77 | }
78 | if (max>0) {
79 | url = [[url stringByAppendingString:sep] stringByAppendingFormat:@"max_rows=%d",max];
80 | sep = @"&";
81 | }
82 |
83 | id task = [self.urlManager load:[NSURL URLWithString:url] delegate:self];
84 | IkhoyoTask* tb = [[IkhoyoTask alloc] init];
85 | tb.obj = task;
86 | tb.task = block;
87 | [self.tasks addObject:tb];
88 | }
89 |
90 | - (NSString*) convertData:(NSData*) data {
91 | return [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding: NSUTF8StringEncoding] autorelease];
92 | }
93 |
94 | -(void) urlTaskFailed:(IkhoyoURLTask*) task {
95 | [self performSelectorOnMainThread:@selector(taskFailed:) withObject:task waitUntilDone:NO];
96 | }
97 |
98 | -(void) urlTaskSuccessful:(IkhoyoURLTask*) task {
99 | [self performSelectorOnMainThread:@selector(taskDone:) withObject:task waitUntilDone:NO];
100 | }
101 |
102 | - (IkhoyoTask*) getTask:(IkhoyoURLTask*) urlTask {
103 | for (int i=0;i<[self.tasks count];i++) {
104 | IkhoyoTask* task = [self.tasks objectAtIndex:i];
105 | if (task.obj==urlTask)
106 | return task;
107 | }
108 | return nil;
109 | }
110 |
111 | - (void) taskFailed:(IkhoyoURLTask*) urlTask {
112 | IkhoyoTask* task = [self getTask:urlTask];
113 | task.task(urlTask);
114 | [task release];
115 | }
116 |
117 | - (void) taskDone:(IkhoyoURLTask*) urlTask {
118 | IkhoyoTask* task = [self getTask:urlTask];
119 | IkhoyoURLTaskLoad* taskLoad = (IkhoyoURLTaskLoad*) urlTask;
120 | task.task([self convertData:taskLoad.data]);
121 | [task release];
122 | }
123 |
124 | @end
125 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplateLoader_protected.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import "GRMustacheTemplateLoader.h"
25 |
26 |
27 | /**
28 | Class extension exposed to the subclasses of GRMustacheTemplateLoader.
29 |
30 | @since v1.0.0
31 | */
32 | @interface GRMustacheTemplateLoader()
33 |
34 | /**
35 | The extension of loaded templates (if applicable).
36 |
37 | This property is never nil, but may contain an empty NSString.
38 |
39 | @see GRMustacheTemplateLoader#initWithExtension:encoding:
40 | @since v1.0.0
41 | */
42 | @property (nonatomic, readonly, copy) NSString *extension;
43 |
44 | /**
45 | The encoding of data containing templates (if applicable)
46 |
47 | @see GRMustacheTemplateLoader#initWithExtension:encoding:
48 | @since v1.0.0
49 | */
50 | @property (nonatomic, readonly) NSStringEncoding encoding;
51 |
52 | /**
53 | The designated GRMustacheTemplateLoader initializer.
54 |
55 | Don't use this method unless you implement a GRMustacheTemplateLoader subclass.
56 |
57 | @returns a GRMustacheTemplateLoader instance.
58 | @param ext The file name extension of loaded templates.
59 | @param encoding The encoding of data containing templates.
60 |
61 | The returned template loader will load templates with the provided file
62 | name extension, and interpret any template data with the provided encoding.
63 |
64 | If the ext parameter is nil, the "mustache" extension will be assumed.
65 |
66 | If the ext parameter is the empty string, loaded partials won't have any extension.
67 |
68 | For initializing GRMustacheTemplateLoader subclasses which ignore extensions or
69 | encoding, you may pass any value in those parameters.
70 |
71 | @see GRMustacheTemplateLoader#templateStringForTemplateId:error:
72 | @since v1.0.0
73 | */
74 | - (id)initWithExtension:(NSString *)ext encoding:(NSStringEncoding)encoding;
75 |
76 | /**
77 | Don't use this method.
78 |
79 | Subclasses must override it.
80 |
81 | @returns a template identifier
82 | @param name The name of a partial or a template
83 | @param baseTemplateId The identifier of the template refering to the name
84 |
85 | Your subclass will return a template identifier, that is to say an object which
86 | uniquely identifies a template. There must not be two identifiers for a single
87 | template.
88 |
89 | If the baseTemplateId parameter is nil, then the name parameter refers to a
90 | "root template". Otherwise, the name parameter refers to the name of a partial
91 | loaded from the template identified by baseTemplateId.
92 |
93 | @since v1.0.0
94 | */
95 | - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseTemplateId;
96 |
97 | /**
98 | Don't use this method.
99 |
100 | Subclasses must override it.
101 |
102 | @returns A template string
103 | @param templateId A template identifier
104 | @param outError If there is an error building the template string, upon return
105 | contains an NSError object that describes the problem.
106 |
107 | Your subclass will return the string of the template identified by templateId.
108 |
109 | If applicable, your implementation will use the extension and encoding properties.
110 |
111 | @see GRMustacheTemplateLoader#extension
112 | @see GRMustacheTemplateLoader#encoding
113 |
114 | @since v1.0.0
115 | */
116 | // Override this method, and return a template string.
117 | // If applicable, it is your responsability to use the extension property in order to load the correct template.
118 | - (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError;
119 | @end
120 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheRendering.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheTemplate.h"
24 | #import "GRMustacheSection.h"
25 |
26 |
27 | @interface GRMustacheSection(Rendering)
28 | - (NSString *)renderObject:(id)object;
29 | @end
30 |
31 | @interface GRMustacheTemplate(Rendering)
32 |
33 | //////////////////////////////////////////////////////////////////////////////////////////
34 | /// @name Rendering
35 | //////////////////////////////////////////////////////////////////////////////////////////
36 |
37 | /**
38 | Renders a context object from a template string
39 |
40 | @returns A string containing the rendered template
41 | @param object A context object used for interpreting Mustache tags
42 | @param templateString The template string
43 | @param outError If there is an error loading or parsing template and partials, upon return
44 | contains an NSError object that describes the problem.
45 |
46 | @since v1.0.0
47 | */
48 | + (NSString *)renderObject:(id)object fromString:(NSString *)templateString error:(NSError **)outError;
49 |
50 | /**
51 | Renders a context object from a file template.
52 |
53 | @returns A string containing the rendered template
54 | @param object A context object used for interpreting Mustache tags
55 | @param url The URL of the template
56 | @param outError If there is an error loading or parsing template and partials, upon return
57 | contains an NSError object that describes the problem.
58 |
59 | The template at url must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
60 |
61 | @since v1.0.0
62 | */
63 | + (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url error:(NSError **)outError;
64 |
65 | /**
66 | Renders a context object from a bundle resource template.
67 |
68 | @returns A string containing the rendered template
69 | @param object A context object used for interpreting Mustache tags
70 | @param name The name of a bundle resource of extension "mustache"
71 | @param bundle The bundle where to look for the template resource
72 | @param outError If there is an error loading or parsing template and partials, upon return
73 | contains an NSError object that describes the problem.
74 |
75 | If you provide nil as a bundle, the resource will be looked in the main bundle.
76 |
77 | The template resource must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
78 |
79 | @since v1.0.0
80 | */
81 | + (NSString *)renderObject:(id)object fromResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError;
82 |
83 | /**
84 | Renders a context object from a bundle resource template.
85 |
86 | @returns A string containing the rendered template
87 | @param object A context object used for interpreting Mustache tags
88 | @param name The name of a bundle resource
89 | @param ext The extension of the bundle resource
90 | @param bundle The bundle where to look for the template resource.
91 | @param outError If there is an error loading or parsing template and partials, upon return
92 | contains an NSError object that describes the problem.
93 |
94 | If you provide nil as a bundle, the resource will be looked in the main bundle.
95 |
96 | The template resource must be encoded in UTF8. See the GRMustacheTemplateLoader class for more encoding options.
97 |
98 | @since v1.0.0
99 | */
100 | + (NSString *)renderObject:(id)object fromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError;
101 |
102 | /**
103 | Renders a template with a context object.
104 |
105 | @returns A string containing the rendered template
106 | @param object A context object used for interpreting Mustache tags
107 |
108 | @since v1.0.0
109 | */
110 | - (NSString *)renderObject:(id)object;
111 |
112 | /**
113 | Renders a template without any context object for interpreting Mustache tags.
114 |
115 | @returns A string containing the rendered template
116 |
117 | @since v1.0.0
118 | */
119 | - (NSString *)render;
120 |
121 | @end
122 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheLambda.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import "GRMustacheLambda_private.h"
25 | #import "GRMustacheRendering.h"
26 |
27 | @implementation GRMustacheLambdaWrapper
28 |
29 | - (NSString *)renderObject:(id)context withSection:(GRMustacheSection *)section {
30 | return @"";
31 | }
32 |
33 | @end
34 |
35 |
36 | @interface GRMustacheLambdaSelectorWrapper()
37 | - (id)initWithObject:(id)object selector:(SEL)renderingSelector;
38 | @end
39 |
40 |
41 | @implementation GRMustacheLambdaSelectorWrapper
42 |
43 | + (id)helperWithObject:(id)object selector:(SEL)renderingSelector {
44 | return [[[self alloc] initWithObject:object selector:renderingSelector] autorelease];
45 | }
46 |
47 | - (id)initWithObject:(id)theObject selector:(SEL)theRenderingSelector {
48 | if ((self = [self init])) {
49 | object = [theObject retain];
50 | renderingSelector = theRenderingSelector;
51 | }
52 | return self;
53 | }
54 |
55 | - (void)dealloc {
56 | [object release];
57 | [super dealloc];
58 | }
59 |
60 | - (NSString *)renderObject:(id)context withSection:(GRMustacheSection *)section {
61 | NSString *result = objc_msgSend(object, renderingSelector, section, context);
62 | if (result == nil) {
63 | return @"";
64 | }
65 | return result;
66 | }
67 |
68 | @end
69 |
70 |
71 | #if NS_BLOCKS_AVAILABLE
72 |
73 | @interface GRMustacheDeprecatedLambdaBlockWrapper: GRMustacheLambdaWrapper {
74 | @private
75 | NSString *(^block)(NSString *(^)(id object), id, NSString *);
76 | }
77 | + (id)lambdaWithBlock:(NSString *(^)(NSString *(^)(id object), id, NSString *))block;
78 | - (id)initWithBlock:(NSString *(^)(NSString *(^)(id object), id, NSString *))block;
79 | @end
80 |
81 |
82 | @implementation GRMustacheDeprecatedLambdaBlockWrapper
83 |
84 | + (id)lambdaWithBlock:(NSString *(^)(NSString *(^)(id object), id, NSString *))block {
85 | return [[[self alloc] initWithBlock:block] autorelease];
86 | }
87 |
88 | - (id)initWithBlock:(NSString *(^)(NSString *(^)(id object), id, NSString *))theBlock {
89 | if ((self = [self init])) {
90 | block = [theBlock copy];
91 | }
92 | return self;
93 | }
94 |
95 | - (NSString *)renderObject:(id)context withSection:(GRMustacheSection *)section {
96 | NSString *result = block(^(id object){ return [section renderObject:object]; }, context, section.templateString);
97 | if (result == nil) {
98 | return @"";
99 | }
100 | return result;
101 | }
102 |
103 | - (NSString *)description {
104 | return @"";
105 | }
106 |
107 | - (void)dealloc {
108 | [block release];
109 | [super dealloc];
110 | }
111 |
112 | @end
113 |
114 |
115 | id GRMustacheLambdaMake(NSString *(^block)(NSString *(^)(id object), id, NSString *)) {
116 | return [GRMustacheDeprecatedLambdaBlockWrapper lambdaWithBlock:block];
117 | }
118 |
119 |
120 | @interface GRMustacheLambdaBlockWrapper: GRMustacheLambdaWrapper {
121 | @private
122 | GRMustacheRenderingBlock block;
123 | }
124 | + (id)lambdaWithBlock:(GRMustacheRenderingBlock)block;
125 | - (id)initWithBlock:(GRMustacheRenderingBlock)block;
126 | @end
127 |
128 |
129 | @implementation GRMustacheLambdaBlockWrapper
130 |
131 | + (id)lambdaWithBlock:(GRMustacheRenderingBlock)block {
132 | return [[(GRMustacheLambdaBlockWrapper *)[self alloc] initWithBlock:block] autorelease];
133 | }
134 |
135 | - (id)initWithBlock:(GRMustacheRenderingBlock)theBlock {
136 | if ((self = [self init])) {
137 | block = [theBlock copy];
138 | }
139 | return self;
140 | }
141 |
142 | - (NSString *)renderObject:(id)context withSection:(GRMustacheSection *)section {
143 | NSString *result = block(section, context);
144 | if (result == nil) {
145 | return @"";
146 | }
147 | return result;
148 | }
149 |
150 | - (NSString *)description {
151 | return @"";
152 | }
153 |
154 | - (void)dealloc {
155 | [block release];
156 | [super dealloc];
157 | }
158 |
159 | @end
160 |
161 |
162 | id GRMustacheLambdaBlockMake(GRMustacheRenderingBlock block) {
163 | return [GRMustacheLambdaBlockWrapper lambdaWithBlock:block];
164 | }
165 | #endif
166 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/NSString+TKCategory.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSStringAddition.m
3 | // Created by Devin Ross on 10/26/09.
4 | //
5 | /*
6 |
7 | tapku.com || http://github.com/devinross/tapkulibrary
8 |
9 | Permission is hereby granted, free of charge, to any person
10 | obtaining a copy of this software and associated documentation
11 | files (the "Software"), to deal in the Software without
12 | restriction, including without limitation the rights to use,
13 | copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the
15 | Software is furnished to do so, subject to the following
16 | conditions:
17 |
18 | The above copyright notice and this permission notice shall be
19 | included in all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 | OTHER DEALINGS IN THE SOFTWARE.
29 |
30 | */
31 |
32 | #import "NSString+TKCategory.h"
33 |
34 | @implementation NSString (TKCategory)
35 |
36 |
37 | -(BOOL) isEmail{
38 |
39 | NSString *emailRegEx =
40 | @"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"
41 | @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
42 | @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
43 | @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
44 | @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
45 | @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
46 | @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
47 |
48 | NSPredicate *regExPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegEx];
49 | return [regExPredicate evaluateWithObject:[self lowercaseString]];
50 | }
51 |
52 |
53 | - (NSString*) URLEncode{
54 | NSString* encodedString = (NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL,(CFStringRef)@":/=,!$&'()*+;[]@#?", kCFStringEncodingUTF8);
55 | return [NSMakeCollectable(encodedString) autorelease];
56 | }
57 |
58 |
59 |
60 | - (NSString *) escapeHTML{
61 | NSMutableString *s = [NSMutableString string];
62 |
63 | int start = 0;
64 | int len = [self length];
65 | NSCharacterSet *chs = [NSCharacterSet characterSetWithCharactersInString:@"<>&\""];
66 |
67 | while (start < len) {
68 | NSRange r = [self rangeOfCharacterFromSet:chs options:0 range:NSMakeRange(start, len-start)];
69 | if (r.location == NSNotFound) {
70 | [s appendString:[self substringFromIndex:start]];
71 | break;
72 | }
73 |
74 | if (start < r.location) {
75 | [s appendString:[self substringWithRange:NSMakeRange(start, r.location-start)]];
76 | }
77 |
78 | switch ([self characterAtIndex:r.location]) {
79 | case '<':
80 | [s appendString:@"<"];
81 | break;
82 | case '>':
83 | [s appendString:@">"];
84 | break;
85 | case '"':
86 | [s appendString:@"""];
87 | break;
88 | // case '…':
89 | // [s appendString:@"…"];
90 | // break;
91 | case '&':
92 | [s appendString:@"&"];
93 | break;
94 | }
95 |
96 | start = r.location + 1;
97 | }
98 |
99 | return s;
100 | }
101 |
102 |
103 | - (NSString *) unescapeHTML{
104 | NSMutableString *s = [NSMutableString string];
105 | NSMutableString *target = [[self mutableCopy] autorelease];
106 | NSCharacterSet *chs = [NSCharacterSet characterSetWithCharactersInString:@"&"];
107 |
108 | while ([target length] > 0) {
109 | NSRange r = [target rangeOfCharacterFromSet:chs];
110 | if (r.location == NSNotFound) {
111 | [s appendString:target];
112 | break;
113 | }
114 |
115 | if (r.location > 0) {
116 | [s appendString:[target substringToIndex:r.location]];
117 | [target deleteCharactersInRange:NSMakeRange(0, r.location)];
118 | }
119 |
120 | if ([target hasPrefix:@"<"]) {
121 | [s appendString:@"<"];
122 | [target deleteCharactersInRange:NSMakeRange(0, 4)];
123 | } else if ([target hasPrefix:@">"]) {
124 | [s appendString:@">"];
125 | [target deleteCharactersInRange:NSMakeRange(0, 4)];
126 | } else if ([target hasPrefix:@"""]) {
127 | [s appendString:@"\""];
128 | [target deleteCharactersInRange:NSMakeRange(0, 6)];
129 | } else if ([target hasPrefix:@"'"]) {
130 | [s appendString:@"'"];
131 | [target deleteCharactersInRange:NSMakeRange(0, 5)];
132 | } else if ([target hasPrefix:@"&"]) {
133 | [s appendString:@"&"];
134 | [target deleteCharactersInRange:NSMakeRange(0, 5)];
135 | } else if ([target hasPrefix:@"…"]) {
136 | [s appendString:@"…"];
137 | [target deleteCharactersInRange:NSMakeRange(0, 8)];
138 | } else {
139 | [s appendString:@"&"];
140 | [target deleteCharactersInRange:NSMakeRange(0, 1)];
141 | }
142 | }
143 |
144 | return s;
145 | }
146 |
147 |
148 |
149 | @end
150 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplateLoader.h:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 |
26 | @class GRMustacheTemplate;
27 |
28 | /**
29 | The GRMustacheTemplateLoader provides with template loading services.
30 |
31 | @since v1.0.0
32 | */
33 | @interface GRMustacheTemplateLoader: NSObject {
34 | @private
35 | NSString *extension;
36 | NSStringEncoding encoding;
37 | NSMutableDictionary *templatesById;
38 | }
39 |
40 | /**
41 | @returns A GRMustacheTemplateLoader instance
42 | @param url The url of a directory
43 |
44 | The returned template loader will load templates and partials from the provided directory url,
45 | with extension "mustache", encoded in UTF8.
46 |
47 | @since v1.0.0
48 | */
49 | + (id)templateLoaderWithBaseURL:(NSURL *)url;
50 |
51 | /**
52 | @returns A GRMustacheTemplateLoader instance
53 | @param url The url of a directory
54 | @param ext The file name extension of loaded templates.
55 |
56 | The returned template loader will load templates and partials from the provided directory url,
57 | with provided extension, encoded in UTF8.
58 |
59 | If the ext parameter is nil, the "mustache" extension will be assumed.
60 |
61 | If the ext parameter is the empty string, loaded partials won't have any extension.
62 |
63 | @since v1.0.0
64 | */
65 | + (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext;
66 |
67 | /**
68 | @returns A GRMustacheTemplateLoader instance
69 | @param url The url of a directory
70 | @param ext The file name extension of loaded templates.
71 | @param encoding The encoding of template files.
72 |
73 | The returned template loader will load templates and partials from the provided directory url,
74 | with provided extension, encoded in provided encoding.
75 |
76 | If the ext parameter is nil, the "mustache" extension will be assumed.
77 |
78 | If the ext parameter is the empty string, loaded partials won't have any extension.
79 |
80 | @since v1.0.0
81 | */
82 | + (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
83 |
84 | /**
85 | @returns A GRMustacheTemplateLoader instance
86 | @param bundle A bundle
87 |
88 | The returned template loader will load templates and partials from the provided bundle,
89 | with extension "mustache", encoded in UTF8.
90 |
91 | @since v1.0.0
92 | */
93 | + (id)templateLoaderWithBundle:(NSBundle *)bundle;
94 |
95 | /**
96 | @returns A GRMustacheTemplateLoader instance
97 | @param bundle A bundle
98 | @param ext The extension of loaded templates.
99 |
100 | The returned template loader will load templates and partials from the provided bundle,
101 | with provided extension, encoded in UTF8.
102 |
103 | If the ext parameter is nil, the "mustache" extension will be assumed.
104 |
105 | @since v1.0.0
106 | */
107 | + (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext;
108 |
109 | /**
110 | @returns A GRMustacheTemplateLoader instance
111 | @param bundle A bundle
112 | @param ext The extension of loaded templates.
113 | @param encoding The encoding of template resources.
114 |
115 | The returned template loader will load templates and partials from the provided bundle,
116 | with provided extension, encoded in the provided encoding.
117 |
118 | If the ext parameter is nil, the "mustache" extension will be assumed.
119 |
120 | @since v1.0.0
121 | */
122 | + (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext encoding:(NSStringEncoding)encoding;
123 |
124 | /**
125 | @returns a GRMustacheTemplate instance
126 | @param name The name of the template
127 | @param outError If there is an error loading or parsing the template, upon return
128 | contains an NSError object that describes the problem.
129 |
130 | Loads, parses, and returns the template of provided name.
131 |
132 | @since v1.0.0
133 | */
134 | - (GRMustacheTemplate *)parseTemplateNamed:(NSString *)name error:(NSError **)outError;
135 |
136 | /**
137 | @returns a GRMustacheTemplate instance
138 | @param templateString The template string
139 | @param outError If there is an error parsing the template string or loading a partial, upon return
140 | contains an NSError object that describes the problem.
141 |
142 | Parses the template string, and returns a GRMustacheTemplate instance.
143 |
144 | @since v1.0.0
145 | */
146 | - (GRMustacheTemplate *)parseString:(NSString *)templateString error:(NSError **)outError;
147 | @end
148 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheRendering.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustacheRendering_private.h"
24 | #import "GRMustacheSection_private.h"
25 | #import "GRMustacheTextElement_private.h"
26 | #import "GRMustacheVariableElement_private.h"
27 | #import "GRMustacheContext.h"
28 | #import "GRMustacheLambda_private.h"
29 | #import "GRMustache_private.h"
30 |
31 |
32 | @implementation GRMustacheTemplate(Rendering)
33 |
34 | + (NSString *)renderObject:(id)object fromString:(NSString *)templateString error:(NSError **)outError {
35 | GRMustacheTemplate *template = [GRMustacheTemplate parseString:templateString error:outError];
36 | if (template == nil) {
37 | return nil;
38 | }
39 | return [template renderObject:object];
40 | }
41 |
42 | + (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url error:(NSError **)outError {
43 | GRMustacheTemplate *template = [GRMustacheTemplate parseContentsOfURL:url error:outError];
44 | if (template == nil) {
45 | return nil;
46 | }
47 | return [template renderObject:object];
48 | }
49 |
50 | + (NSString *)renderObject:(id)object fromResource:(NSString *)name bundle:(NSBundle *)bundle error:(NSError **)outError {
51 | GRMustacheTemplate *template = [GRMustacheTemplate parseResource:name bundle:bundle error:outError];
52 | if (template == nil) {
53 | return nil;
54 | }
55 | return [template renderObject:object];
56 | }
57 |
58 | + (NSString *)renderObject:(id)object fromResource:(NSString *)name withExtension:(NSString *)ext bundle:(NSBundle *)bundle error:(NSError **)outError {
59 | GRMustacheTemplate *template = [GRMustacheTemplate parseResource:name withExtension:ext bundle:bundle error:outError];
60 | if (template == nil) {
61 | return nil;
62 | }
63 | return [template renderObject:object];
64 | }
65 |
66 | - (NSString *)render {
67 | return [self renderObject:nil];
68 | }
69 |
70 | - (NSString *)renderObject:(id)object {
71 | return [self renderContext:[GRMustacheContext contextWithObject:object]];
72 | }
73 |
74 | @end
75 |
76 | @implementation GRMustacheSection(Rendering)
77 |
78 | - (NSString *)renderObject:(id)object {
79 | GRMustacheContext *context = [GRMustacheContext contextWithObject:object];
80 | NSMutableString *buffer = [NSMutableString string];
81 | for (id elem in elems) {
82 | [buffer appendString:[elem renderContext:context]];
83 | }
84 | return buffer;
85 | }
86 |
87 | @end
88 |
89 | @implementation GRMustacheSection(PrivateRendering)
90 |
91 | - (NSString *)renderContext:(GRMustacheContext *)context {
92 | id value = [context valueForKey:name];
93 | NSMutableString *buffer= [NSMutableString stringWithCapacity:1024];
94 |
95 | switch([GRMustache objectKind:value]) {
96 | case GRMustacheObjectKindFalseValue:
97 | if (inverted) {
98 | for (id elem in elems) {
99 | [buffer appendString:[elem renderContext:context]];
100 | }
101 | }
102 | break;
103 |
104 | case GRMustacheObjectKindTrueValue:
105 | if (!inverted) {
106 | GRMustacheContext *innerContext = [context contextByAddingObject:value];
107 | for (id elem in elems) {
108 | [buffer appendString:[elem renderContext:innerContext]];
109 | }
110 | }
111 | break;
112 |
113 | case GRMustacheObjectKindEnumerable:
114 | if (inverted) {
115 | BOOL empty = YES;
116 | for (id object in value) {
117 | empty = NO;
118 | break;
119 | }
120 | if (empty) {
121 | for (id elem in elems) {
122 | [buffer appendString:[elem renderContext:context]];
123 | }
124 | }
125 | } else {
126 | for (id object in value) {
127 | GRMustacheContext *innerContext = [context contextByAddingObject:object];
128 | for (id elem in elems) {
129 | [buffer appendString:[elem renderContext:innerContext]];
130 | }
131 | }
132 | }
133 | break;
134 |
135 | case GRMustacheObjectKindLambda:
136 | if (!inverted) {
137 | [buffer appendString:[(GRMustacheLambdaWrapper *)value renderObject:context withSection:self]];
138 | }
139 | break;
140 |
141 | default:
142 | // should not be here
143 | NSAssert(NO, nil);
144 | }
145 |
146 | return buffer;
147 | }
148 |
149 | @end
150 |
151 | @implementation GRMustacheTemplate(PrivateRendering)
152 |
153 | - (NSString *)renderContext:(GRMustacheContext *)context {
154 | if (elems == nil) {
155 | return @"";
156 | }
157 | NSMutableString *buffer = [NSMutableString string];
158 | for (id elem in elems) {
159 | [buffer appendString:[elem renderContext:context]];
160 | }
161 | return buffer;
162 | }
163 |
164 | @end
165 |
166 | @implementation GRMustacheTextElement(PrivateRendering)
167 |
168 | - (NSString *)renderContext:(GRMustacheContext *)context {
169 | return text;
170 | }
171 |
172 | @end
173 |
174 | @implementation GRMustacheVariableElement(PrivateRendering)
175 |
176 | - (NSString *)htmlEscape:(NSString *)string {
177 | NSMutableString *result = [NSMutableString stringWithCapacity:5 + ceilf(string.length * 1.1)];
178 | [result appendString:string];
179 | [result replaceOccurrencesOfString:@"&" withString:@"&" options:NSLiteralSearch range:NSMakeRange(0, result.length)];
180 | [result replaceOccurrencesOfString:@"<" withString:@"<" options:NSLiteralSearch range:NSMakeRange(0, result.length)];
181 | [result replaceOccurrencesOfString:@">" withString:@">" options:NSLiteralSearch range:NSMakeRange(0, result.length)];
182 | [result replaceOccurrencesOfString:@"\"" withString:@""" options:NSLiteralSearch range:NSMakeRange(0, result.length)];
183 | [result replaceOccurrencesOfString:@"'" withString:@"'" options:NSLiteralSearch range:NSMakeRange(0, result.length)];
184 | return result;
185 | }
186 |
187 | - (NSString *)renderContext:(GRMustacheContext *)context {
188 | id value = [context valueForKey:name];
189 | if ([GRMustache objectIsFalseValue:value]) {
190 | return @"";
191 | }
192 | if (raw) {
193 | return [value description];
194 | }
195 | return [self htmlEscape:[value description]];
196 | }
197 |
198 | @end
199 |
200 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheTemplateLoader.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "GRMustache_private.h"
24 | #import "GRMustacheTemplateLoader_private.h"
25 | #import "GRMustacheTemplate_private.h"
26 | #import "GRMustacheDirectoryTemplateLoader_private.h"
27 | #import "GRMustacheBundleTemplateLoader_private.h"
28 | #import "GRMustacheTemplateParser_private.h"
29 | #import "GRMustacheTokenizer_private.h"
30 |
31 |
32 | NSString* const GRMustacheDefaultExtension = @"mustache";
33 |
34 |
35 | @interface GRMustacheTemplateLoader()
36 | - (GRMustacheTemplate *)parseString:(NSString *)templateString templateId:(id)templateId error:(NSError **)outError;
37 | @end
38 |
39 | @implementation GRMustacheTemplateLoader
40 | @synthesize extension;
41 | @synthesize encoding;
42 |
43 | + (id)templateLoaderWithCurrentWorkingDirectory {
44 | return [self templateLoaderWithBaseURL:[NSURL fileURLWithPath:[[NSFileManager defaultManager] currentDirectoryPath] isDirectory:YES]];
45 | }
46 |
47 | + (id)templateLoaderWithBaseURL:(NSURL *)url {
48 | return [[[GRMustacheDirectoryTemplateLoader alloc] initWithURL:url extension:nil encoding:NSUTF8StringEncoding] autorelease];
49 | }
50 |
51 | + (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext {
52 | return [[[GRMustacheDirectoryTemplateLoader alloc] initWithURL:url extension:ext encoding:NSUTF8StringEncoding] autorelease];
53 | }
54 |
55 | + (id)templateLoaderWithBaseURL:(NSURL *)url extension:(NSString *)ext encoding:(NSStringEncoding)encoding {
56 | return [[[GRMustacheDirectoryTemplateLoader alloc] initWithURL:url extension:ext encoding:encoding] autorelease];
57 | }
58 |
59 | + (id)templateLoaderWithBundle:(NSBundle *)bundle {
60 | return [[[GRMustacheBundleTemplateLoader alloc] initWithBundle:bundle extension:nil encoding:NSUTF8StringEncoding] autorelease];
61 | }
62 |
63 | + (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext {
64 | return [[[GRMustacheBundleTemplateLoader alloc] initWithBundle:bundle extension:ext encoding:NSUTF8StringEncoding] autorelease];
65 | }
66 |
67 | + (id)templateLoaderWithBundle:(NSBundle *)bundle extension:(NSString *)ext encoding:(NSStringEncoding)encoding {
68 | return [[[GRMustacheBundleTemplateLoader alloc] initWithBundle:bundle extension:ext encoding:encoding] autorelease];
69 | }
70 |
71 | - (id)initWithExtension:(NSString *)theExtension encoding:(NSStringEncoding)theEncoding {
72 | if ((self = [self init])) {
73 | if (theExtension == nil) {
74 | theExtension = GRMustacheDefaultExtension;
75 | }
76 | extension = [theExtension retain];
77 | encoding = theEncoding;
78 | templatesById = [[NSMutableDictionary dictionaryWithCapacity:4] retain];
79 | }
80 | return self;
81 | }
82 |
83 | - (GRMustacheTemplate *)parseTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseTemplateId error:(NSError **)outError {
84 | id templateId = [self templateIdForTemplateNamed:name relativeToTemplateId:baseTemplateId];
85 | if (templateId == nil) {
86 | if (outError != NULL) {
87 | *outError = [NSError errorWithDomain:GRMustacheErrorDomain
88 | code:GRMustacheErrorCodeTemplateNotFound
89 | userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"No such template: %@", name, nil]
90 | forKey:NSLocalizedDescriptionKey]];
91 | }
92 | return nil;
93 | }
94 |
95 | GRMustacheTemplate *template = [templatesById objectForKey:templateId];
96 |
97 | if (template == nil) {
98 | // templateStringForTemplateId is a method that GRMustache users may implement.
99 | // We have to take extra care of error handling here.
100 | if (outError != NULL) {
101 | *outError = nil;
102 | }
103 | NSString *templateString = [self templateStringForTemplateId:templateId error:outError];
104 | if (!templateString) {
105 | if (outError != NULL) {
106 | // make sure we return an error
107 | if (*outError == nil) {
108 | *outError = [NSError errorWithDomain:GRMustacheErrorDomain
109 | code:GRMustacheErrorCodeTemplateNotFound
110 | userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"No such template: %@", name, nil]
111 | forKey:NSLocalizedDescriptionKey]];
112 | }
113 | }
114 | return nil;
115 | }
116 |
117 | // store an empty template before parsing, so that we support recursive partials
118 | template = [GRMustacheTemplate templateWithElements:nil];
119 | [self setTemplate:template forTemplateId:templateId];
120 |
121 | // parse
122 | GRMustacheTemplate *parsedTemplate = [self parseString:templateString templateId:templateId error:outError];
123 | if (parsedTemplate == nil) {
124 | [self setTemplate:nil forTemplateId:templateId];
125 | return nil;
126 | } else {
127 | template.elems = parsedTemplate.elems;
128 | }
129 | }
130 |
131 | return template;
132 | }
133 |
134 | - (GRMustacheTemplate *)parseTemplateNamed:(NSString *)name error:(NSError **)outError {
135 | return [self parseTemplateNamed:name relativeToTemplateId:nil error:outError];
136 | }
137 |
138 | - (GRMustacheTemplate *)parseString:(NSString *)templateString error:(NSError **)outError {
139 | return [self parseString:templateString templateId:nil error:outError];
140 | }
141 |
142 | - (void)setTemplate:(GRMustacheTemplate *)template forTemplateId:(id)templateId {
143 | if (template) {
144 | [templatesById setObject:template forKey:templateId];
145 | } else {
146 | [templatesById removeObjectForKey:templateId];
147 | }
148 | }
149 |
150 | - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseTemplateId {
151 | NSAssert(NO, @"abstract method");
152 | return nil;
153 | }
154 |
155 | - (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError {
156 | NSAssert(NO, @"abstract method");
157 | return nil;
158 | }
159 |
160 | - (void)dealloc {
161 | [extension release];
162 | [templatesById release];
163 | [super dealloc];
164 | }
165 |
166 | #pragma mark Private
167 |
168 | - (GRMustacheTemplate *)parseString:(NSString *)templateString templateId:(id)templateId error:(NSError **)outError {
169 | GRMustacheTemplateParser *parser = [[[GRMustacheTemplateParser alloc] initWithTemplateLoader:self templateId:templateId] autorelease];
170 | GRMustacheTokenizer *tokenizer = [[[GRMustacheTokenizer alloc] init] autorelease];
171 | tokenizer.delegate = parser;
172 | [tokenizer parseTemplateString:templateString];
173 | return [parser templateReturningError:outError];
174 | }
175 |
176 | @end
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/projects/ikhoyo-ui/GRMustacheContext.m:
--------------------------------------------------------------------------------
1 | // The MIT License
2 | //
3 | // Copyright (c) 2010 Gwendal Roué
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #if (TARGET_OS_IPHONE)
24 | // http://iphonedevelopment.blogspot.com/2008/10/device-vs-simulator.html
25 | #import
26 | #import
27 | #else
28 | #import
29 | #endif
30 |
31 | #import "GRMustache_private.h"
32 | #import "GRMustacheContext.h"
33 | #import "GRMustacheLambda_private.h"
34 |
35 |
36 | static NSInteger BOOLPropertyType = NSNotFound;
37 |
38 | @interface GRMustacheProperty: NSObject
39 | @property BOOL BOOLProperty;
40 | + (BOOL)class:(Class)class hasBOOLPropertyNamed:(NSString *)propertyName;
41 | @end
42 |
43 | @implementation GRMustacheProperty
44 | @dynamic BOOLProperty;
45 |
46 | + (NSInteger)typeForPropertyNamed:(NSString *)propertyName ofClass:(Class)class {
47 | objc_property_t property = class_getProperty(class, [propertyName cStringUsingEncoding:NSUTF8StringEncoding]);
48 | if (property != NULL) {
49 | const char *attributesCString = property_getAttributes(property);
50 | while (attributesCString) {
51 | if (attributesCString[0] == 'T') {
52 | return attributesCString[1];
53 | }
54 | attributesCString = strchr(attributesCString, ',');
55 | if (attributesCString) {
56 | attributesCString++;
57 | }
58 | }
59 | }
60 | return NSNotFound;
61 | }
62 |
63 | + (BOOL)class:(Class)class hasBOOLPropertyNamed:(NSString *)propertyName {
64 | static NSMutableDictionary *classes = nil;
65 |
66 | if (classes == nil) {
67 | classes = [[NSMutableDictionary dictionaryWithCapacity:12] retain];
68 | }
69 |
70 | NSMutableDictionary *propertyNames = [classes objectForKey:class];
71 | if (propertyNames == nil) {
72 | propertyNames = [[NSMutableDictionary dictionaryWithCapacity:4] retain];
73 | [classes setObject:propertyNames forKey:class];
74 | }
75 |
76 | NSNumber *boolNumber = [propertyNames objectForKey:propertyName];
77 | if (boolNumber == nil) {
78 | if (BOOLPropertyType == NSNotFound) {
79 | BOOLPropertyType = [self typeForPropertyNamed:@"BOOLProperty" ofClass:self];
80 | }
81 | BOOL booleanProperty = ([self typeForPropertyNamed:propertyName ofClass:class] == BOOLPropertyType);
82 | [propertyNames setObject:[NSNumber numberWithBool:booleanProperty] forKey:propertyName];
83 | return booleanProperty;
84 | }
85 |
86 | return [boolNumber boolValue];
87 | }
88 |
89 | @end
90 |
91 |
92 | @interface GRMustacheContext()
93 | @property (nonatomic, retain) id object;
94 | @property (nonatomic, retain) GRMustacheContext *parent;
95 | - (id)initWithObject:(id)object parent:(GRMustacheContext *)parent;
96 | - (BOOL)shouldConsiderObjectValue:(id)value forKey:(NSString *)key asBoolean:(CFBooleanRef *)outBooleanRef;
97 | - (id)valueForKeyComponent:(NSString *)key;
98 | @end
99 |
100 |
101 | @implementation GRMustacheContext
102 | @synthesize object;
103 | @synthesize parent;
104 |
105 | + (id)contextWithObject:(id)object {
106 | if ([object isKindOfClass:[GRMustacheContext class]]) {
107 | return object;
108 | }
109 | return [[[self alloc] initWithObject:object parent:nil] autorelease];
110 | }
111 |
112 | + (id)contextWithObjects:(id)object, ... {
113 | GRMustacheContext *context = nil;
114 | id eachObject;
115 | va_list argumentList;
116 | if (object) {
117 | context = [self contextWithObject:object];
118 | va_start(argumentList, object);
119 | while ((eachObject = va_arg(argumentList, id))) {
120 | context = [context contextByAddingObject:eachObject];
121 | }
122 | va_end(argumentList);
123 | } else {
124 | context = [self contextWithObject:nil];
125 | }
126 | return context;
127 | }
128 |
129 | - (id)initWithObject:(id)theObject parent:(GRMustacheContext *)theParent {
130 | if ((self = [self init])) {
131 | object = [theObject retain];
132 | parent = [theParent retain];
133 | }
134 | return self;
135 | }
136 |
137 | - (GRMustacheContext *)contextByAddingObject:(id)theObject {
138 | return [[[GRMustacheContext alloc] initWithObject:theObject parent:self] autorelease];
139 | }
140 |
141 | - (id)valueForKey:(NSString *)key {
142 | NSArray *components = [key componentsSeparatedByString:@"/"];
143 |
144 | // fast path for single component
145 | if (components.count == 1) {
146 | if ([key isEqualToString:@"."]) {
147 | return object;
148 | }
149 | if ([key isEqualToString:@".."]) {
150 | if (parent == nil) {
151 | // went too far
152 | return nil;
153 | }
154 | return parent.object;
155 | }
156 | return [self valueForKeyComponent:key];
157 | }
158 |
159 | // slow path for multiple components
160 | GRMustacheContext *context = self;
161 | for (NSString *component in components) {
162 | if (component.length == 0) {
163 | continue;
164 | }
165 | if ([component isEqualToString:@"."]) {
166 | continue;
167 | }
168 | if ([component isEqualToString:@".."]) {
169 | context = context.parent;
170 | if (context == nil) {
171 | // went too far
172 | return nil;
173 | }
174 | continue;
175 | }
176 | id value = [context valueForKeyComponent:component];
177 | if (value == nil) {
178 | return nil;
179 | }
180 | // further contexts are not in the context stack
181 | context = [GRMustacheContext contextWithObject:value];
182 | }
183 |
184 | return context.object;
185 | }
186 |
187 | - (void)dealloc {
188 | [object release];
189 | [parent release];
190 | [super dealloc];
191 | }
192 |
193 | - (id)valueForKeyComponent:(NSString *)key {
194 | // value by selector
195 |
196 | SEL renderingSelector = NSSelectorFromString([NSString stringWithFormat:@"%@Section:withContext:", key]);
197 | if ([object respondsToSelector:renderingSelector]) {
198 | return [GRMustacheLambdaSelectorWrapper helperWithObject:object selector:renderingSelector];
199 | }
200 |
201 | // value by KVC
202 |
203 | id value = nil;
204 |
205 | @try {
206 | value = [object valueForKey:key];
207 | }
208 | @catch (NSException *exception) {
209 | if (![[exception name] isEqualToString:NSUndefinedKeyException] ||
210 | [[exception userInfo] objectForKey:@"NSTargetObjectUserInfoKey"] != object ||
211 | ![[[exception userInfo] objectForKey:@"NSUnknownUserInfoKey"] isEqualToString:key])
212 | {
213 | // that's some exception we are not related to
214 | [exception raise];
215 | }
216 | }
217 |
218 | // value interpretation
219 |
220 | if (value != nil) {
221 | CFBooleanRef booleanRef;
222 | if ([self shouldConsiderObjectValue:value forKey:key asBoolean:&booleanRef]) {
223 | return (id)booleanRef;
224 | }
225 | return value;
226 | }
227 |
228 | // parent value
229 |
230 | if (parent == nil) { return nil; }
231 | return [parent valueForKeyComponent:key];
232 | }
233 |
234 | - (BOOL)shouldConsiderObjectValue:(id)value forKey:(NSString *)key asBoolean:(CFBooleanRef *)outBooleanRef {
235 | if ((CFBooleanRef)value == kCFBooleanTrue ||
236 | (CFBooleanRef)value == kCFBooleanFalse)
237 | {
238 | if (outBooleanRef) {
239 | *outBooleanRef = (CFBooleanRef)value;
240 | }
241 | return YES;
242 | }
243 |
244 | if ([value isKindOfClass:[NSNumber class]] &&
245 | ![GRMustache strictBooleanMode] &&
246 | [GRMustacheProperty class:[object class] hasBOOLPropertyNamed:key])
247 | {
248 | if (outBooleanRef) {
249 | *outBooleanRef = [(NSNumber *)value boolValue] ? kCFBooleanTrue : kCFBooleanFalse;
250 | }
251 | return YES;
252 | }
253 |
254 | return NO;
255 | }
256 |
257 | @end
258 |
--------------------------------------------------------------------------------