-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMPWHtmlPage.m
More file actions
91 lines (70 loc) · 2.02 KB
/
MPWHtmlPage.m
File metadata and controls
91 lines (70 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// MPWHtmlPage.m
// ObjectiveHTTPD
//
// Created by Marcel Weiher on 7/4/07.
// Copyright 2007 Marcel Weiher. All rights reserved.
//
#import "MPWHtmlPage.h"
#import "WAHtmlRenderer.h"
@implementation MPWHtmlPage
idAccessor( title, setTitle )
idAccessor( content , setContent )
idAccessor( path , setPath )
-init
{
[super init];
[self setTitle:@""];
return self;
}
-(void)renderHeaderOn:(WAHtmlRenderer*)aRenderer
{
[aRenderer element:"meta" attributes:@"http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"" content:@""];
[aRenderer element:"title" content:[self title]];
}
-(void)renderBodyOn:(WAHtmlRenderer*)aRenderer
{
if ( [self content] ) {
[aRenderer element:"div" attributes:@" name='mainContent'" content:[self content]];
}
}
-(void)renderHtmlOn:(WAHtmlRenderer*)renderer
{
[renderer element:"head" content:self selector:@selector(renderHeaderOn:)];
[renderer element:"body" content:self selector:@selector(renderBodyOn:)];
}
-(void)renderOn:(WAHtmlRenderer*)renderer
{
[renderer element:"html" content:self selector:@selector(renderHtmlOn:)];
}
-(void)dealloc
{
[content release];
[title release];
[path release];
[super dealloc];
}
@end
#import "WAHtmlRenderer.h"
@implementation MPWHtmlPage(rendering)
+(void)testPlainPage
{
id page=[[[self alloc] init] autorelease];
id result=[[WAHtmlRenderer process:page] stringValue];
IDEXPECT( result, @"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta><title></title></head><body></body></html>", @"html for index.html");
}
+(void)testPlainPageWithTitle
{
id page=[[[self alloc] init] autorelease];
id result;
[page setTitle:@"Test Title"];
result=[[WAHtmlRenderer process:page] stringValue];
IDEXPECT( result, @"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta><title>Test Title</title></head><body></body></html>", @"html for index.html");
}
+testSelectors {
return [NSArray arrayWithObjects:
@"testPlainPage",
@"testPlainPageWithTitle",
nil];
}
@end