Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Starting a blog

  • 05-04-2011 03:45PM
    #1
    Registered Users, Registered Users 2 Posts: 9,035 ✭✭✭


    Hi,
    I was thinking of starting a blog.

    The idea would be show some coding tips.
    I'd like to be:

    1. able to display formatted source code
    2. able to execute javascript in my blog pages

    any suggestions?

    I was looking at google's blogspot and I spent a lot of time trying to hack their hacking of my HTML.

    Any ideas appreciated.

    Thanks.


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    For displaying formatted, syntax highlighted sourcecode
    the javascript files from
    http://alexgorbatchev.com/SyntaxHighlighter/

    is pretty nice with support for the most popular languages.


  • Registered Users, Registered Users 2 Posts: 9,035 ✭✭✭Tim Robbins


    ressem wrote: »
    For displaying formatted, syntax highlighted sourcecode
    the javascript files from
    http://alexgorbatchev.com/SyntaxHighlighter/

    is pretty nice with support for the most popular languages.

    But don't I need to upload some of his files to get that working? I am not sure the likes of wordpress will allow that.


  • Registered Users, Registered Users 2 Posts: 9,035 ✭✭✭Tim Robbins


    ressem wrote: »
    For displaying formatted, syntax highlighted sourcecode
    the javascript files from
    http://alexgorbatchev.com/SyntaxHighlighter/

    is pretty nice with support for the most popular languages.

    But don't I need to upload some of his files to get that working? I am not sure the likes of wordpress will allow that.


  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    It is built-in to wordpress.com.
    http://en.support.wordpress.com/code/posting-source-code/
    No harder to use than boards
    tag.
    
    If you are creating a blog on your own hosting space with your own install of wordpress then it's available as a plugin.
    http://wordpress.org/extend/plugins/syntaxhighlighter/
    
    Or you can use http://codex.wordpress.org/Function_Reference/wp_enqueue_script
    add to header.php or functions.php in the template /theme to add javascript files.
    
    from www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/
    Site seems unavailable currently
    [code]
    Assuming that your theme’s name is MyFavoriteTheme, you’ll have to create the child theme as MyFavoriteTheme-child.
    
    In order to use your new theme, you’ll have to create in the MyFavoriteTheme-child folder two files:
    
    styles.css – required – who’ll mark your folder as a child theme
    functions.php – optional – for our example is required, as we’ll write code inside of it
    
     You’ll have to put all needed JavaScript files in the /scripts folder, in the root of the WordPress install, and the css files respectively in /styles folder. 
    
    Then, in the functions.php from your MyFavoriteTheme-child folder you have to insert the following text:
    
    <?php
    $path_to_scripts = "/scripts/";
    $path_to_styles = "/styles/";
    
    function register_syntaxhighlight() {
      wp_enqueue_script('shcore',  $path_to_scripts.'shcore.js');
    
      wp_enqueue_script('shbrushcsharp', $path_to_scripts.'shBrushCSharp.js');
      wp_enqueue_script('shbrushcpp', $path_to_scripts.'shBrushCpp.js');
      wp_enqueue_script('shbrushcss', $path_to_scripts.'shBrushCss.js');
      wp_enqueue_script('shbrushobjc', $path_to_scripts.'shBrushObjC.js');
      wp_enqueue_script('shbrushjscript', $path_to_scripts.'shBrushJScript.js');
      wp_enqueue_script('shbrushphp', $path_to_scripts.'shBrushPhp.js');
      wp_enqueue_script('shbrushplain', $path_to_scripts.'shBrushPlain.js');
      wp_enqueue_script('shbrushruby', $path_to_scripts.'shBrushRuby.js');
      wp_enqueue_script('shbrushsql', $path_to_scripts.'shBrushSql.js');
      wp_enqueue_script('shbrushxml', $path_to_scripts.'shBrushXml.js');
      wp_enqueue_script('shbrushas3', $path_to_scripts.'shBrushAs3.js');
      wp_enqueue_script('shbrushjava', $path_to_scripts.'shBrushJava.js');
      wp_enqueue_script('shbrushSql', $path_to_scripts.'shBrushSql.js');
    
      wp_enqueue_script('shstarter', $path_to_scripts.'shstarter.js', array('shcore'));
    
      wp_enqueue_style('shcore',  $path_to_styles.'shcore.css');
      wp_enqueue_style('shThemeDefault', $path_to_styles.'shThemeDefault.css');
    }
    
    add_action('init', 'register_syntaxhighlight');
    
    ?>
    
    If you want to run javascript examples within individual posts, by default they'll be removed as a security feature, so it'll be untidy to allow this.


  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    Drupal, Joomla or Wordpress should all do this with the right plugins.


  • Advertisement
Advertisement