Adding SyntaxHighlighter plugin to tinyMCE

by Jacobus Meintjes February 03, 2010 21:59

This will only be a step-by-step to add the plugin to BlogEngine.

1. Download SyntaxHighlighter

2. Download plugin

3. Copy SyntaxHighlighter to BlogEngine's root folder

Layout 1

4. Copy plugin to editors plugin folder

Layout 2

5. Add the following line to the top of your selected theme's masterpage.

<link rel="stylesheet" href="~/SyntaxHighlighter/styles/SyntaxHighlighter.css" />

6. Add the following section to the bottom of your selected theme's masterpage.

<script language="javascript" src="/SyntaxHighlighter/scripts/shCore.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushCSharp.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushXml.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushCss.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushSql.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushVb.js"></script>
<script language="javascript" src="/SyntaxHighlighter/scripts/shBrushJScript.js"></script>

<script language="javascript">
    window.onload = function() {
        dp.SyntaxHighlighter.ClipboardSwf = 'SyntaxHighlighter/flash/clipboard.swf';
//this section is important to allow for the correct formatting of BR tags
        dp.SyntaxHighlighter.BloggerMode();

        dp.SyntaxHighlighter.HighlightAll('code');
    }
</script>

7. In the admin folder, locate the tinyMCE.ascx file and change the following

<script type="text/javascript">
    tinyMCE.init({
        // General options
        mode: "exact",
        elements : "<%=txtContent.ClientID %>",
        theme: "advanced",
        plugins: "inlinepopups,fullscreen,contextmenu,emotions,table,iespell,advlink,codesyntax",
        convert_urls: false,
       
      // Theme options
        theme_advanced_buttons1: "fullscreen,code,|,cut,copy,paste,|,undo,redo,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,|,iespell,link,unlink,sub,sup,removeformat,cleanup,charmap,emotions,|,formatselect,fontselect,fontsizeselect,|,codeformat",
        theme_advanced_buttons2: "",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,
        extended_valid_elements: "pre[name|class]",
        tab_focus : ":prev,:next"
    });
</script>

8. Now you are done.

Your Add Entry editor should now contain a dropdown like the one below

Layout 3

It works the same as formatting text inside the editor, just select the text to change and then the format at has to comply to.

Tags: , ,

Javascript | tinyMCE

Upgraded to BlogEngine.Net 1.6

by Jacobus Meintjes February 03, 2010 21:48

Upgraded the version of BlogEngine to 1.6.0 and updated a tinyMCE plugin I did previously to allow me to use SyntaxHighlighter.

Test to ensure that the plugin is working correctly.

Xml code

<person>
    <name>Jacobus</name>
    <url>http://www.phoenixcode.net</url>
</person>

C# code

public int Main(string[] args)
{
     if(args.Length > 0)
{      Console.WriteLine("Success"); } }

 

 

Tags: , , ,

tinyMCE | BlogEngine.Net

NHibernate: My composite table is not saved

by Jacobus Meintjes July 29, 2009 16:26

I was trying to save a many-to-many relationship set to the database, it saved my mapped objects. It did not however save my composite table (linked table) information.

 

The mappings and schema I was using for my classes (only extracts from the required sections):

Trust:

<bag name="Trustees" table="FinanceStore_TrustTrustee" cascade="all">
     <key>
          <column name="TrustId"/>
     </key>
     <many-to-many column="TrusteeId" class="FinanceStore.Model.Entities.Trustee, FinanceStore.Model"/>
</bag>

 

Trustee

<bag name="Trust" cascade="all"  table="FinanceStore_TrustTrustee" lazy="true">  
     <key>
         <column name="TrusteeId"/>
     </key>
     <many-to-many  column="TrustId" class="FinanceStore.Model.Entities.Trust, FinanceStore.Model"/>
</bag>

 

Database schema:

The mapping worked, in the sense of alowing me to retrieve my objects without creating a object between Trust and Trustee, which is the correct way to handle the objects. After some searching on google I found that I was using the wrong collection type mapping and should have used the <!--[endif]--> <idbag></idbag>configuration.

idbag explained by NHibernate: "NHibernate provides a feature that allows you to map many to many associations and collections of values to a table with a surrogate key. The <idbag> element lets you map a List (or Collection) with bag semantics"

 

In the end the mappings were changed to

Trust

Tags:

tinyMCE

HowTo: tinyMCE code formatting plugin

by Jacobus Meintjes June 14, 2009 12:54

This is just a quick howto that I put together to get this to work. For more info you can download the code.

 

1.  Add the following line to you're site.master and admin.master - site.master is dependant on the theme you are using.

   <link rel="stylesheet" href="~/csharp.css" type="text/css" />

 

2. copy csharp.css to the path you specified.

   You can change the css to suite you're needs.

 

3. Under the admin folder, there is a tinyMCE.ascx file
    Open the file and add the following to the javascript inside

    First you have to register the plugin on the following line:
        plugins: "codeformat,,inlinepopups,

    Then you have to add the icon to the toolbar:
        theme_advanced_buttons1: "codeformat,fullscreen

 

4. Copy ico.gif to admin\images folder.

 

5. Copy CodeStyle.aspx and CodeStyle.aspx.cs to the admin folder.


6. Copy the tinyMCE plugin to the plugin folder located under editors\tiny_mce3\plugins\

 

 

Please ensure that this copyright is copied with all changes made to any code from manoli.net

 

   1:  #region Copyright © 2001-2003 Jean-Claude Manoli [jc@manoli.net]
   2:  /*
   3:   * This software is provided 'as-is', without any express or implied warranty.
   4:   * In no event will the author(s) be held liable for any damages arising from
   5:   * the use of this software.
   6:   *
   7:   * Permission is granted to anyone to use this software for any purpose,
   8:   * including commercial applications, and to alter it and redistribute it
   9:   * freely, subject to the following restrictions:
  10:   *
  11:   *   1. The origin of this software must not be misrepresented; you must not
  12:   *      claim that you wrote the original software. If you use this software
  13:   *      in a product, an acknowledgment in the product documentation would be
  14:   *      appreciated but is not required.
  15:   *
  16:   *   2. Altered source versions must be plainly marked as such, and must not
  17:   *      be misrepresented as being the original software.
  18:   *
  19:   *   3. This notice may not be removed or altered from any source distribution.
  20:   */
  21:  #endregion

 

Tags: , ,

tinyMCE | Tutorials

Code formatting for BlogEngine.Net with tinyMCE

by Jacobus Meintjes June 14, 2009 11:29

 

This is my first try at the code formatting. Thanks to Manoli.net for the formatting code. I have added this to my BlogSite.


I will zip this and add it to this post later.

 


1:
using System;
   2:  using System.IO;
   3:  using System.Reflection;
   4:  using System.Text;
   5:  using System.Text.RegularExpressions;
   6:   
   7:  public partial class admin_CodeStyle : System.Web.UI.Page
   8:  {
   9:      protected void Page_Load(object sender, EventArgs e)
  10:      {
  11:   
  12:      }
  13:   
  14:      private string FormatSource()
  15:      {
  16:          CSharpFormat format = new CSharpFormat();
  17:          format.LineNumbers = true;
  18:          format.TabSpaces = 4;
  19:          format.Alternate = false;
  20:          return format.FormatCode(txtCode.Text);
  21:      }
  22:   

 

Tags:

tinyMCE

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant

About Me

Jacobus Meintjes
 
C# developer working with ASP.Net and/or Windows Forms.
Email Me

Cumulus

This will be shown to users with no Flash or Javascript.

Widget Twitter not found.

Root element is missing.X