• Home
  • Contact Us
  • Privacy Policy
  • Disclaimer
BTemplates Hive
  • BTH Home

    Welcome
  • Blogger DIY Tutorials

    Make your blog awesome
  • Blogger Templates

    Choose Layout Style
    • 1 Column
    • 2 Column
    • 3 Column
    • 3 Column Footer
    • 4 Column Footer
  • Blogger Widgets

    Powerup your Blog
  • Template Reviews

    Our Honest Opinion
  • Coupons

    Freebies
Showing posts with label Blogger Tutorials. Show all posts
I have recently stumbled upon a great jQuery plugin which allows you to display date-stamps in an appealing style. Guess what? It's the same fuzzy date format that we often see on comments section like 'Commented 2 minutes ago' or 'Updated 3 days ago' etc. While this was available for free, I kept wondering how to install TimeAgo jQuery plugin on Blogger?


Being one of a jQuery plugin, it was not that difficult to integrate it with blogger. Infact, this particular plugin was even easier to setup than any other similar script. We just need to add the jQuery library (if not already available), add TimeAgo script and use appropriate class to get the desired result.

Let me guide you in a step-by-step approach. First go to Edit HTML section of your Blogger Blog and search for </head>. Now paste the following line of code just before the closing head tag.

<script src='http://code.jquery.com/jquery-latest.js'></script>
<script src='http://timeago.yarp.com/jquery.timeago.js'></script>
<script>
    jQuery(document).ready(function($){
     $("abbr.timeago").timeago()

Now, remember that if you are already using jQuery plugins, you most probably also have the jQuery library installed. In that case, you do not need to add Line 1 of the code snippet above.

Now, find the code that renders the date/time stamp on your blogger blog. Here, you will actually be looking for the following line on your blogger template.

<h2 class='date-header'><span><data:post.dateHeader/></span></h2>

You have to replace the above line with the following code snippet.

<abbr class="timeago" expr:title="data:post.timestampISO8601"><data:post.dateHeader/></abbr>

Now, save the template and Voila! Your date-stamp is now converted into TimeAgo format.

Do try this TimeAgo Blogger Plugin on your blog and don't forget to share your feedback about this awesome Blogger Widget by commenting below.
Tweet
Today, we have an interesting topic to discuss. The scene is - "You have a Blogger blog and you share code snippets, programming tutorials or simply Blogger Tutorials just like this one"". In this regard, let me reiterate that "Content is king" and readers are always in a hunt for awesome articles but the one that really converts them into returning visitors or more specifically, active followers, are the one's which is presented in a professional way or more precisely, in a readable format.


Apart from an elegant, clean & professional template, you must also stress on the post formatting in a way that appeals all the readers. In this article, we will be guiding you on How to use prettify with blogger/blogspot to publish code snippet using <code> or <pre> tag in Blogger.

So, what is Prettify?

Well, Prettify is a combo of a Javascript module and the CSS that can be used as syntax highlighter for code snippets in any HTML page (which in our case is on Blogger).

If you want to see a demo of how it looks like, you may preview it on this blog itself which is used on article pages such as the Blogger Print CSS tutorial or preview it with a small example below.

CSS:
body {
background: #eee;
font-family: Georgia;
}
#wrapper {
width: 100%;  /* reset width of the main wrapper */
margin: 0 auto;
}

How to install Google Code Prettify Plugin on Blogger?

Before installing the plugin, we insist that you note down few facts about Prettify to understand how it works. This syntax highlighter plugin consist of a JS file, CSS (or Prettify theme) & extensible language handlers. While Prettify can work without specifying the language with C-like, Bash-like, and XML-like languages, other languages are supported through extensible language handlers.

Some of the extensible language handlers are CSS, SQL, Visual Basic etc.

Now, let's get back to the point. In order to install Prettify on Blogger/Blogspot, first of all paste the following JS file just above </head> tag.

<script src='https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js'/>

You can then go to this Google Code page and choose one Prettify theme to use with Blogger. You can accordingly add the CSS files of any desired theme by pasting it above </b:skin> tag.

We have been using a modified version of Sunburst theme in this blog with improved line numbers and better alignment. The CSS code is shared below:-

pre.prettyprint { display: block; background-color: #111;white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap; }
pre .nocode { background-color: none; color: #000 }
pre .str { color: #ffa0a0 } 
pre .kwd { color: #f0e68c; font-weight: bold }
pre .com { color: #87ceeb }
pre .typ { color: #98fb98 } 
pre .lit { color: #cd5c5c } 
pre .pun { color: #fff }    
pre .pln { color: #fff }    
pre .tag { color: #f0e68c; font-weight: bold } 
pre .atn { color: #bdb76b; font-weight: bold } 
pre .atv { white-space: normal;color: #ffa0a0 } 
pre .dec { color: #98fb98 } 
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } 
li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9 {list-style-type: decimal!important;}
li.L1,li.L3,li.L5,li.L7,li.L9 {background: none!important;}

@media print {
  pre.prettyprint { background-color: none }
  pre .str, code .str { display:block;color: #060 }
  pre .kwd, code .kwd { display:block;color: #006; font-weight: bold }
  pre .com, code .com { display:block;color: #600; font-style: italic }
  pre .typ, code .typ { display:block;color: #404; font-weight: bold }
  pre .lit, code .lit { display:block;color: #044 }
  pre .pun, code .pun { display:block;color: #440 }
  pre .pln, code .pln { display:block;color: #000 }
  pre .tag, code .tag { display:block;color: #006; font-weight: bold }
  pre .atn, code .atn { display:block;color: #404 }
  pre .atv, code .atv { white-space: normal;display:block;color: #060 }
}

Save the template and you are good to go.

Usage

Using Prettify Plugin in Blogger is easy. You just need to add the Prettify class while using it with <code> or <pre> tag as shown below:-

<pre class="prettyprint">
// Your code snippets here...
</pre>

To enable line numbers, you may use the following pattern:-

<pre class="prettyprint linenums">
// Your code snippets here...
</pre>

To add an extensible language handlers like CSS, add ?lang=css on the main JS files.

<script src='https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=css'/>

For using extensible language handlers like CSS, you need to specify the language.

<pre class="prettyprint linenums lang-css">
// Your CSS codes here...
</pre>

That's all for today. Hope this tutorial has guided you well for successfully installing Prettify Plugin on Blogger. Do write back if you have any query or otherwise leave your feedback below.
Tweet
Do you maintain a Blogger blog and struggling to make it look professional and feel premium? Well, it's not just the blogger template that matters, but the features and ease of use offered to the readers are the real factors among all other things. Popular blogs have always something new to offer and along with the awesome content published by them, some features impresses a lot.

Today, we are going to discuss about making your Blogger blog printer friendly. As you might have already noticed, regular non-optimized blog often results in a cluttered layout when you print any page. This is quite annoying as it results in wastage of paper and spoils the blog's branding.

For example, you may print preview this page from the Desire Mag Premium blogger template and see for yourself what we are trying to explain. So, how is this actually done?

Well, it is very simple and you do not need to play with lot of codings, javascripts etc. A simple media query does it all and you can get rid of any distracting element from the print page.

@media print { /* declaring the css media query */
#sidebar, 
#footer,
#comments, 
#nav {display: none!important;} /* removing unnecessary elements */
#wrapper, 
#content {width: 100%!important;} /* make content fit the page width */
.entry:after{
display: block;
content: "Copyright Notice: Unauthorized use and/or duplication of this material without express and written permission from this blogs author and/or owner is strictly prohibited.";
margin-top: 30px;
line-height: 21px!important;
font-family: 'Droid Serif','Georgia','Serif'!important;
font-size: 14px!important;
color: black!important;
border-top: 1px dotted #555;
padding-top: 8px;
text-align: center;
padding-bottom: 10px}
}  /* css media query ends */

The above CSS codes are just a sample of how a blogger blog can be made printer friendly. The actual CSS will vary with each blog depending on its structure and definitions used.

How to implement?

While the use of print media query is applicable for all platforms, Blogger users may place the above media queries in Edit HTML mode just above </b:skin> or otherwise go to Templates ► [Customize] and then [Advanced] ► [Add CSS] and paste the codes in the box preferably at bottom..

Now, let us explain to you what we have done with those code as show above. The concept is as simple as shown below but requires the knowledge of CSS to execute.

@media print {
Place your CSS codes here...
}

In other words, @media print{} allows you to define a separate stylesheet for your blog which is also called the 'Print CSS'. Here, you can reset the width of the content wrapper, hide all unwanted <div></div> such as for Sidebar, Footer, Comment, Share buttons, Header, Navigation Menu etc. and also add a footer note with QR Code as shown in line no.8-21 in the above code box.

The Print CSS will be effective only for the Print version of the page and as such you can easily target what to display and what not to within the print page. If you want to add a QR Code at bottom of the page, then you may consider to add the following line (refer line no.2-8) below:-

@media print {
body:after{
content: url(https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=http://your-blog.blogspot.in//&choe=UTF-8);
padding: 3px 5px;
display: block;
text-align: center;
margin: 0 auto;}
Place your CSS codes here ...
}

A lot of references are also available when you search about CSS3 Media Queries in search engines. The compatibility of these media queries is decent in all widely used browsers. A snapshot of the same can be seen below which indicates compatibility in both Desktops & Mobile browsers.


We hope this article would be useful for all the Blogger users and would like to invite your feedback on it. Do comment below if you have any query related to the use of Print Media Query.
Tweet
Older Posts

Connect with us

Join us on Facebook

Now Trending

Templates/Widgets/Tuts
  • Simplex Creative Parallax Blogger Template (Free Premium)
  • BoardMag Parallax One Page Portfolio Blogger Template
  • esoTalk Blogger Forum Template
  • Parix Parallax One Page Portfolio Blogger Template

Contact Form

Name

Email *

Message *

Category

  • 2-Column
  • Blogger Template
  • Blogger Tutorials
  • CSS
  • Free
  • Paid
  • Parallax
  • Responsive

Recent Comments

© 2014-15 | Blogger Templates Hive - Premium Blogger Templates

  • Home