About to release my new Blog with ContentBox but need to know if.....

Ok, I have been working on a theme for ContentBox so that I can update my existing blog with the ContentBox.

However there are a few things that I need to know, how far down the track these things are going to be addressed or fixed. Basically I can’t release until these issues are addressed.

  1. Changing the location of preEntry / postEntry so that the interceptor is run on each iteration of entries. This is more for the default themes, rather than mine as I can make that change.

  2. The actual data or post is passed across so that one can manipulate the post if need be.

I need this for my SyntaxHighlighter module that I sort of can’t release until these two are fixed, and my blog is reliant on this as well

Now I can make the changes myself, but I am not sure if what I am thinking is the right process either. For example I was thinking that in the template entry.cfm put the pre / post Entry in there and pass in the content / post. I noticed that a lot of these sort of things, are the same where there is nothing passed in the interceptorData so there is nothing to change.

I am about a week off finishing my theme for my new blog, so I am not in a hurry for this. But it would be nice to know so that I can also finish the modules that I am currently working on as well.

Ok, I have been working on a theme for ContentBox so that I can update my existing blog with the ContentBox.

However there are a few things that I need to know, how far down the track these things are going to be addressed or fixed. Basically I can’t release until these issues are addressed.

  1. Changing the location of preEntry / postEntry so that the interceptor is run on each iteration of entries. This is more for the default themes, rather than mine as I can make that change.

  2. The actual data or post is passed across so that one can manipulate the post if need be.

I need this for my SyntaxHighlighter module that I sort of can’t release until these two are fixed, and my blog is reliant on this as well

Now I can make the changes myself, but I am not sure if what I am thinking is the right process either. For example I was thinking that in the template entry.cfm put the pre / post Entry in there and pass in the content / post. I noticed that a lot of these sort of things, are the same where there is nothing passed in the interceptorData so there is nothing to change.

I am about a week off finishing my theme for my new blog, so I am not in a hurry for this. But it would be nice to know so that I can also finish the modules that I am currently working on as well.

I have a pull request with you still, so I can add it to that as I have with all the other bugs that I have fixed.

Like the username and password text for the importer to name one.

And no you missed the point on what I mean for number 2, I don’t think you comprehend what I am asking for here.

Here is an example of code that I refer too… This is in my module, and is for changing

[code] to 
So my interceptor is listening on

//------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------
public void function cbui_preEntryDisplay(event, interceptData) {
var prc = event.getCollection(private=true);
var rc = event.getCollection();
}

But the problem how do I modify the content here, so that it re-renders as described above? And what I propose is making the change like this.

Remove the following from view/entry.cfm

#cb.event("cbui_preEntryDisplay")#

into template/entry.cfm and modify it so that it passes in the content for example

#cb.event("cbui_preEntryDisplay", entry.renderContent())#

However this has the added problem that there are two renderings in template/entry.cfm, so that means we would need to do something like



#cb.event("cbui_preEntryDisplay", entry.getExcerpt())#
#entry.getExcerpt()#

#cb.event("cbui_postEntryDisplay", entry.getExcerpt())#



#cb.event("cbui_preEntryDisplay", entry.renderContent())#
#entry.renderContent()#

#cb.event("cbui_postEntryDisplay", entry.renderContent())#


Does this make sense now, what I am saying?

I should also mention that I did post awhile ago about maybe

entry.getExcerpt()

Announcing the pre/post and others like it, rather than relying on the views and templates to have it.

Ok so let me get this straight. You need to convert this <pre>[code] to <pre class="brush: js;"> but you do not want to store the latter in the db right?

I would suspect that you wouldn't. All you want is to translate it at rendering time. If that is the case then you need to use the translation interceptors and the examples that I posted like the widget translator and the link translator. These interceptors manipulate or translate the content when rendered and not stored back on the db. Basically what you are posting is a markup that needs conversion.

Luis Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

So why have you created preEntry and postEntry interceptions, when they are useless?

Actually after looking at the code, for the widgetRender and linkRender. It is still not going to work. There is no interceptData as I have mentioned a number of times now.

There is. That is how they work. They receive the content as a string builder so you can translate it.

As for ore entry and post entry those are so you can add content or output content. Not to manipulate the entry.

Did you dump the arguments of the translation interceptors?

Ok, I see what you saying. I know many others are going to fall into that trap too.

Anyway I stand by what I said earlier about moving the firing points, because I made the assumption that preEntryDisplay would be before each entry iteration, when in fact it is not. Secondly as no interceptData is passed in then it makes it hard to also make the pre/post entry specific either. For example I might want to put content before each entry based on information in the entry, but I can’t because it is before the entire loop of entries, as well as no data to get at.

As I want it to only apply to blog entries, the preEntryDisplay would have been what I considered the best option, because I didn’t want this to apply to pages or other content types.

And cb_onContentRendering applies to all content types does it not? So if you say this is the best place, why do we need a preEntryDisplay and postEntryDisplay, would the onContentRendering do the same thing as the preEntryDisplay interception point?

Ok, I still don’t see how that is going to help either.

I see that translateContent is being passed the content, I see no manipulation of the content. Nor do I see a setContent in any of the methods. So how do you change the content?

Ok, here is the link one, which is short:

void function cb_onContentRendering(event,struct interceptData){
translateContent(builder=arguments.interceptData.builder,content=arguments.interceptData.content);
}

Two objects in the intercept data, builder which is the string builder that holds the content and content which is the content object, any content object.

To translate it you must look for the specific content you want to convert and then replace it in the incoming builder.

private function translateContent(required builder, content, customHTML){
// our mustaches pattern
var regex = “(page|entry|root):[[^]]*]”;
// match contentbox links in our incoming builder and build our targets array and len
var targets = reMatch( regex, builder.toString() );
var targetLen = arrayLen( targets );
var tagString = “”;
var linkContent = “”;

// Loop over found links
for(var x=1; x lte targetLen; x++){
tagString = targets[x];

// convert quotes to standards
tagString = replace(tagString,"&##34;",’"’,“all”);
tagString = replace(tagString,"&##39;","’",“all”);
tagString = replace(tagString,""","’",“all”);

try{

var linkType = getToken( tagString, 1, “:” );
switch( linkType ){
case “page” : { linkContent = cb.linkPage( determineSlug(tagString) ); break; }
case “entry” : { linkContent = cb.linkEntry( determineSlug(tagString) ); break; }
case “root” : { linkContent = cb.layoutRoot(); break; }

}

}
catch(Any e){
linkContent = “Error translating link: #e.message# #e.detail#”;
log.error(“Error translating link on target: #targets[x]#”, e);
}

// PROCESS REPLACING

// get location of target
var rLocation = builder.indexOf( targets[x] );
var rLen = len( targets[x] );

// Loop findings of same {{{}}} instances to replace
while( rLocation gt -1 ){
// Replace it
builder.replace( rLocation, rLocation+rLen, linkContent);
// look again
rLocation = builder.indexOf( targets[x], rLocation );
}

}
}

This uses the visitor pattern to replace content as there could be multiple instances of the content to replace in the string. So the string builder already has the content and remember that multiple translators can be applied to the same content string, so you cannot set the content back on the content object. The string builder traverses the chain of translators and each translator does it thing. So yours, would do the same by looking for a regex that matches your [code], then do the replacements by doing indexOF() and replacements. Not an easy concept, but hey, this is not easy :slight_smile:

The other interception points, preEntry and postEntry, I will look into what you say as I just wanted to talk about this topic first.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

And how the hell was I supposed to know that? You pass in both builder and content, have no physical reference to it content, and you expect me and others to have known that?

Nope not until I write the docs, thus this is called a beta :slight_smile:

Yeah well I think rather than just saying use that, and expecting me to know was like saying here is the key and there are 1000 cars go for it.

Anyway after doing a search for the interceptorpoint I found the announce, and I might have done that earlier…

Yea writing sometimes does not portray the full picture. Plus. It is sometimes hard to Verbalize everything in my head. That will be where I need help in the documentation that I started writing.

So what do you think can we get something like this?

Do you understand the problem now?

I mean if it wasn’t for blogCFCImporter neededing to wrap the code with

 this would not be an issue at all.