Jahia Dev Forum > Disable codeHighlighter...

0 (0 Good)
0 (0 Bad)

Disable codeHighlighter during blog editing?

by  rvt »  2014/01/21 02:54

hey All,

is it possible to disable the code highlighter during blog editing? The problem is that when you edit a blog, you need to disable some filter's that might mangle content you don't want.
When editing a blog endtry you don't want your [code:XXX] tahes be replaced by html tags.
I have been looked if this is possible editing codeHighlighter.xml, but since all content get's run through the filter's I don't think there is a way to test if 'something is active'.

At this moment I came up with the following in execute method of CodeFilter, but this is a rather ugly hack:

1         if (renderContext.getRequest().getAttribute(CodeFilter.class+"SKIP")!=null) {
2             return previousOut;
3         }
4 
5         if (resource.getNode().getPrimaryNodeTypeName().equals("jnt:blogEntryFormEdition")) {
6             renderContext.getRequest().setAttribute(CodeFilter.class+"SKIP",Boolean.TRUE);
7             return previousOut;
8         }

Any other options? have?

Ries

  • Disable codeHighlighter during blog editing?
    2014/01/21 02:54

    rvt <p> hey All,</p> <p> is it possible to disable the code highlighter during blog editing? The problem is that when you edit a blog, you need to disable some filter&#39;s that might mangle content you don&#39;t want.<br /> When editing a blog endtry you don&#39;t want your [code:XXX] tahes be replaced by html tags.<br /> I have been looked if this is possible editing&nbsp;codeHighlighter.xml, but since all content get&#39;s run through the filter&#39;s I don&#39;t think there is a way to test if &#39;something is active&#39;.</p> <p> At this moment I came up with the following in execute method of CodeFilter, but this is a rather ugly hack:</p> <pre style="line-height: 100%; border: 0.01mm solid rgb(0, 0, 0); padding: 4px; font-size: 12pt;"> <span style="color:#800000;background-color:#f0f0f0;">1 </span> <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (renderContext.getRequest().getAttribute(CodeFilter.<span style="color: rgb(0, 0, 128); font-weight: bold;">class</span>+<span style="color: rgb(0, 128, 0); font-weight: bold;">&quot;SKIP&quot;</span>)!=<span style="color: rgb(0, 0, 128); font-weight: bold;">null</span>) { <span style="color:#800000;background-color:#f0f0f0;">2 </span> <span style="color: rgb(0, 0, 128); font-weight: bold;">return</span> previousOut; <span style="color:#800000;background-color:#f0f0f0;">3 </span> } <span style="color:#800000;background-color:#f0f0f0;">4 5 </span> <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (resource.getNode().getPrimaryNodeTypeName().equals(<span style="color: rgb(0, 128, 0); font-weight: bold;">&quot;jnt:blogEntryFormEdition&quot;</span>)) { <span style="color:#800000;background-color:#f0f0f0;">6 </span> renderContext.getRequest().setAttribute(CodeFilter.<span style="color: rgb(0, 0, 128); font-weight: bold;">class</span>+<span style="color: rgb(0, 128, 0); font-weight: bold;">&quot;SKIP&quot;</span>,Boolean.TRUE); <span style="color:#800000;background-color:#f0f0f0;">7 </span> <span style="color: rgb(0, 0, 128); font-weight: bold;">return</span> previousOut; <span style="color:#800000;background-color:#f0f0f0;">8 </span> }</pre> <p> Any other options? have?</p> <p> Ries</p>

  • Number of messages  185
    Registration date Jan 21, 2014
    0 (0 Good)
    0 (0 Bad)

    Re: Disable codeHighlighter during blog editing?

    by  rvt »  2014/01/24 16:44

    Hello,

    I found a other issue with combining Forum and Code HighLighter which is somewhat similar to the first.

    When the blog generates the overview page, it is assumed that all element's within the editor are HTML tags because the excerpt is generated for the first 1200 characters, html cleaned
    Now when you cut in the middle of a [code:block], then codeHeighlighter might find any other code blocks that is a end, trying to highlite across different blog except's.

    So also on this page, the code highlighter should be disabled.

    Note the page I am taliing about is this : http://riesvantwisk.com/cms/home/blog/weeklystuff.html

    At this moment I had to modify the blog file to to replace all [code:] with [ this is why you see [java] instead of [code:java]

     

     

     

  • Re: Disable codeHighlighter during blog editing?
    2014/01/24 16:44

    rvt <p> Hello,</p> <p> I found a other issue with combining Forum and Code HighLighter which is somewhat similar to the first.</p> <p> When the blog generates the overview page, it is assumed that all element&#39;s within the editor are HTML tags because the excerpt is generated for the first 1200 characters, html cleaned<br /> Now when you cut in the middle of a [code:block], then codeHeighlighter might find any other code blocks that is a end, trying to highlite across different blog except&#39;s.</p> <p> So also on this page, the code highlighter should be disabled.</p> <p> Note the page I am taliing about is this :&nbsp;<a href="http://riesvantwisk.com/cms/home/blog/weeklystuff.html">http://riesvantwisk.com/cms/home/blog/weeklystuff.html</a></p> <p> At this moment I had to modify the blog file to to replace all [code:] with [ this is why you see [java] instead of [code:java]</p> <p> <img alt="" src="http://skitch.rvantwisk.nl/~rvt/bmk/Weekly_stuff-20140124-114236.png" style="width: 351px; height: 216px;" /></p> <p> &nbsp;</p> <p> &nbsp;</p> <p> &nbsp;</p>

  • Number of messages  185
    Registration date Jan 24, 2014
    0 (0 Good)
    0 (0 Bad)

    Re: Disable codeHighlighter during blog editing?

    by  qlamerand »  2014/01/24 17:34

    Hello Ries,

    You could try a filter configuration like :

            <property name="applyOnNodeTypes" value="jnt:blogPost" />
            <property name="applyOnConfigurations" value="module" />
     
    This way, the filter should be executed separately for each blog post in  the page.
     
    Best regards,
    Quentin
  • Re: Disable codeHighlighter during blog editing?
    2014/01/24 17:34

    qlamerand <p> Hello Ries,</p> <p> You could try a filter configuration like :</p> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;applyOnNodeTypes&quot; value=&quot;jnt:blogPost&quot; /&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;applyOnConfigurations&quot; value=&quot;module&quot; /&gt;</div> <div> &nbsp;</div> <div> This way, the filter should be executed separately for each blog post in &nbsp;the page.</div> <div> &nbsp;</div> <div> Best regards,</div> <div> Quentin</div>

  • Number of messages  28
    Registration date Jan 24, 2014
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Disable codeHighlighter during blog editing?

    by  rvt »  2014/01/24 19:11

    hey Quentin,

    thank you for responding, unfortunatly your suggestion isn't working.
    With the combination of jnt:blogPost and module the CodeHighlighter isn't called at all.

    I tried changing it to:

            <property name="applyOnNodeTypes" value="jnt:blogPost" />
            <property name="applyOnConfigurations" value="wrappedcontent" />
     
    That works, but then for some odd reason codeHighter doesn't 'see' the brushes anymore and I get this error:
     
    The generated code for teh brushes looks like :
     
    <div id="brushes" style="display:none;">aabrushesaa</div>
    so, it's not replaced by the actual bush code's used.
     
    This weekend I will see if I can dig a bit deeper... 
    If you have questions, please let me know.
     
    Ries
     
  • Re: Re: Disable codeHighlighter during blog editing?
    2014/01/24 19:11

    rvt <p> hey Quentin,</p> <p> thank you for responding, unfortunatly your suggestion isn&#39;t working.<br /> With the combination of jnt:blogPost and module the CodeHighlighter isn&#39;t called at all.</p> <p> I tried changing it to:</p> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;applyOnNodeTypes&quot; value=&quot;jnt:blogPost&quot; /&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;applyOnConfigurations&quot; value=&quot;wrappedcontent&quot; /&gt;</div> <div> &nbsp;</div> <div> That works, but then for some odd reason codeHighter doesn&#39;t &#39;see&#39; the brushes anymore and I get this error:</div> <div> <img alt="" src="http://skitch.rvantwisk.nl/~rvt/bmk/Safari-20140124-140939.png" /></div> <div> &nbsp;</div> <div> The generated code for teh brushes looks like :</div> <div> &nbsp;</div> <div> &lt;div id=&quot;brushes&quot; style=&quot;display:none;&quot;&gt;aabrushesaa&lt;/div&gt;</div> <div> so, it&#39;s not replaced by the actual bush code&#39;s used.</div> <div> &nbsp;</div> <div> This weekend I will see if I can dig a bit deeper...&nbsp;</div> <div> If you have questions, please let me know.</div> <div> &nbsp;</div> <div> Ries</div> <div> &nbsp;</div>

  • Number of messages  185
    Registration date Jan 24, 2014
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page