Julia
Julia аватар
User offline. Last seen 5 недель 2 дня ago. Не в сети
Зарегистрирован(а): 07/06/2007

How to simply create a RSS Feed from a text file

rssfeedIf you need to generate a RSS Feed from scratch - for example for an html static website or a site which is not your own - you can of course download some softwares to do so but after trying many of them, I didn’t find them as productive as I wish so I decided to use my favorite scripting language to do so.

If you have followed past tutorials like this one, the script should be easy to understand so I won’t comment it as you should understand it by just reading the source code below. To test it, just copy and paste it in rebol’s console then type genrss and result should be copied to the clipboard.



datas: [
"Creating an OData API for StackOverflow including XML and JSON in 30 minutes"
http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludin...
{I emailed Jeff Atwood last night a one line email. "You should make a StackOverflow API using OData." Then I realized that, as Linus says, Talk is Cheap, Show me the Code. So I created an initial prototype of a StackOverflow API using OData on an Airplane. I allocated the whole 12 hour flight. Unfortunately it took 30 minutes so I watched movies the rest of the time.}
"2010-03-28 09:29"

"Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong"
http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyY...
{I did a talk on Deployment called "Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong." }
"2010-03-24 10:36"

"ASP.NET MVC 2 Released"
http://www.hanselman.com/blog/ASPNETMVC2Released.aspx
{ASP.NET MVC 2 is out. This means, it's released. It's final. Use it. Love it.

You can download it directly, or install it (and whatever else you like) with the Web Platform Installer.}
"2010-03-11 09:35"
]    

if exists? %datas.txt [
    datas: load %datas.txt
]

genrss: func[][

item-template: {    
      <%title%>
      <%url%>
      <%description%>
      <%date%>
    
    }

  items: copy ""
  foreach [field-title field-url field-description field-date] datas [
    title: field-title
    url: field-url
    description: field-description
    date: field-date
    append items build-markup item-template
    append items newline
  ]

  template: {<?xml version="1.0" encoding="UTF-8"?>

  
    Sat, 03 Apr 2010 21:52:39 +0200
<%items%>
  
}  

  write clipboard:// build-markup template
]

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->

 

бивает ______________________

бивает

_________________________
[url=http://continent-telecom.com]прямой рекламный номер[/url]

Абсолютно с Вами согласен. В

Абсолютно с Вами согласен. В этом что-то есть и мне кажется это хорошая идея. Я согласен с Вами.

_________________________
рыбалка

Отправить комментарий

Содержание этого поля является приватным и не предназначено к показу.

Подробнее о форматировании

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.