Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 2
- Log:
Initial import of Instiki 0.11.0 sources from a downloaded Tarball.
Instiki is a Ruby On Rails based Wiki clone.
- Author:
- adh
- Date:
- Sat Jul 22 14:54:51 +0100 2006
- Size:
- 2698 Bytes
1 | #include <unistd.h> |
2 | #include <sys/wait.h> |
3 | #import "AppDelegate.h" |
4 | |
5 | int launch_ruby (char const* cmd) |
6 | { |
7 | int pId, parentID = getpid(); |
8 | if((pId = fork()) == 0) // child |
9 | { |
10 | NSLog(@"set child (%d) to pgrp %d", getpid(), parentID); |
11 | setpgrp(0, parentID); |
12 | system(cmd); |
13 | return 0; |
14 | } |
15 | else // parent |
16 | { |
17 | NSLog(@"started child process: %d", pId); |
18 | return pId; |
19 | } |
20 | } |
21 | |
22 | @implementation AppDelegate |
23 | |
24 | - (NSString*)storageDirectory |
25 | { |
26 | NSString* dir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Instiki"]; |
27 | [[NSFileManager defaultManager] createDirectoryAtPath:dir attributes:nil]; |
28 | return dir; |
29 | } |
30 | |
31 | - (void)awakeFromNib |
32 | { |
33 | setpgrp(0, getpid()); |
34 | |
35 | if([[[[NSBundle mainBundle] infoDictionary] objectForKey:@"LSUIElement"] isEqualToString:@"1"]) |
36 | { |
37 | NSStatusBar* bar = [NSStatusBar systemStatusBar]; |
38 | NSStatusItem* item = [[bar statusItemWithLength:NSVariableStatusItemLength] retain]; |
39 | [item setTitle:@"Wiki"]; |
40 | [item setHighlightMode:YES]; |
41 | [item setMenu:statusMenu]; |
42 | } |
43 | |
44 | NSBundle* bundle = [NSBundle bundleForClass:[self class]]; |
45 | NSString* ruby = [bundle pathForResource:@"ruby" ofType:nil]; |
46 | NSString* script = [[bundle resourcePath] stringByAppendingPathComponent:@"rb_src/instiki.rb"]; |
47 | if(ruby && script) |
48 | { |
49 | NSString* cmd = [NSString stringWithFormat: |
50 | @"%@ -I '%@' -I '%@' '%@' -s --storage='%@'", |
51 | ruby, |
52 | [[bundle resourcePath] stringByAppendingPathComponent:@"lib/ruby/1.8"], |
53 | [[bundle resourcePath] stringByAppendingPathComponent:@"lib/ruby/1.8/powerpc-darwin"], |
54 | script, |
55 | [self storageDirectory] |
56 | ]; |
57 | NSLog(@"starting %@", cmd); |
58 | processID = launch_ruby([cmd UTF8String]); |
59 | } |
60 | |
61 | /* public the service using rendezvous */ |
62 | service = [[NSNetService alloc] |
63 | initWithDomain:@"" // default domain |
64 | type:@"_http._tcp." |
65 | name:[NSString stringWithFormat:@"%@'s Instiki", NSFullUserName()] |
66 | port:2500]; |
67 | [service publish]; |
68 | } |
69 | |
70 | - (void)applicationWillTerminate:(NSNotification*)aNotification |
71 | { |
72 | [service stop]; |
73 | [service release]; |
74 | |
75 | kill(0, SIGTERM); |
76 | } |
77 | |
78 | - (IBAction)about:(id)sender |
79 | { |
80 | [NSApp activateIgnoringOtherApps:YES]; |
81 | [NSApp orderFrontStandardAboutPanel:self]; |
82 | } |
83 | |
84 | - (IBAction)goToHomepage:(id)sender |
85 | { |
86 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://localhost:2500/"]]; |
87 | } |
88 | |
89 | - (IBAction)goToInstikiOrg:(id)sender |
90 | { |
91 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.instiki.org/"]]; |
92 | } |
93 | |
94 | - (BOOL)applicationShouldOpenUntitledFile:(NSApplication*)sender |
95 | { |
96 | return shouldOpenUntitled ?: (shouldOpenUntitled = YES, NO); |
97 | } |
98 | |
99 | - (BOOL)applicationOpenUntitledFile:(NSApplication*)theApplication |
100 | { |
101 | return [self goToHomepage:self], YES; |
102 | } |
103 | |
104 | - (IBAction)quit:(id)sender |
105 | { |
106 | [NSApp terminate:self]; |
107 | } |
108 | |
109 | @end |