User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Fri Jul 24, 2009 6:32 am

You're going to hate this one... :drevil:

Question
Is there a way to determine that you are processing the last feed item in a {%REPEAT% FeedItems}{%/REPEAT%} loop?


My preliminary findings
I've tried to find a way to do it and I don't see how it can currently be determined. If you knew that a certain parameter did not have a value you could use the conditional section to output, or omit outputting, something; but since we don't have control over the feed items we can't guarantee that the last feed item will have, or not have, a certain value.

I found the {%FEED-ITEM-COUNT-INFO%} and {%SEARCH-RESULT-COUNT-MSG%} parameters but I don't think these alone will work.

I've also seen a "Template parameters" dialog box within the "Channel report" dialog box but these look like they are static values added by the user.


Of course, at this point you're thinking... what on earth are you trying to do? :roll:
Basically, I'm creating a Channel Report that will output 1) HTML and 2) JavaScript where the JavaScript block contains a JSON array of feed item data that will be embedded in the <head> of the HTML page and will be processed by some linked JavaScript to display something that you've never seen a feed reader display.

It will elicit some "oohs" and "ahhs", and a few "cool"s, and some may find it beneficial, and some may say it's all "smoke and mirrors" and not really all that useful. But as a Channel Report it could be automatically FTP'd to a web server and made available to many eyeballs.


Here's a scaled-down example of the problem

Code: Select all

var theArray = [FeedTitle1, FeedTitle, FeedTitle3,];

It's that last comma before the "]" that's causing the problem. Syntactically, that last comma shouldn't really be there. Internet Explorer throws a script error (tested in IE6, IE7 & IE8), Firefox 3 is more forgiving and ignores it, but it'd really be nice to have it work in both browsers; so a way to know that this is the last feed item and be able to add or omit some output would be very beneficial. And if this request is ever implemented, it might make sense to have a way to know if it's the first feed item too.


Harebrained proposal :blink:
It seems like if there were a {%ITEM-METADATA% count} parameter that would spit out the current feed item's number within all of the feeds items being processed by the loop and a conditional way to say {%?ITEM-METADATA% count == %ITEM-METADATA% itemcount} (where {%ITEM-METADATA% itemcount} gives you the total number of items being processed by the loop) so you could tell if you were on the last item, and {%?ITEM-METADATA% count == 1} would tell you that you're on the first item; that seems like it would do the trick.

Alternatively {%?ITEM-METADATA% firstitem} and {%?ITEM-METADATA% lastitem} conditional sections would also work.


Thanks for listening
I know this is a bit of a corner case and I know this is probably not an easy thing to implement and I know it's way too late for the 2.4.1 release, but I thought I'd mention it anyway. You are the innovator in ATOM/RSS. If the marriage of feed data and JSON is ever going to happen; you, my friend, will preside over the wedding. :bow:

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Fri Jul 24, 2009 12:15 pm

kevotheclone wrote:You're going to hate this one... :drevil:

Only because I've been there before and didn't fix it... :|

kevotheclone wrote:I found the {%FEED-ITEM-COUNT-INFO%} and {%SEARCH-RESULT-COUNT-MSG%} parameters but I don't think these alone will work.

No, these are just static messages.

kevotheclone wrote:I've also seen a "Template parameters" dialog box within the "Channel report" dialog box but these look like they are static values added by the user.

That's correct.

kevotheclone wrote:It seems like if there were a {%ITEM-METADATA% count} parameter that would spit out the current feed item's number within all of the feeds items being processed by the loop and a conditional way to say {%?ITEM-METADATA% count == %ITEM-METADATA% itemcount} (where {%ITEM-METADATA% itemcount} gives you the total number of items being processed by the loop) so you could tell if you were on the last item, and {%?ITEM-METADATA% count == 1} would tell you that you're on the first item; that seems like it would do the trick.

There is already a <tt>{%REPEAT-NUMBER%}</tt> parameter that returns, well, the repeat number when you're in a <tt>{%REPEAT%}</tt> loop. It's not used anywhere, which is why I guess you didn't know about it (jeez, you didn't run <tt>strings</tt> on the Awasu EXE's? :roll:). Adding another parameter that returned the total number of iterations would be tricky (since it's usually not known in advance), and adding the ability to compare the two would be a non-trivial job as well.

Now, if you cast your mind back to the start of this reply, I said that I'd been here before. First time was ages ago when I added support for Atom. This allows for multiple authors for a feed item and I wanted to show them in the channel pages separated by a comma. I ran into exactly the same problem you did and eventually <strike>couldn't be bothered</strike> didn't get around to implementing a solution and just separated them with spaces :roll:

I ran into the same problem again when implementing Send-To tools. If you look in the channel template files, you'll see that the <tt>{%REPEAT%}</tt> tags have <tt>header=...</tt> and <tt>footer=...</tt> parameters, which specify text that gets inserted into the output before and after the repeated items (as long as there's at least one). Now, these don't help you but...

...I've added support for a new <tt>insert=...</tt> parameter that specifies text that will get inserted in between repeated items, so in your case, you would just set it to be a comma. I've just sent you a new build.

kevotheclone wrote:I know it's way too late for the 2.4.1 release, but I thought I'd mention it anyway.

It's a fairly easy change and since it's an addition of a new parameter, it should be fairly low risk (famous last words :unsure:).

kevotheclone wrote:You are the innovator in ATOM/RSS. If the marriage of feed data and JSON is ever going to happen; you, my friend, will preside over the wedding. :bow:

Yikes. It sounds like you're going to be the best man... :whistle:

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Sat Jul 25, 2009 8:44 am

Your solution worked great! Thanks for the quick turnaround! ::-):
I've replied to your email with a copy of the Channel Report Template as it stands today (still a work in progress).
jeez, you didn't run strings on the Awasu EXE's

No, but I have previously extracted the "Sachurazi" and "Cow" sounds out of the EXE (I missed the "classic" Sachurazi sound). :(

Previously I did notice the "header=" and "footer=" attributes, but I forgot about them; and {%REPEAT-NUMBER%} is metioned in Awasu's Help file and I've seen it before but in my haste yesterday I didn't search for the right word "REPEAT", so I didn't find it.

I ran all of my existing Channel Reports and didn't see any conflict with the new "insert=" attribute.

There's still one problem in this marriage of feed item data and JSON, but it's a JavaScript/JSON thing and I don't expect you to try to fix it. I don't think there is a way express a String literal that has embedded carriage returns/new line characters; e.g. the following code generates an JavaScript error:

Code: Select all

var desc = "this is a
big post with
embedded carriage returns";


Now you could probably build some kind of "encode=json" functionality that would replace carriage returns with \r and new line characters with \n, but I think that would be a bit much to ask for right now (it'd also need to escape apostrophes \' and quotes \").

So right now, this Channel Report Template will not be able to display the feed item Description directly, insead the user will have to click the link to see the Description.

I'm also working on another variation on this same type of Channel Report Template, where the feed item data is in XML format. In this case the XML-based feed item data cannot be embedded within the HTML file. so the entire Channel Report wouldn't be as self-contained in file file and instantly viewable in Awasu; instead the XML-based feed item data could be saved to a file or FTP'd to a place where the HTML expects to find it and the HTML would load it in via a URL.

For you guys following along at home, I'll give you more details about what this Channel Report does in a seperate post; it's alte and I'm gonna get some "shut eye". :asleep:

Thanks again! :bow:
Last edited by kevotheclone on Fri Aug 07, 2009 5:23 am, edited 1 time in total.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Jul 25, 2009 11:30 am

kevotheclone wrote:I've replied to your email with a copy of the Channel Report Template as it stands today

That's insanely cool! :clap:

kevotheclone wrote:I don't think there is a way express a String literal that has embedded carriage returns/new line characters

Do it like this:

Code: Select all

{%ITEM-METADATA% description encode=percent chars='"}


"percent" encoding will encode anything with an ASCII code <32, a percent sign, or any of the characters you specify. You can then decode it all back in the JavaScript.

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Sun Jul 26, 2009 12:14 am

Today I could really use a "man bitten by dog" emoticon, 'cause that's how my morning started. :bigshock: My forearm is a little sore, but I'll be ok, so anyway...

support wrote:That's insanely cool! :clap:


Thanks! I knew I'd get a "cool" out of someone, glad to hear it from you.

You're right about the percent encoding, it worked. And it's right there in the help file, I guess I need to read it more closely. :oops:

I used the built-in JavaScript unescape() function to convert the percent encoding into a plain old string that JavaScript is happy with.

I've got more work to do on this before it's ready for Awasu's wiki. I may add some filtering and highlighting capability, so you can type some text into a text box and either filter or highlight certain feed items; it's built into the JavaScript library that I'm using so it's not too difficult to add this. And the balloons need some formatting too. Also, I may try to create a version of this that uses the "Template parameters" dialog box within the "Channel report" dialog box to pass in parameters to determine the time scale that is used in the display because if there are a lot of feed items that appear in a short time span you'll want to use a different scaling than if the feed items are spread out more sparsely.

I'll write another post later today explaining what this Channel Report Template does and provide a link to a non-feed-item example for those of you following along.

<tweet>
It's time to re-clean my wound.
</tweet>

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Sun Jul 26, 2009 5:27 am

support wrote:That's insanely cool! :clap:

We all know about "insanely cool", 'cause we use Awasu!

The Channel Report Template (CRT) we've been discussing displays feed items in a left-to-right timeline using the Simile Timeline library.

Here's an example of a Timeline of the events surrounding the assignation of US President John F Kennedy (JFK). Many more examples are available here and here (older, some dead links). This one, Religion Timelines, features both the Filter and Highlight functionality.

Depending upon the number of the feed items in a given unit of time the display may be very crowded or it may contain large areas with no posts, so choosing the correct unit of time (Day, Week, Month, Year) with the number of feed items and the range of dates can greatly affect the displayed output. I'll attempt to find some guidelines based upon my Channels and try to add a reasonable amount of JavaScript "smarts" as I can before I upload it to Awasu Wiki. I may end up posting several different versions of this CRT, with some suggested guidelines in a ReadMe.txt file.

Note in the JFK example there is a mixture in the date/time units as the upper bad contains Daily sections, Weekly sections, hourly sections and even sections as small as 10 minutes. So the Simile Timeline library is pretty versatile and with enough effort you could actually pre-analyze the feed item data (stored in JSON format) with JavaScript and then dynamically customize the timeline so that it's display would never be too dense or too sparse.

Simile Timeline, an "insanely cool" JavaScript library, yes it is.

While this isn't really a good CRT for reading each and every feed item; it's a great CRT for zooming out and seeing the feed item activity from a broader perspective. Here's one example where this CRT shines: let's say you make a product and you have a Search Channel or maybe a *Google Application Plugin-based channel that returns feed items every time your production is mentioned. This timeline-based CRT will help to see the overall pattern of activity from a date/time perspective, and can show you how a much "talk" about your product was generated from a specific marketing campaign.

* And if you didn't get a Google SOAP license key, I'll have an alternative Application Plugin that will provide similar capabilities, available from Awasu's wiki in the near future.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 26, 2009 1:14 pm

kevotheclone wrote:Also, I may try to create a version of this that uses the "Template parameters" dialog box within the "Channel report" dialog box to pass in parameters to determine the time scale that is used in the display because if there are a lot of feed items that appear in a short time span you'll want to use a different scaling than if the feed items are spread out more sparsely.
There's also a <i>Templates</i> button in the Advanced tab of the Program Options for setting global template parameters that would apply to all reports. But wouldn't you want to add controls in the report page itself that got the JavaScript to dynamically adjust the time scale itself?

Ha! I get to ask feature requests of you! :whip:
It feels good... :whistle:

kevotheclone wrote:It's time to re-clean my wound.
I'll have a look around for a <i>"too much information"</i> emoticon while I'm at it... :unsure:

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Jul 26, 2009 1:17 pm

kevotheclone wrote:And if you didn't get a Google SOAP license key, I'll have an alternative Application Plugin that will provide similar capabilities, available from Awasu's wiki in the near future.

I'd be interested to see this. I was very disappointed when Google dropped their SOAP interface and replaced it with a JavaScript-only one since it meant it was basically impossible for us to use it.

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Mon Jul 27, 2009 7:41 am

support wrote:I'll have a look around for a "too much information" emoticon while I'm at it... :unsure:


:hysterical: If you add a TMI emoticon I'm sure it'll get lots of use after every one of my forums posts.

support wrote:Ha! I get to ask feature requests of you! :whip:
It feels good... :whistle:


I'm up for the challenge and I'll work on automatic time scaling via JavaScript, but that'll take longer, especially given the small amount of time that I have each week for extending Awasu and the other extensions I've already started, and what with cleaning my wounds and all... oops... I forgot TMI! I'd kind of like to release a 0.5 version of the "Timeline" Channel Report Template (CRT) using the "Template parameters" dialog box within the "Channel report" dialog box to specify the time scale for a variety of reasons:
    1) I could get it to the wiki much sooner
    2) Awasu users could start using it and hopefully provide some feedback
    3) It would force me to learn to use and understand "Template parameters". I believe I can use Conditional Sections in the CRT to output default values if the parameter is not defined, but allow the defaults to be overridden if the parameter is defined; I'm not sure about this that's why I'd like to test it and learn.
    4) It would force Awasu users to use and understand "Template parameters". I don't believe this feature is documented anywhere (help file, wiki, example CRTs), this timeline CRT could help familiarize Awasu user's with "Template parameters" and serve as an example.

Simile Timeline's Achilles' Heel
One of Simile Timeline's deficiencies is vertical scrolling. Out of the box there is seemingly no provision for scrolling the events in a band up and down. So if you have too many events clustered together in a short time frame some of the event will not display at all because they are drawn below the bottom border of the band. This is why it's important to match the correct scaling with the feed items frequency of the feed items. I seen people ask for a solution to this but nobody has written one yet. I'll try a few easy things to see if I can easily solve it but they've probably already been tried and failed.

Template parameters
So for the short term (version 0.5) I'm proposing that I release some a 2, 3 and maybe 4 band (those horizontal timelines are called "bands") versions of the Timeline CRT with instructions so that the user can enter parameters that adjust the scale of each band. So for Earl's feed (who averages a post a day) the user might enter DAY and WEEK in a 2-band version of the Timeline CRT. But for a Google News feed, you might want to use HOUR and DAY when using the same 2-band version of the Timeline CRT.

Auto JavaScript Scaling
I'll need to study the JFK example to find out how set up multiple scales in a single band, as I haven't done this before. I'll also need to figure out how to determine if there are two many feed times for a give time frame, so that I can adjust the time scale to the next larger interval. To do this correctly I'll also have to look at the height of the "main" band in the timeline as different screen resolutions will affect how many feed items can be stacked into a small unit of time before they start getting drawn below the band's lower border. I'll be an interesting project, but one that I doubt will be resolved in the next couple of weeks.

Google Application Plugin alternative
I just emailed you my OpenSearch Application Plugin, see if you think it's "wiki worthy" (basically it uses bing.com, yahoo.com and other search engines directly from within Awasu).

During the course of re-writing the OpenSearch Application Plugin in Python I started thinking of additional features (people call me "the scope creep") and I also had a Application Plugin "epiphany"; that Application Plugin's can be called from Send to and User tools, very cool! :coolthumb:

<tweet>
Went to the Courtland Pear Fair today, very nice, but also very hot.
</tweet>

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Wed Jul 29, 2009 9:01 am

kevotheclone wrote:I also had a Application Plugin "epiphany"; that Application Plugin's can be called from Send to and User tools, very cool!

Except you're not sure what the port number is going to be (it'll be 2604, unless another copy of Awasu is already running somewhere). I'll add something for the next release to let extensions know.


Return to “Awasu - Feature Requests”

Who is online

Users browsing this forum: No registered users and 2 guests