PTG Assignment 2: RSS/Atom Feed Extension for WebDSL

Extend the WebDSL language to allow for the generation of RSS or Atom feeds.

Suggested syntax:

    define feed newsUpdates() {
      feed {
        title { "Website news updates" }
        link { "http://www.website.com" }
      }
      items {
        for(ni : NewsItem) {
          item {
             title { output(ni.title) }
             date { output(ni.date) }
             author { output(ni.author.name) }
             description { output(ni.content) }
          }
        }
      }
    }

Adapt your solution to assignment 1 to use this new language construct to enable someone to subscribe to the link stream of a user or a group of users.

Background information

Wikipedia:

RSS (Really Simple Syndication) is a family of Web feed formats used to publish frequently updated content such as blog entries, news headlines or podcasts. An RSS document, which is called a "feed," "web feed," or "channel," contains either a summary of content from an associated web site or the full text. RSS makes it possible for people to keep up with their favorite web sites in an automated manner that's easier than checking them manually.

RSS content can be read using software called an "RSS reader", "feed reader" or an "aggregator". The user subscribes to a feed by entering the feed's link into the reader or by clicking an RSS icon in a browser that initiates the subscription process. The reader checks the user's subscribed feeds regularly for new content, downloading any updates that it finds.

Links

Example feed (RSS 2.0):

    <?xml version="1.0"?>
      <rss version="2.0">
      <channel>
        <title>Lift Off News</title>
        <link>http://liftoff.msfc.nasa.gov/</link>
        <description>Liftoff to Space Exploration.</description>
        <language>en-us</language>
        <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
        <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <generator>Weblog Editor 2.0</generator>
        <managingEditor>editor@example.com</managingEditor>
        <webMaster>webmaster@example.com</webMaster>

        <item>
          <title>Star City</title>
          <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
          <description>How do Americans get ready to work with Russians aboard the
            International Space Station? They take a crash course in culture, language
            and protocol at Russia's Star City.</description>
          <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
          <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
        </item>

        <item>
          <title>Space Exploration</title>
          <link>http://liftoff.msfc.nasa.gov/</link>
          <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada
            will experience a partial eclipse of the Sun on Saturday, May 31st.</description>
          <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
          <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
        </item>

        <item>
          <title>The Engine That Does More</title>
          <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
          <description>Before man travels to Mars, NASA hopes to design new engines
            that will let us fly through the Solar System more quickly. The proposed
            VASIMR engine would do that.</description>
          <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
          <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
        </item>

        <item>
          <title>Astronauts' Dirty Laundry</title>
          <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
          <description>Compared to earlier spacecraft, the International Space
            Station has many luxuries, but laundry facilities are not one of them.
            Instead, astronauts have other options.</description>
          <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
          <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
        </item>
      </channel>
    </rss>

Installation

Download the WebDSL source code from subversion: svn co https://svn.cs.uu.nl:12443/repos/WebDSL/webdsls/trunk webdsl

Build it and install it locally as follows:

cd webdsl
./bootstrap
./configure --prefix=/home/ubuntu/programs/webdslRss
make && make install

The first three commands only have to be executed once, repeat the fourth to build and install the new version of WebDSL that you created. Keep in mind that after executing the above commands, you have two versions of WebDSL on your system. The first is the one that was pre-installed on the virtual machine. The second is the one you just installed and are going to adapt. The original WebDSL can still be called using the command webdsl. The new WebDSL can be called using the command ~/programs/webdslRss/bin/webdsl (since that is where you installed the binaries).

Approach

Put your solution in a separate file called "rss.str" in the src/org/webdsl/dsl/modules directory. Be sure to include an accompanying .meta file, which determines the syntax it uses. Any changes to the syntax should be done in a file "rss.sdf", in the src/org/webdsl/dsl/modules directory. Include the file in the main grammar by adding an import definition to the src/org/webdsl/dsl/syntax/WebDSL.sdf (i.e., imports rss). Try to change as little as possible in other parts of the WebDSL compiler; this should be a modular extension of the WebDSL generator. If you do (which is not unlikely), document any such changes in a separate document.

The simplest way to approach this problem is by closely studying what code is generated for pages (JSF and Java files) and reusing parts of this infrastructure. In essence a feed is no different than a page, it just has a different, more restricted format. Note: do not worry about content-types. Strictly speaking RSS and Atom require to send a different content-type HTTP header than the standard (text/html). If you figure out how to set the content type, great, if not, don't spend too much time on it.

Tips

  • To get started, it's probably a good idea to follow the Stratego tutorial and browse through the documentation (see the course page). From there, you should explore the WebDSL sources. The main body of the language's syntax is defined in the src/org/webdsl/dsl/syntax/WebDSL.sdf file, while the .str (Stratego) files in the src/org/webdsl/dsl/ subdirectories define the semantics.

  • You can play around a bit with the Stratego language using the stratego shell, which can be installed by following the instructions above. Start it with the 'stratego-shell' command, and be sure to start your shell session with a 'import libstratego-lib' command.

  • While this is thoroughly covered by the documentation, working with concrete syntax for the first time can be a bit tricky. Therefore, some pointers:

  • The .meta file accompanying each stratego file determines the syntax used in that file. To enable use of quoted WebDSL, Java, and XML, the contents of this file should be:

    Meta([Syntax("Stratego-WebDSL-Java-XML")])

    • There are different (anti-)quotations and meta-variables for different language elements. Have a look at the existing sources to get a feel of this, and be sure to check the definitions in src/org/webdsl/dsl/syntax/WebDslMix.sdf. The definition for embedded Java and XML can be found using the 'locate' command: locate EmbeddedJava.sdf; locate Stratego-xml.sdf.

    • The WebDSL generator uses quotations for multiple embedded languages. To avoid ambiguities, always use the most explicit quotation form. I.e., to quote a null expression, write: java |[ null ]| or webdsl |[ null ]| (don't simply write |[ null ]|).

    • Finally, using concrete syntax may not always be the best approach. You can always fall back on the abstract syntax, even if it reduces readability!

Possible extras

  1. Support both RSS and Atom and implement this in an elegant way
  2. Add support for generated RSS pages, similar to the generated pages already available in WebDSL. For example, a default page rss-user could be generated for entity type 'User', listing the latest users. Similar default pages could be generated for all entity types. This requires the addition of an implicit 'date' property to all entity types.

Submission

Please ensure your submission compiles before submission. Submit all source files in the src/org/webdsl/dsl directory. Please first remove all binary files using the make clean command, and do not include the (large) src/org/webdsl/dsl/project directory. Any changes you make to files other than the Stratego and syntax file specified above should be documented.

The deadline for this and the previous assignment is on the 28th of March

Contributions by SanderVermolen LennartKats