Sunday, March 31, 2013

Automatic Updating Recipe Index on Blogger- An Update

Have you ever had something that just gnawed at you? It happens to me a lot but I tend to get them resolved reasonably quickly. But this one has hung out there for over a year.

Let me briefly explain what the heck I'm talking about. Food bloggers are starting to list their past post (i.e. recipes) on one "index page" to help visitors find the recipes. Well, most bloggers are making a static page but that requires an update with every post to keep it current. A pain I refuse to do. There is enough to do with cooking, photography, writing, photo editing, posting links to Facebook and much much more. I refuse to update the index manually every time. So my solution was a dynamic page that pulls data from the RSS blog feed and can pull that data and display it as a click-able link. This is call RSS to Java or RSS to HTML.  Original instructions at  Making An Automatic Updating Recipe Index in Blogger

I have not for the life of me been able to get my recipe index to list more than 25 posts under any category. I first published a technique for an automatic updating recipe index for a food blog in November 2011. It worked really neat BUT would only list the latest 25 recipes in any one category. I worked around this by not have "Chicken" as a category but "Chicken - Skinless Boneless" but as I published more, even this did not work well. I lost the earlier posts from the index and hence became hard for visitors to find. I tried multiple techniques, 30 day trials of this software or that web site. Nobody wanted to let me have more than 25. (Actually one did let me have 28...)

The Solution

Before you go any farther, you need to be aware that this will take a few seconds to load on my site with a desktop or laptop with a good connection.  But on something like an iPad or iPhone with a relatively slow processor compared to a real computer, loading is slow if it completes at all. So I use this and then will block copy onto a static page that will load quickly for my visitors. That is what you will see on my site.

The solution comes from Google Feed API in Google Developers Network . From there you can read all about it if you want. Good luck with that. I went to the Code Playground/Blogger/Posts/List Posts. After a lot of play in the playground, I had my solution.

First there is code they want in the Head area of the page. The code is needed but can be placed at the top of the page. Second, the page gets very long so a directory at the top with anchors is a must. Third, the data section for each category must have a unique name. I just went with content1, content2, etc.

Lastly, you CAN NOT do the editing within the Blogger editor if you use the anchors. The Blogger editor will "relate" them back to the location in the editor, not on the site and you are sxxxwed. I use Dreamweaver which I have used for years for other projects. Any HTML editor, many of which are freeware or shareware will do.

Step by Step

1) Open a blank page. Here is the required Java code. Place this at the top

    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript">
      google.load("gdata", "1.x", { packages : ["blogger"] });
    </script> 


2) I now inserted an anchor for the top of the page so readers can clink on a graphic and go back to the top. Plus I used a graphic for the title of the page.

<a name="RETURN TO TOP"></a>
<img src="http://1.bp.blogspot.com/-wFCu1jqlVIA/UCbh5QQdEuI/AAAAAAAAFLs/FNHWABcqKls/s1600/recipe-index1.jpg" width="800" height="150" align="middle"> <br />
<br />


3) I used 3 columns at the top to list all the categories I wanted with links to the anchors that are down the page.

<div style="float: left; width: 30%; padding: 4px;"><i><u style="color: blue;">


insert links to your anchors and categories here like this
<a href="#Bacon">Bacon</a><br />


</div><div style="float: left; width: 30%; padding: 4px;">  

insert more categories here

</div><div style="float: left; width: 35%; padding: 1px;">

and more here

</div>
you will needs lots of line breaks here to space down past the categories


4) Now the code for each category. I start with the anchor that will allow the visitor to jump down the page to the category from the list at the top. Then the title of the category followed by a link back to the top of the page with a graphic that says top. Then a picture and the the Java script to generate the list of posts.

In this example I use "content2" as the name of the content. It must be unique to each category and appears 5 times in this code. You must be sure they all match. Also note the address for the link to the feed specific to my bacon label.

<a name="Bacon"><u><b><span style="font-size: xx-large;">Bacon</span></b></u> </a><a href="#RETURN TO TOP"><img border="0" src="http://3.bp.blogspot.com/-ha2Bgj8RYqM/Tr7KK_O-AfI/AAAAAAAAED4/8N2zTt5kd-4/s1600/top.gif" /></a><br /> <img src="http://3.bp.blogspot.com/-5x74VQR-Ykg/TpCQHtXd53I/AAAAAAAADyY/X6cZRazx-O0/s1600/DSC00630b.jpg" width="240" height="180" /><br />

<script type="text/javascript">
      function _run() {
      var content2 = document.getElementById('content2');
        var bloggerService = new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
 
        var feedUri = 'http://www.101cookingfortwo.com/feeds/posts/default/-/bacon?max-results=100';
 
        var handleBlogPostFeed = function(postsFeedRoot) {
          var posts = postsFeedRoot.feed.getEntries();
          var html = '';
          // Display blog posts
        html += '<dd><ul>';
  for (var i = 0, post; post = posts[i]; i++) {
    var postTitle = post.getTitle().getText();
    var postURL = post.getHtmlLink().getHref();
    html += '<li><a href="' + postURL + '" target="_blank">'
              + postTitle
              + '</a></li>';
  }
  html += '</ul></dd>';
          content2.innerHTML = html;};
        var handleError = function(error) {
          content2.innerHTML = '<pre>' + error + '</pre>';};
        bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
      }
      google.setOnLoadCallback(_run);
    </script>

        <script type="text/javascript">
      google.load("gdata", "1.x", { packages : ["blogger"] });
    </script>
    <div id="content2" style="width:100%;">Loading...</div>


  <br />


Monday, December 31, 2012

A Grumpy Happy New Years

Peter Finch as news anchor Howard Beale in Network
I have made this an annual December 31st event.(It is now officially a tradition with this being the third year)

2 years ago (2010) I heard way too much BS on diets and health going into the New Years holiday. I just couldn't take it anymore so I whipped off an “I’m mad as h_ll, and I’m not going to take this anymore!” post. It felt  so good after and I think it was a great public service announcement. Here's a rerun since it continues today.

Well "they" are on their way out from under their rocks again today and for the next week or two so here is the entire post again...
+++++++++++++++++++++++++++++++++++++++++++
I Call BS


There Are No Silver Bullets Tonto

Happy New Years to All except liars and shysters. A little harsh you say... why you say? It's the season when many of us try to correct our bad habits. And always in the top 5 New Year's resolutions will be get healthier and lose weight.  And I see them coming out from under their rocks.

There will be well meaning (but clueless) experts telling you what to do or eat. I listened to one on the radio this morning. In 20 minutes, she had not one fully true statement. There will be the outright shister wanting you to believe only they have the magic knowledge. There will be compelling stories that are sprinkled with pseudo-scientific BS and if you don't know better, you may believe it. There will be celebrities who you trust making a pitch for this diet plan, that magic supplement or a magic energy bracelet.

Are you really that clueless? Well if you are, I will give you some clues to look for...  

First key phrase that I hate:
  • Supports the Immune System - I don't know what this means and I'm a doctor. I call BS anytime you hear this
  • Increase your metabolic rate - I call BS
  • Burns fat - I call BS
  • Loss weight while you sleep- Really?- A major I call BS
  • Emerging studies or science reveals- I call BS
  • Promotes or Supports whatever - really... then how? prove it sucker - I call BS 99% of the time
  • Colon health - again a 99% bogus phrase to fleece you  - I call BS again
  • The magic of -I don't believe in magic - I call BS
  • Leading experts - you can be sure they aren't - I call BS ever time
  • Antioxidants - not a bad thing by it self but almost always BS- just eat your veggies.
  • Stem cells - I just saw an ad to "turn on" stem cells in the skin. I see a major cancer risk if true. I call BS again 
  • "Detoxifying" What does that mean??? - This one is just plain stupid - I call BS
Other things to watch for:
  •  Infomercial - BAD- Always
  •  Doctor or Dietitian provided to the local TV station by your hospital system - Usually good
  • "Expert" on morning TV- frequently bad- watch for key words. 
  • An advertised product - almost always bad - I will say I believe Weigh Watchers is GOOD for adults.
  • Your PCP (Primary care provider) - Usually good
  • A friend or relative - Almost always wrong. 99.9999%
  • You mother - better than you think usually
Some general rules that may help:
  1. The middle of the bell shaped curve is usually the correct place to be. This means that the mainstream is more likely to be correct then the extremes.
  2. Your local nonprofit hospital system will have you best health in mind.
  3. Almost all PCP's are good resources for you.
  4. Even your insurance company wants you healthy. Even if yours is a blood sucking leach on society, a healthy you is cheaper than a sick you.
  5. Drug companies almost always try to sell inappropriate and expensive drugs.
  6. Most of the time when a insurance company doesn't pay of a $200 or a $500 procedure from your marginal care provider, it is of little or no value. The first clue to these providers is that they don't take insurance because they don't want a third party that has some knowledge taking a close look at them. The shyster will ding you over and over. Run the other way and rescue your friends and family.
  7. If they tell you that doctors or the AMA doesn't want you to know a secret. I again call 100% BS. Hold on tight to your wallet.
  8. NEVER make a major change in your diet or exercise program without consulting you PCP.
Final thoughts:
  1.  A pound of fat is about 3500 calories. So a can of pop or 12 oz of juice a day is 20 pounds of weight gain per year.
  2. Weight is all about calories in and calories out.
  3. Your thyroid is probably fine but your doctor can check. There will always be somebody willing to give you an excuse if you'll pay for it.
  4. A low glycemic diet will help you control your appetite. But be careful what is called low glycemic. I just saw a recommendation for a "healthy" low glycemic breakfast of a glass of OJ with a bunch of heavy cream.. NOT healthy nor low glycemic.
  5. If it sounds stupid or too good to be true , it probably is stupid or too good to be true.
Special note: I'm changing my comment policy for a while so I don't get slammed. I will be approving all comments for now before publishing. If you want to disagree... Start your own blog and say whatever you want. I will publish comments that I consider scientifically sound but ranting or pseudo-scientific BS will not be published.

Sorry, I stepped on toes but it needed to be said.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The end... Now I feel good... I love musing...

May you all have a Healthy and Happy New Years. Bless you all and may your year be full of joy and happiness.

DrDan


Updated

December 31 2012

DrDan

Saturday, December 1, 2012

Greg's Holiday TV Guide

Pop over to Greg's Kitchen for a great list of your favorite Christmas TV shows. Time to set the DVR. I want to watch them all... Special thanks to Greg
http://gregkantner.com/blog/archives/5299