Skip to content

Commit

Permalink
Template engine.
Browse files Browse the repository at this point in the history
Very rough implementation of a new template engine for themes.
Requires optimization and is not complete. Only supports main
log line rendering. Inline media, links, and other stuff do not
work yet. Use at your own risk.
  • Loading branch information
emsquared committed Jul 25, 2012
1 parent a0b0049 commit d987731
Show file tree
Hide file tree
Showing 164 changed files with 3,913 additions and 776 deletions.
6 changes: 3 additions & 3 deletions Classes/Controllers/TXMasterController.m
Original file line number Diff line number Diff line change
Expand Up @@ -648,17 +648,17 @@ - (void)themeStyleDidChange:(NSNotification *)note

[self.world reloadTheme];

if (self.viewTheme.other.nicknameFormat) {
if (NSObjectIsNotEmpty(self.viewTheme.other.nicknameFormat)) {
[sf appendString:TXTLS(@"ThemeChangeOverridePromptNicknameFormat")];
[sf appendString:NSStringNewlinePlaceholder];
}

if (self.viewTheme.other.timestampFormat) {
if (NSObjectIsNotEmpty(self.viewTheme.other.timestampFormat)) {
[sf appendString:TXTLS(@"ThemeChangeOverridePromptTimestampFormat")];
[sf appendString:NSStringNewlinePlaceholder];
}

if (self.viewTheme.other.channelViewFontOverrode) {
if (self.viewTheme.other.channelViewFont) {
[sf appendString:TXTLS(@"ThemeChangeOverridePromptChannelFont")];
[sf appendString:NSStringNewlinePlaceholder];
}
Expand Down
12 changes: 10 additions & 2 deletions Classes/Dialogs/Preferences/TDCPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ - (void)onChangedTheme:(id)sender
- (void)onSelectFont:(id)sender
{
NSFont *logfont = self.world.viewTheme.other.channelViewFont;

if (PointerIsEmpty(logfont)) {
logfont = [TPCPreferences themeChannelViewFont];
}

[_NSFontManager() setSelectedFont:logfont isMultiple:NO];
[_NSFontManager() orderFrontFontPanel:self];
Expand All @@ -541,9 +545,13 @@ - (void)onSelectFont:(id)sender

- (void)changeItemFont:(NSFontManager *)sender
{
TPCOtherTheme *theme = self.world.viewTheme.other;
NSFont *logfont = self.world.viewTheme.other.channelViewFont;

if (PointerIsEmpty(logfont)) {
logfont = [TPCPreferences themeChannelViewFont];
}

NSFont *newFont = [sender convertFont:theme.channelViewFont];
NSFont *newFont = [sender convertFont:logfont];

[TPCPreferences setThemeChannelViewFontName:[newFont fontName]];
[TPCPreferences setThemeChannelViewFontSize:[newFont pointSize]];
Expand Down
90 changes: 90 additions & 0 deletions Classes/Headers/External Libraries/GRMustache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// The MIT License
//
// Copyright (c) 2012 Gwendal Roué
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "TextualApplication.h"

/**
* A C struct that hold GRMustache version information
*
* @since v1.0
*/
typedef struct {
int major; /**< The major component of the version. */
int minor; /**< The minor component of the version. */
int patch; /**< The patch-level component of the version. */
} GRMustacheVersion;


/**
* The GRMustache class provides with global-level information and configuration
* of the GRMustache library.
*
* @since v1.0
*/
@interface GRMustache: NSObject

////////////////////////////////////////////////////////////////////////////////
/// @name Getting the GRMustache version
////////////////////////////////////////////////////////////////////////////////

/**
* @return The version of GRMustache as a GRMustacheVersion struct.
*
* @since v1.0
*/
+ (GRMustacheVersion)version AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER;

////////////////////////////////////////////////////////////////////////////////
/// @name Preventing NSUndefinedKeyException when using GRMustache in Development configuration
////////////////////////////////////////////////////////////////////////////////

/**
* Have GRMustache avoid most `NSUndefinedKeyExceptions` when rendering
* templates.
*
* The rendering of a GRMustache template can lead to many
* `NSUndefinedKeyExceptions` to be raised, because of the heavy usage of
* Key-Value Coding. Those exceptions are nicely handled by GRMustache, and are
* part of the regular rendering of a template.
*
* Unfortunately, when debugging a project, developers usually set their
* debugger to stop on every Objective-C exceptions. GRMustache rendering can
* thus become a huge annoyance. This method prevents it.
*
* You'll get a slight performance hit, so you'd probably make sure this call
* does not enter your Release configuration.
*
* One way to achieve this is to add `-DDEBUG` to the "Other C Flags" setting of
* your development configuration, and to wrap the
* `preventNSUndefinedKeyExceptionAttack` method call in a #if block, like:
*
* #ifdef DEBUG
* [GRMustache preventNSUndefinedKeyExceptionAttack];
* #endif
*
* **Companion guide:** https://github.com/groue/GRMustache/blob/master/Guides/runtime/context_stack.md
*
* @since v1.7
*/
+ (void)preventNSUndefinedKeyExceptionAttack AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER;

@end
146 changes: 146 additions & 0 deletions Classes/Headers/External Libraries/GRMustacheAvailabilityMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// The MIT License
//
// Copyright (c) 2012 Gwendal Roué
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "TextualApplication.h"



/*
* Set up standard GRMustache versions
*/
#define GRMUSTACHE_VERSION_4_0 4000
#define GRMUSTACHE_VERSION_4_1 4010






/*
* If max GRMustacheVersion not specified, assume 4.1
*/
#ifndef GRMUSTACHE_VERSION_MAX_ALLOWED
#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_4_1
#endif

/*
* if min GRMustacheVersion not specified, assume max
*/
#ifndef GRMUSTACHE_VERSION_MIN_REQUIRED
#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_MAX_ALLOWED
#endif

/*
* Error on bad values
*/
#if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_MIN_REQUIRED
#error GRMUSTACHE_VERSION_MAX_ALLOWED must be >= GRMUSTACHE_VERSION_MIN_REQUIRED
#endif
#if GRMUSTACHE_VERSION_MIN_REQUIRED < GRMUSTACHE_VERSION_4_0
#error GRMUSTACHE_VERSION_MIN_REQUIRED must be >= GRMUSTACHE_VERSION_4_0
#endif






/*
* AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER
*
* Used on declarations introduced in GRMustache 4.0
*/
#define AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER

/*
* AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER_BUT_DEPRECATED
*
* Used on declarations introduced in GRMustache 4.0,
* and deprecated in GRMustache 4.0
*/
#define AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE

/*
* DEPRECATED_IN_GRMUSTACHE_VERSION_4_0_AND_LATER
*
* Used on types deprecated in GRMustache 4.0
*/
#define DEPRECATED_IN_GRMUSTACHE_VERSION_4_0_AND_LATER DEPRECATED_ATTRIBUTE






/*
* AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER
*
* Used on declarations introduced in GRMustache 4.1
*/
#if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_4_1
#define AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER UNAVAILABLE_ATTRIBUTE
#elif GRMUSTACHE_VERSION_MIN_REQUIRED < GRMUSTACHE_VERSION_4_1
#define AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER WEAK_IMPORT_ATTRIBUTE
#else
#define AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER
#endif

/*
* AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER_BUT_DEPRECATED
*
* Used on declarations introduced in GRMustache 4.1,
* and deprecated in GRMustache 4.1
*/
#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_4_1
#define AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
#else
#define AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER_BUT_DEPRECATED AVAILABLE_GRMUSTACHE_VERSION_4_1_AND_LATER
#endif

/*
* AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_4_1
*
* Used on declarations introduced in GRMustache 4.0,
* but later deprecated in GRMustache 4.1
*/
#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_4_1
#define AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_4_1 DEPRECATED_ATTRIBUTE
#else
#define AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_4_1 AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER
#endif

/*
* DEPRECATED_IN_GRMUSTACHE_VERSION_4_1_AND_LATER
*
* Used on types deprecated in GRMustache 4.1
*/
#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_4_1
#define DEPRECATED_IN_GRMUSTACHE_VERSION_4_1_AND_LATER DEPRECATED_ATTRIBUTE
#else
#define DEPRECATED_IN_GRMUSTACHE_VERSION_4_1_AND_LATER
#endif






54 changes: 54 additions & 0 deletions Classes/Headers/External Libraries/GRMustacheError.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// The MIT License
//
// Copyright (c) 2012 Gwendal Roué
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import "TextualApplication.h"


/**
* The domain of a GRMustache-generated NSError
*
* @since v1.0
*/
extern NSString* const GRMustacheErrorDomain AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER;

/**
* The codes of a GRMustache-generated NSError
*
* @since v1.0
*/
typedef enum {
/**
* The error code for parse errors.
*
* @since v1.0
*/
GRMustacheErrorCodeParseError,

/**
* The error code for not found templates and partials.
*
* @since v1.0
*/
GRMustacheErrorCodeTemplateNotFound,
} GRMustacheErrorCode AVAILABLE_GRMUSTACHE_VERSION_4_0_AND_LATER;


Loading

0 comments on commit d987731

Please sign in to comment.