Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Starting a blog

  • 05-04-2011 2:45pm
    #1
    Registered Users, Registered Users 2 Posts: 9,023 ✭✭✭


    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 Posts: 2,426 ✭✭✭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,023 ✭✭✭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,023 ✭✭✭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: 2,426 ✭✭✭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