Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.1, 4.0
    • Fix Version/s: None
    • Component/s: Newsfeeds (RSS & Atom)
    • Labels:
      None
    • Environment:
      n/a
    • Browser Version:
      n/a
    • Customer(s):
      Cisco
    • Database:
      n/a
    • JDK Version:
      n/a
    • Level of effort:
      1 week create and test
    • O/S Version:
      n/a

      Description

      It would be useful to me to have a JSON view of the feeds generated from FeedServlet. I'd be willing to do the work to make this happen and donate it back, but as it is to make this happen I'd have to sublcass virtually all of the FeedServlet and I'm trying to avoid too much customization – it would be much nicer to roll this back into Roller.

      Basically as I see it this would involve modifying the FeedServlet and creating several .vm files (such as weblog-entries-json.vm) for the JSON views. Not sure how to handle the XSLT view yet.

      Does anyone see any good reason not to do this?

        Activity

        Hide
        Allen Gilliland added a comment -

        I like the idea of having support for JSON as an output format for weblog data. I don't think this really has to have anything to do with the feeds though since JSON isn't so much about feeds as it is just another data output format (other than html or xml).

        I think the best approach would be to create a new JSONServlet which can use its own templates for doing JSON output and we would probably set it up so that it would allow for grabbing entry data and comment data. I suppose we could provide access to other data such as bookmark data, referrer data, etc, but i'm not sure what the use case would be for that stuff.

        Urls might be something like ...

        /<weblog>/json/entries
        /<weblog>/json/entries?anchor=<anchor>
        /<weblog>/json/entries?category=<category>
        /<weblog>/json/comments
        /<weblog>/json/comments?anchor=<anchor>

        I'm not much of a JSON expert, so if someone wants to come up with the JSON formatting I would be willing to do the JSONServlet and all the other stuff.

        Show
        Allen Gilliland added a comment - I like the idea of having support for JSON as an output format for weblog data. I don't think this really has to have anything to do with the feeds though since JSON isn't so much about feeds as it is just another data output format (other than html or xml). I think the best approach would be to create a new JSONServlet which can use its own templates for doing JSON output and we would probably set it up so that it would allow for grabbing entry data and comment data. I suppose we could provide access to other data such as bookmark data, referrer data, etc, but i'm not sure what the use case would be for that stuff. Urls might be something like ... /<weblog>/json/entries /<weblog>/json/entries?anchor=<anchor> /<weblog>/json/entries?category=<category> /<weblog>/json/comments /<weblog>/json/comments?anchor=<anchor> I'm not much of a JSON expert, so if someone wants to come up with the JSON formatting I would be willing to do the JSONServlet and all the other stuff.
        Hide
        Dolan Halbrook added a comment -

        Hi Allen,

        Thanks for responding. There are several ways of creating data using the JSON syntax. The most straightforward is probably to use the libraries available here:

        http://www.json.org/java/index.html

        Even easier might be to use the latest version of XStream, which has some JSON support:

        http://xstream.codehaus.org/

        Finally, one could just create the JSON in Velocity, similar to the way the feeds are created.

        The best source of JSON documentation is really here:

        http://www.json.org/

        ... and it looks like there are quite a few other libraries available besides the ones I've mentioned.

        As I said before, I'd be happy to help work on this – just let me know which parts you'd like me to take care of.

        Show
        Dolan Halbrook added a comment - Hi Allen, Thanks for responding. There are several ways of creating data using the JSON syntax. The most straightforward is probably to use the libraries available here: http://www.json.org/java/index.html Even easier might be to use the latest version of XStream, which has some JSON support: http://xstream.codehaus.org/ Finally, one could just create the JSON in Velocity, similar to the way the feeds are created. The best source of JSON documentation is really here: http://www.json.org/ ... and it looks like there are quite a few other libraries available besides the ones I've mentioned. As I said before, I'd be happy to help work on this – just let me know which parts you'd like me to take care of.
        Hide
        Allen Gilliland added a comment -

        Using a JSON library sounds interesting and would definitely cut into the work load a bit, but my fear would be that the libraries don't give you enough control over the output format and if they do something wrong you SOL. Looking at the Xstream stuff it doesn't look like you get to make many choices, you basically just say turn object WeblogEntry into JSON and hope it comes out correctly, so that would make me a little nervous.

        My preference would probably be to just use a velocity template so that we can control the format ourselves, make sure only the appropriate data is included, and also make sure that when things change from version to version that they remain backwards compatible.

        If you are willing to do that part then I can do the rest. So if can put together some velocity templates which would be able to accept an entry or collection of entries and comment or collection of comments and output them in json format then that should give me enough to get started.

        Show
        Allen Gilliland added a comment - Using a JSON library sounds interesting and would definitely cut into the work load a bit, but my fear would be that the libraries don't give you enough control over the output format and if they do something wrong you SOL. Looking at the Xstream stuff it doesn't look like you get to make many choices, you basically just say turn object WeblogEntry into JSON and hope it comes out correctly, so that would make me a little nervous. My preference would probably be to just use a velocity template so that we can control the format ourselves, make sure only the appropriate data is included, and also make sure that when things change from version to version that they remain backwards compatible. If you are willing to do that part then I can do the rest. So if can put together some velocity templates which would be able to accept an entry or collection of entries and comment or collection of comments and output them in json format then that should give me enough to get started.
        Hide
        Dolan Halbrook added a comment -

        Hi Allen,

        Have a look at this link:

        http://xstream.codehaus.org/manual-tweaking-output.html

        XStream offers quite a few options in tweaking XML output – I'll do some work to see how much this applies to the JSONOutputStream, since I have to do this for another project anyways.

        I just like the fact that we could essentially expose an XStream instance as a Velocity tool and not worry about the model change too much in the future, but I'm ok with going the straight Velocity route also, since I've used both kinds of solutions in the past.

        Show
        Dolan Halbrook added a comment - Hi Allen, Have a look at this link: http://xstream.codehaus.org/manual-tweaking-output.html XStream offers quite a few options in tweaking XML output – I'll do some work to see how much this applies to the JSONOutputStream, since I have to do this for another project anyways. I just like the fact that we could essentially expose an XStream instance as a Velocity tool and not worry about the model change too much in the future, but I'm ok with going the straight Velocity route also, since I've used both kinds of solutions in the past.
        Hide
        Dolan Halbrook added a comment -

        One more thing to consider:

        I've been using Spring MVC a lot and it allows you to easily merge content-type and view technology into a bundle. This way you don't have the extra logic of determining this in the servlet.

        For example, you might define a base view like:

        <bean id="vel-parent" abstract="true" abstract="true"
        class="org.springframework.web.servlet.view.velocity.VelocityToolboxView">
        <property name="contentType" value="text/html"/>
        <property name="toolboxConfigLocation" value="/WEB-INF/velocity/toolbox.xml"/>
        </bean>

        but you could easily create "feed " views like:

        <bean id="sonDetail" parent="vel-parent">
        <property name="contentType" value="text/javascript"/>
        <property name="url" value="/views/html/jsonDetail.vm"/>
        </bean>

        <bean id="xmlDetail" parent="vel-parent">
        <property name="contentType" value="text/xml"/>
        <property name="url" value="/views/html/xmlDetail.vm"/>
        </bean>

        However, i'm not sure how much Spring is welcome in the Roller project, not to mention Spring MVC. I'm a big fan, but I understand it other methods are preferred.

        Show
        Dolan Halbrook added a comment - One more thing to consider: I've been using Spring MVC a lot and it allows you to easily merge content-type and view technology into a bundle. This way you don't have the extra logic of determining this in the servlet. For example, you might define a base view like: <bean id="vel-parent" abstract="true" abstract="true" class="org.springframework.web.servlet.view.velocity.VelocityToolboxView"> <property name="contentType" value="text/html"/> <property name="toolboxConfigLocation" value="/WEB-INF/velocity/toolbox.xml"/> </bean> but you could easily create "feed " views like: <bean id="sonDetail" parent="vel-parent"> <property name="contentType" value="text/javascript"/> <property name="url" value="/views/html/jsonDetail.vm"/> </bean> <bean id="xmlDetail" parent="vel-parent"> <property name="contentType" value="text/xml"/> <property name="url" value="/views/html/xmlDetail.vm"/> </bean> However, i'm not sure how much Spring is welcome in the Roller project, not to mention Spring MVC. I'm a big fan, but I understand it other methods are preferred.
        Hide
        Greg Shaw added a comment -

        This doesn't look like it has been worked on since June 07. I've actually taken on some of the project that Dolan originally requested this feature for so I'd like to take it on.

        I agree with Allen that a velocity template would be the best solution but I'd like to take it one step further. In FeedServlet.java add a property that allows for output formats and their respective content-types (JSON needs "text/json") and then provide .vm templates for site/weblog and entries/comments in the specified format. This removes the need to modify FeedServlet.java if another format request comes along (we already have another one internally).

        Show
        Greg Shaw added a comment - This doesn't look like it has been worked on since June 07. I've actually taken on some of the project that Dolan originally requested this feature for so I'd like to take it on. I agree with Allen that a velocity template would be the best solution but I'd like to take it one step further. In FeedServlet.java add a property that allows for output formats and their respective content-types (JSON needs "text/json") and then provide .vm templates for site/weblog and entries/comments in the specified format. This removes the need to modify FeedServlet.java if another format request comes along (we already have another one internally).

          People

          • Assignee:
            Roller Unassigned
            Reporter:
            Dolan Halbrook
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development