ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* typeset rss feed
@ 2012-04-20 20:15 Jelle Huisman
  2012-04-20 20:40 ` Philipp Gesang
  2012-04-20 21:14 ` Aditya Mahajan
  0 siblings, 2 replies; 4+ messages in thread
From: Jelle Huisman @ 2012-04-20 20:15 UTC (permalink / raw)
  To: mailing ConTeXt users list for

Hello all,

I'd like to typeset an RSS feed and I was wondering whether I could
instruct ConTeXt to fetch the contents of a url like:
http://feeds.bbci.co.uk/news/rss.xml
Thanks for any pointers,

Jelle
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typeset rss feed
  2012-04-20 20:15 typeset rss feed Jelle Huisman
@ 2012-04-20 20:40 ` Philipp Gesang
  2012-04-20 20:47   ` Jelle Huisman
  2012-04-20 21:14 ` Aditya Mahajan
  1 sibling, 1 reply; 4+ messages in thread
From: Philipp Gesang @ 2012-04-20 20:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1530 bytes --]

Hi Jelle,

On 2012-04-20 16:15, Jelle Huisman wrote:
> Hello all,
> 
> I'd like to typeset an RSS feed and I was wondering whether I could
> instruct ConTeXt to fetch the contents of a url like:
> http://feeds.bbci.co.uk/news/rss.xml
> Thanks for any pointers,

the fetching part is easy as we have LuaSocket:

········································································
\starttext
\startluacode
  local bbc_rss = socket.http.request"http://feeds.bbci.co.uk/news/rss.xml"
  context["type"](bbc_rss)
\stopluacode
\stoptext \endinput
········································································

In your document, however, you will want to save the file locally
for a given Context session and reuse the local copy to avoid
re-fetching it on every pass. Maybe use the timestamp to force
a fresh fetch after some time.

Regards
Philipp


> 
> Jelle
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typeset rss feed
  2012-04-20 20:40 ` Philipp Gesang
@ 2012-04-20 20:47   ` Jelle Huisman
  0 siblings, 0 replies; 4+ messages in thread
From: Jelle Huisman @ 2012-04-20 20:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 04/20/2012 04:40 PM, Philipp Gesang wrote:
> Hi Jelle,
> 
> On 2012-04-20 16:15, Jelle Huisman wrote:
>> Hello all,
>>
>> I'd like to typeset an RSS feed and I was wondering whether I could
>> instruct ConTeXt to fetch the contents of a url like:
>> http://feeds.bbci.co.uk/news/rss.xml
>> Thanks for any pointers,
> 
> the fetching part is easy as we have LuaSocket:

Hi Philip,

Thank you, that was precisely what I was looking for. I knew that I had
seen LuaSocket before, but I could not find it.

Jelle
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: typeset rss feed
  2012-04-20 20:15 typeset rss feed Jelle Huisman
  2012-04-20 20:40 ` Philipp Gesang
@ 2012-04-20 21:14 ` Aditya Mahajan
  1 sibling, 0 replies; 4+ messages in thread
From: Aditya Mahajan @ 2012-04-20 21:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 20 Apr 2012, Jelle Huisman wrote:

> I'd like to typeset an RSS feed

I was also recently thinking along these lines (set a cron job to typeset 
RSS feed into pdf and email to kindle). So, please release your code 
once you are done.

> and I was wondering whether I could
> instruct ConTeXt to fetch the contents of a url like:
> http://feeds.bbci.co.uk/news/rss.xml

Suppose you write a macro

      \processrssfile{...}

that takes a local rss file and typesets it, then you can simply call

     \processrssfile{\locfilename{http://feeds.bbci.co.uk/news/rss.xml}}

to process a remote file. ConTeXt downloads and caches the file. On 
subsequent calls, the cached file is used. IIRC, the cache remains valid 
for a day and it is possible to change the threshold after which a new 
file is fetched.

FWIW, I have added this to t-vim.tex so it can pretty-print remote files. 
This only works with http:// or ftp:// and not with https://

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-20 21:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-20 20:15 typeset rss feed Jelle Huisman
2012-04-20 20:40 ` Philipp Gesang
2012-04-20 20:47   ` Jelle Huisman
2012-04-20 21:14 ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).