Skip to content

Commit

Permalink
Store default templates in app.
Browse files Browse the repository at this point in the history
  • Loading branch information
emsquared committed Jul 26, 2012
1 parent 374a42c commit 0848951
Show file tree
Hide file tree
Showing 187 changed files with 45 additions and 887 deletions.
21 changes: 21 additions & 0 deletions Classes/Preferences/Themes/TPCOtherTheme.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@interface TPCOtherTheme ()
@property (nonatomic, strong) NSDictionary *styleSettings;
@property (nonatomic, strong) GRMustacheTemplateRepository *templateRepository;
@property (nonatomic, strong) GRMustacheTemplateRepository *appTemplateRepository;
@end

@implementation TPCOtherTheme
Expand Down Expand Up @@ -123,6 +124,14 @@ - (GRMustacheTemplate *)templateWithName:(NSString *)name
GRMustacheTemplate *tmpl = [self.templateRepository templateForName:name error:&load_error];

if (PointerIsEmpty(tmpl) || load_error) {
if (load_error.code == GRMustacheErrorCodeTemplateNotFound || load_error.code == 260) {
GRMustacheTemplate *tmpl = [self.appTemplateRepository templateForName:name error:&load_error];

if (PointerIsNotEmpty(tmpl)) {
return tmpl;
}
}

NSLog(TXTLS(@"StyleTemplateLoadFailed"),
name, [load_error localizedDescription]);

Expand All @@ -148,6 +157,18 @@ - (void)reload
exit(10);
}

// ---- //

if (PointerIsEmpty(self.appTemplateRepository)) {
dictPath = [[TPCPreferences whereResourcePath] stringByAppendingPathComponent:@"/Style Default Templates"];

self.appTemplateRepository = [GRMustacheTemplateRepository templateRepositoryWithBaseURL:[NSURL fileURLWithPath:dictPath]];

if (PointerIsEmpty(self.appTemplateRepository)) {
exit(10);
}
}

// ---- //

self.styleSettings = nil;
Expand Down
33 changes: 5 additions & 28 deletions Classes/Views/Channel View/TVCLogController.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,9 @@ - (void)goToMark

- (void)reloadTheme
{
if (self.loaded == NO) return;

DOMDocument *doc = [self mainFrameDocument];
if (PointerIsEmpty(doc)) return;


[self executeScriptCommand:@"themeWillChange" withArguments:@[]];

DOMElement *body = [self body:doc];
if (PointerIsEmpty(body)) return;

Expand All @@ -462,8 +457,6 @@ - (void)reloadTheme

- (void)clear
{
if (self.loaded == NO) return;

self.html = nil;
self.loaded = NO;
self.count = 0;
Expand Down Expand Up @@ -932,10 +925,13 @@ - (NSString *)initialDocument:(NSString *)topic
templateTokens[@"activeStyleAbsolutePath"] = self.theme.other.path;
templateTokens[@"applicationResourcePath"] = [TPCPreferences whereResourcePath];

templateTokens[@"existingBody"] = NSStringNilValueSubstitute(self.html);

// ---- //

if (self.channel) {
templateTokens[@"isChannelView"] = @(YES);

templateTokens[@"channelName"] = logEscape(self.channel.name);
templateTokens[@"viewTypeToken"] = [self.channel channelTypeString];

Expand Down Expand Up @@ -1086,27 +1082,8 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame

self.autoScroller.webFrame = self.view.mainFrame.frameView;

if (self.html) {
DOMDocument *doc = [frame DOMDocument];

if (doc) {
DOMElement *body = [self body:doc];

[(id)body setInnerHTML:self.html];

self.html = nil;

if (self.scrollBottom) {
[self moveToBottom];
} else if (self.scrollTop) {
[body setValue:@(self.scrollTop) forKey:@"scrollTop"];
}
}
} else {
[self moveToBottom];

self.bottom = YES;
}
[self moveToBottom];
self.bottom = YES;

DOMDocument *doc = [frame DOMDocument];
if (PointerIsEmpty(doc)) return;
Expand Down
20 changes: 16 additions & 4 deletions Main Project (Textual).xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
4C46CCC91580469E00846B64 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C46CCC01580469E00846B64 /* Security.framework */; };
4C46CCCA1580469E00846B64 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C46CCC11580469E00846B64 /* SystemConfiguration.framework */; };
4C46CCCB1580469E00846B64 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C46CCC21580469E00846B64 /* WebKit.framework */; };
4C52379415C18F6700414852 /* Style Default Templates in Resources */ = {isa = PBXBuildFile; fileRef = 4C52379215C18F6700414852 /* Style Default Templates */; };
4C52379515C18F6700414852 /* Styles in Resources */ = {isa = PBXBuildFile; fileRef = 4C52379315C18F6700414852 /* Styles */; };
4C63C6B61592F0B0009F1635 /* TPWTB_Alerts.tif in Resources */ = {isa = PBXBuildFile; fileRef = 4C63C6B01592F0B0009F1635 /* TPWTB_Alerts.tif */; };
4C63C6B71592F0B0009F1635 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4C63C6B11592F0B0009F1635 /* [email protected] */; };
4C63C6BC1592F360009F1635 /* TPWTB_Extensions.tif in Resources */ = {isa = PBXBuildFile; fileRef = 4C63C6BA1592F360009F1635 /* TPWTB_Extensions.tif */; };
Expand Down Expand Up @@ -378,7 +380,6 @@
4CCF2F271580481E006FFE21 /* FormattingColor_13.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CCF2F161580481E006FFE21 /* FormattingColor_13.png */; };
4CCF2F281580481E006FFE21 /* FormattingColor_14.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CCF2F171580481E006FFE21 /* FormattingColor_14.png */; };
4CCF2F291580481E006FFE21 /* FormattingColor_15.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CCF2F181580481E006FFE21 /* FormattingColor_15.png */; };
4CCF2F5215804868006FFE21 /* Styles in Resources */ = {isa = PBXBuildFile; fileRef = 4CCF2F5115804868006FFE21 /* Styles */; };
4CCF2F9915804BC9006FFE21 /* core.js in Copy JavaScript Files */ = {isa = PBXBuildFile; fileRef = 4CCF2F5315804888006FFE21 /* core.js */; };
4CCF2F9D15804BF8006FFE21 /* Growl.framework in Copy Additional Frameworks */ = {isa = PBXBuildFile; fileRef = 4CCF2EE1158046F9006FFE21 /* Growl.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -510,6 +511,8 @@
4C46CCC01580469E00846B64 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
4C46CCC11580469E00846B64 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
4C46CCC21580469E00846B64 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; };
4C52379215C18F6700414852 /* Style Default Templates */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Style Default Templates"; path = "Resources/Styles/Style Default Templates"; sourceTree = SOURCE_ROOT; };
4C52379315C18F6700414852 /* Styles */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Styles; path = Resources/Styles/Styles; sourceTree = SOURCE_ROOT; };
4C63C6B01592F0B0009F1635 /* TPWTB_Alerts.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = TPWTB_Alerts.tif; sourceTree = "<group>"; };
4C63C6B11592F0B0009F1635 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "[email protected]"; sourceTree = "<group>"; };
4C63C6BA1592F360009F1635 /* TPWTB_Extensions.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = TPWTB_Extensions.tif; sourceTree = "<group>"; };
Expand Down Expand Up @@ -821,7 +824,6 @@
4CCF2F161580481E006FFE21 /* FormattingColor_13.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FormattingColor_13.png; path = "Resources/Images/IRC Formatting Colors/FormattingColor_13.png"; sourceTree = SOURCE_ROOT; };
4CCF2F171580481E006FFE21 /* FormattingColor_14.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FormattingColor_14.png; path = "Resources/Images/IRC Formatting Colors/FormattingColor_14.png"; sourceTree = SOURCE_ROOT; };
4CCF2F181580481E006FFE21 /* FormattingColor_15.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FormattingColor_15.png; path = "Resources/Images/IRC Formatting Colors/FormattingColor_15.png"; sourceTree = SOURCE_ROOT; };
4CCF2F5115804868006FFE21 /* Styles */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Styles; path = Resources/Styles; sourceTree = SOURCE_ROOT; };
4CCF2F5315804888006FFE21 /* core.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = core.js; path = Resources/Javascript/API/core.js; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -977,10 +979,10 @@
4C46CC97158042E700846B64 /* Styles & Scripts */ = {
isa = PBXGroup;
children = (
4C52379115C0E0CA00414852 /* Styles */,
4C46CCA6158043BB00846B64 /* Extensions */,
4C46CCA4158043A300846B64 /* JavaScript */,
4CCC6B60158E8C48003A102B /* Scripts */,
4CCF2F5115804868006FFE21 /* Styles */,
);
name = "Styles & Scripts";
sourceTree = "<group>";
Expand Down Expand Up @@ -1163,6 +1165,15 @@
name = "External Frameworks";
sourceTree = "<group>";
};
4C52379115C0E0CA00414852 /* Styles */ = {
isa = PBXGroup;
children = (
4C52379215C18F6700414852 /* Style Default Templates */,
4C52379315C18F6700414852 /* Styles */,
);
name = Styles;
sourceTree = "<group>";
};
4C63C6AD1592F0B0009F1635 /* Toolbar Icons */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1960,7 +1971,6 @@
4CCF2F271580481E006FFE21 /* FormattingColor_13.png in Resources */,
4CCF2F281580481E006FFE21 /* FormattingColor_14.png in Resources */,
4CCF2F291580481E006FFE21 /* FormattingColor_15.png in Resources */,
4CCF2F5215804868006FFE21 /* Styles in Resources */,
4C97075A158D740A0005CF68 /* colloquyRoomTabRegular.tif in Resources */,
4CCC6B61158E8C48003A102B /* Scripts in Resources */,
4C8AF728158E9B330026668C /* TDCAboutPanel.xib in Resources */,
Expand Down Expand Up @@ -2024,6 +2034,8 @@
4C73F946159DD38E00C1BB5F /* ServerCellSelection_Inverted.tif in Resources */,
4C73F947159DD38E00C1BB5F /* [email protected] in Resources */,
4C3ED27A15A0E0E40063880C /* DarkServerListViewSelectedQueryUser.tif in Resources */,
4C52379415C18F6700414852 /* Style Default Templates in Resources */,
4C52379515C18F6700414852 /* Styles in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<key>TXBundleBuildCodeName</key>
<string>Turtle Soup</string>
<key>TXBundleBuildNumber</key>
<string>12083</string>
<string>12095</string>
<key>TXBundleBuildReference</key>
<string>2.1.1-253-gad883c3-appstore,llvm4.0</string>
<string>2.1.1-254-g374a42c-debug,llvm4.0</string>
</dict>
</plist>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0848951

Please sign in to comment.