Skip to content

Commit

Permalink
Remove mutabletags from the 0.1 release.
Browse files Browse the repository at this point in the history
The feature may be redesinged and added again in the future.
  • Loading branch information
steveire committed Apr 9, 2010
1 parent 3ec39b0 commit b54d247
Show file tree
Hide file tree
Showing 41 changed files with 2 additions and 1,984 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ if (BUILD_MAIN_PLUGINS)
add_subdirectory(defaulttags)

add_subdirectory(defaultfilters)

add_subdirectory(mutabletags)
endif()

if (BUILD_SCRIPT_PLUGIN)
Expand Down
2 changes: 0 additions & 2 deletions corelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set (grantlee_core_SRCS
engine.cpp
filterexpression.cpp
lexer.cpp
mutabletemplate.cpp
node.cpp
nodebuiltins.cpp
outputstream.cpp
Expand Down Expand Up @@ -59,7 +58,6 @@ install(FILES
filterexpression.h
grantlee_core_export.h
${PROJECT_BINARY_DIR}/grantlee_version.h
mutabletemplate.h
node.h
outputstream.h
parser.h
Expand Down
28 changes: 0 additions & 28 deletions corelib/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,34 +271,6 @@ Template Engine::loadByName( const QString &name ) const
return t;
}

MutableTemplate Engine::loadMutableByName( const QString &name ) const
{
Q_D( const Engine );

QListIterator<AbstractTemplateLoader::Ptr> it( d->m_loaders );

while ( it.hasNext() ) {
AbstractTemplateLoader::Ptr loader = it.next();
MutableTemplate t = loader->loadMutableByName( name, this );
if ( t ) {
return t;
}
}
MutableTemplate t = MutableTemplate( new MutableTemplateImpl( this ) );
t->setObjectName( name );
t->d_ptr->m_error = TagSyntaxError;
t->d_ptr->m_errorString = QString::fromLatin1( "Template not found, %1" ).arg( name );
return t;
}

MutableTemplate Engine::newMutableTemplate( const QString &content, const QString &name ) const
{
MutableTemplate t = MutableTemplate( new MutableTemplateImpl( this ) );
t->setObjectName( name );
t->setContent( content );
return t;
}

Template Engine::newTemplate( const QString &content, const QString &name ) const
{
Template t = Template( new TemplateImpl( this ) );
Expand Down
17 changes: 1 addition & 16 deletions corelib/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#ifndef GRANTLEE_ENGINE_H
#define GRANTLEE_ENGINE_H

#include "mutabletemplate.h"
#include "template.h"
#include "templateloader.h"

Expand All @@ -36,7 +35,7 @@ class EnginePrivate;
/**
@brief Grantlee::Engine is the main entry point for creating %Grantlee Templates.
The Grantlee::Engine is responsible for configuring and creating Template and MutableTemplate objects.
The Grantlee::Engine is responsible for configuring and creating Template objects.
In typical use, one or more TemplateLoader objects will be added to the Engine to load template objects, and
plugin directories will be set to enable finding template tags and filters.
Expand Down Expand Up @@ -123,20 +122,6 @@ class GRANTLEE_CORE_EXPORT Engine : public QObject
*/
Template newTemplate( const QString &content, const QString &name ) const;

/**
Load the MutableTemplate identified by @p name.
The Templates and plugins loaded and will be determined by the Engine configuration.
*/
MutableTemplate loadMutableByName( const QString &name ) const;

/**
Create a new MutableTemplate with the content @p content identified by @p name.
The secondary Templates and plugins loaded will be determined by the Engine configuration.
*/
MutableTemplate newMutableTemplate( const QString &content, const QString &name ) const;

/**
Returns the libraries available by default to new Templates.
*/
Expand Down
1 change: 0 additions & 1 deletion corelib/grantlee_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "grantlee/filterexpression.h"
#include "grantlee/grantlee_core_export.h"
#include "grantlee/grantlee_version.h"
#include "grantlee/mutabletemplate.h"
#include "grantlee/node.h"
#include "grantlee/outputstream.h"
#include "grantlee/parser.h"
Expand Down
39 changes: 0 additions & 39 deletions corelib/mutabletemplate.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions corelib/mutabletemplate.h

This file was deleted.

40 changes: 0 additions & 40 deletions corelib/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,53 +152,13 @@ bool NodeList::containsNonText() const

void NodeList::render( OutputStream *stream, Context *c )
{
if ( c->isMutating() )
return mutableRender( stream, c );

for ( int i = 0; i < this->size(); ++i ) {
this->at( i )->render( stream, c );
}

return;
}

void NodeList::mutableRender( OutputStream *stream, Context *c )
{
QString renderedTemplate;
QString renderedNode;

QTextStream textStream( &renderedNode );
QSharedPointer<OutputStream> nodeStream = stream->clone( &textStream );

QList<Grantlee::Node*>::iterator it;
QList<Grantlee::Node*>::iterator first = begin();
QList<Grantlee::Node*>::iterator last = end();

for ( it = first; it != last; ++it ) {
renderedNode.clear();
Grantlee::Node *node = *it;
node->render( nodeStream.data(), c );
renderedTemplate += renderedNode;
bool isPersistent = node->isPersistent();
if ( it != first ) {
Grantlee::Node *lastNode = *( it - 1 );
TextNode *textNode = qobject_cast<TextNode*>( lastNode );
if ( textNode && ( !isPersistent || node->isRepeatable() ) ) {
textNode->appendContent( renderedNode );
}
if ( *it == *( last - 1 ) ) {
break;
}
if ( !isPersistent && !lastNode->isPersistent() ) {
it = erase( it );
// TODO: This --it is broken. Fix this iteration.
--it;
}
}
}
( *stream ) << renderedTemplate;
}

AbstractNodeFactory::AbstractNodeFactory( QObject *parent )
: QObject( parent ), d_ptr( new AbstractNodeFactoryPrivate( this ) )
{
Expand Down
22 changes: 0 additions & 22 deletions corelib/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,6 @@ class GRANTLEE_CORE_EXPORT Node : public QObject
// This can't be const because CycleNode needs to change on each render.
virtual void render( OutputStream *stream, Context *c ) = 0;

/**
Reimplement this to return whether the node is persistent.
@see mutable_templates
*/
virtual bool isPersistent() { // krazy:exclude:inline
return isRepeatable();
}

/**
Reimplement this to return whether the node is repeatable.
@see mutable_templates
*/
virtual bool isRepeatable() { // krazy:exclude:inline
return false;
}

#ifndef Q_QDOC
/**
@internal
Expand Down Expand Up @@ -218,12 +202,6 @@ class GRANTLEE_CORE_EXPORT NodeList : public QList<Grantlee::Node*>
*/
void render( OutputStream *stream, Context *c );

protected:
/**
Renders the list of Nodes in the Context @p c, possibly mutating the nodes contained in it.
*/
void mutableRender( OutputStream *stream, Context *c );

private:
bool m_containsNonText;
};
Expand Down
38 changes: 0 additions & 38 deletions corelib/templateloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,6 @@ bool FileSystemTemplateLoader::canLoadTemplate( const QString &name ) const
return true;
}

// TODO Refactor these two.
MutableTemplate FileSystemTemplateLoader::loadMutableByName( const QString &fileName, Engine const *engine ) const
{
int i = 0;
QFile file;

while ( !file.exists() ) {
if ( i >= m_templateDirs.size() )
break;

file.setFileName( m_templateDirs.at( i ) + '/' + m_themeName + '/' + fileName );

QFileInfo fi( file );
if ( !fi.canonicalFilePath().contains( QDir( m_templateDirs.at( i ) ).canonicalPath() ) )
return MutableTemplate();
++i;
}

if ( !file.exists() || !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template from %1. File does not exist." ).arg( fileName ) );
}

QString content;
content = file.readAll();

MutableTemplate t = engine->newMutableTemplate( content, fileName );
return t;
}

Template FileSystemTemplateLoader::loadByName( const QString &fileName, Engine const *engine ) const
{
int i = 0;
Expand Down Expand Up @@ -189,15 +160,6 @@ Template InMemoryTemplateLoader::loadByName( const QString& name, Engine const *
throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template %1. Template does not exist." ).arg( name ) );
}

MutableTemplate InMemoryTemplateLoader::loadMutableByName( const QString& name, Engine const *engine ) const
{
if ( m_namedTemplates.contains( name ) ) {
MutableTemplate t = engine->newMutableTemplate( m_namedTemplates.value( name ), name );
return t;
}
throw Grantlee::Exception( TagSyntaxError, QString( "Couldn't load template %1. Template does not exist." ).arg( name ) );
}

QPair<QString, QString> InMemoryTemplateLoader::getMediaUri( const QString& fileName ) const
{
Q_UNUSED( fileName )
Expand Down
10 changes: 0 additions & 10 deletions corelib/templateloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <QtCore/QSharedPointer>

#include "mutabletemplate.h"
#include "template.h"

#include "grantlee_core_export.h"
Expand Down Expand Up @@ -56,11 +55,6 @@ class GRANTLEE_CORE_EXPORT AbstractTemplateLoader
*/
virtual ~AbstractTemplateLoader();

/**
Load a MutableTemplate called @p name. Return an invalid Template if no content by that name exists.
*/
virtual MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const = 0;

/**
Load a Template called @p name. Return an invalid Template if no content by that name exists.
*/
Expand Down Expand Up @@ -140,8 +134,6 @@ class GRANTLEE_CORE_EXPORT FileSystemTemplateLoader : public AbstractTemplateLoa
*/
virtual ~FileSystemTemplateLoader();

/* reimp */ MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const;

/* reimp */ Template loadByName( const QString &name, Engine const *engine ) const;

/* reimp */ bool canLoadTemplate( const QString &name ) const;
Expand Down Expand Up @@ -187,8 +179,6 @@ class GRANTLEE_CORE_EXPORT InMemoryTemplateLoader : public AbstractTemplateLoade
InMemoryTemplateLoader();
virtual ~InMemoryTemplateLoader();

/* reimp */ MutableTemplate loadMutableByName( const QString &name, Engine const *engine ) const;

/* reimp */ Template loadByName( const QString &name, Engine const *engine ) const;

/* reimp */ bool canLoadTemplate( const QString &name ) const;
Expand Down
2 changes: 0 additions & 2 deletions dox/examples.dox
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace Grantlee
@image html grantlee_chat_coloured.png "Simple version with some colouring."
@image html grantlee_chat_boxes.png "A version with content in boxes."

The idea for the Mutable Tags comes from <a href="http://simonwillison.net/2009/May/19/twophased/">this blog</a>.

@section kjots KJots Rewrite.
(see playground/pim/akonadi)
KJots shows a use of %Grantlee by retrieving items from a Model using a custom role, and allows arbitrary nesting by recursively including templates.
Expand Down
Loading

0 comments on commit b54d247

Please sign in to comment.