This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes General Computing and the fly likes Blog advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Blog advice" Watch "Blog advice" New topic
Author

Blog advice

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hi,
I was thinking of starting blog and was looking for advice.

I was hoping to get one where it was easy to mark source code - such as it is in this very good web forum and also one that it was possible to embed javascript into my posts.

Any suggestions welcomed!

Thanks

Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
I am using the syntax highlighter from Alexy Gorbatchev: http://alexgorbatchev.com/SyntaxHighlighter/.

Works in two modes: Either by "full" JavaScript where you can just paste the sourcecode into script tags or in a highlight mode where you have to do the HTML escaping (for < and the others). I use the first one, has the disadvantage that the source does not appear in the RSS feed. The script allows easy highlighting of selected lines.

You can integrate it easily where you are allowed to include external JavaScript.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hauke Ingmar Schmidt wrote:I am using the syntax highlighter from Alexy Gorbatchev: http://alexgorbatchev.com/SyntaxHighlighter/.

Works in two modes: Either by "full" JavaScript where you can just paste the sourcecode into script tags or in a highlight mode where you have to do the HTML escaping (for < and the others). I use the first one, has the disadvantage that the source does not appear in the RSS feed. The script allows easy highlighting of selected lines.

You can integrate it easily where you are allowed to include external JavaScript.


Do you use free hosting with wordpress or bloggspot? And if so how do you integrate Alexy Gorbatchev stuff in with it?

Do you have a link to your blog?

Thanks.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

http://blogs.oracle.com/pranav/2008/12/blog_your_code_using_syntaxhig.html
http://neilblackburn.blogspot.com/2009/03/code-syntax-highlighter-for-blogger.html

hope this helps.


http://muhammadkhojaye.blogspot.com/
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Muhammad Khojaye wrote:http://blogs.oracle.com/pranav/2008/12/blog_your_code_using_syntaxhig.html
http://neilblackburn.blogspot.com/2009/03/code-syntax-highlighter-for-blogger.html

hope this helps.


Hi! Thanks for this.

The problem is that most free blogs (wordpress, bloggspot) don't give tha ability to have your own folders where you can neatly store your javascript.

This will mean you end up with some remote calls to Alex's utilities.

does anyone know of some free blogging software where you can have your own folders?

Thanks

Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Why do you want to store the Javascript locally?

With Blogspot/Blogger you can add a HTML/Javascript block to your layout and enter:


In your post you can then:


That's all you need to do.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hauke Ingmar Schmidt wrote:Why do you want to store the Javascript locally?

With Blogspot/Blogger you can add a HTML/Javascript block to your layout and enter:


In your post you can then:


That's all you need to do.


I'm afaird my javascript / blog knowledge isn't that good, so you're going to have to be patient with me :-)

When you said "... add to your layout" or yuo saying have to add this to every single post or something that is in the template?

Many many thanks!
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
No, it is a one-time thing. With Blogspot you (can) compose your page design by dragging boxes to slots (e.g. Header, Archive, Attribution, Blog posts...). These are rendered on every page. One type of box is simply HTML/Javascript where you can enter code at your own.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hauke Ingmar Schmidt wrote:No, it is a one-time thing. With Blogspot you (can) compose your page design by dragging boxes to slots (e.g. Header, Archive, Attribution, Blog posts...). These are rendered on every page. One type of box is simply HTML/Javascript where you can enter code at your own.


That's good thanks. I'll try that so. You don't have any step by step guides?

Cheers
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
There is not more to do than I already wrote.

When you created a blog at Blogspot/Blogger you can go to the "Design" tab, click on any "Add Gadget" link, select "HTML/Javascript" and paste the code from my first listing. That's it, now syntax highlighting is enabled.

In your blog post you then put your code in script tags like in the second listing. The code will be formatted.

If you run into any specific blockers, don't hesitate to ask.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Thanks to all.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Oh, I am sorry, I forgot one important thing. You have to include the CSS for formatting. I put them to the code directly, that's why I missed them. Tab Design, Edit HTML. I included the following directly after the title tag.

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Thanks for this. I follow instructions, however, I am having difficulty adding Javascipt code which contains the <SCRIPT> tags.

I try...




I get:

Your HTML cannot be accepted: Closing tag has no matching opening tag: SCRIPT

Any ideas?

Note: My design template view, gives me two places to add the the HTML / Javascript gadget. I chose the top and put in the code you suggested?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
You can't nest SCRIPT tags. What are you trying to achieve by doing that?


Ping & DNS - my free Android networking tools app
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Ulf Dittmer wrote:You can't nest SCRIPT tags. What are you trying to achieve by doing that?


I wish to publish snippets of javascript similar to this blog...

http://www.bloggersentral.com/2010/03/where-to-host-javascript-for-blogspot.html

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
I don't see nested SCRIPT tags on that page ... ?
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Ulf Dittmer wrote:I don't see nested SCRIPT tags on that page ... ?


What I mean is he shows samples of Javascript



These samples begin and end with <script> tags

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
Yes, but you can't nest them - meaning, you can't put one <script>...</script> inside of another one.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Ulf Dittmer wrote:Yes, but you can't nest them - meaning, you can't put one <script>...</script> inside of another one.


Well I am obviously ot explaining this well :-(

I wish to Javascript code to be formatted.
To do this, I am included my javscript code within the blocks...



However the tesxt I wish to display and format begins and ends with the <script> tags.

Many thanks.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Please read the documentation. It covers EXACTLY your problem: http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

- You are missing two important lines from my example listing.
- Why are you using a Java brush for JavaScript?
- When highlighting JavaScript there exists this problem with this (the script) method. This is the only problematic case. You never mentioned JavaScript. But the other method works.
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hauke Ingmar Schmidt wrote:Please read the documentation. It covers EXACTLY your problem: http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

- You are missing two important lines from my example listing.
- Why are you using a Java brush for JavaScript?
- When highlighting JavaScript there exists this problem with this (the script) method. This is the only problematic case. You never mentioned JavaScript. But the other method works.


Ok I get all that.

Thanks a million.

Much appreciated.
kritika das
Greenhorn

Joined: Jun 17, 2011
Posts: 10
This has been very helpful thread, as even i was planing to create a blog of my own.
 
 
subject: Blog advice
 
Similar Threads
To bloggers
Scrollable Table with Jquery?
Table Association is not shown
Types of Blog you'd like to see
SCJA Preparation List