学习日记rss订阅方案设计(希望得到您的意见或建议)

  看了www.43things.com的rss订阅方案和roller的rss方案,结合学习日记的特点,提出学习日记的rss订阅方案。

  1、个人的订阅:

  1)、我进行中的目标的最新39篇日记;(参数:type=diary.processGoal,userName=tom)

  2)、我写作的日记的最新39篇评论;(参数:type=advice.diary,userName=tom)

  2、全局的订阅:

  目标的订阅:

  1)、最近创建的39个目标;(参数:type=goal.last)

  2)、加入人数最多的39个目标;(参数:type=goal.mostJoin)

  日记的订阅:

  1)、最近写作的39篇日记;(参数:type=diary.last)

  评论的订阅:

  1)、最近提交的39篇评论;(参数:type=advice.last)

  3、征对某一个目标的订阅:

  1)、这个目标的最新39篇日记;(参数:type=diary.goal,goalID=1)

  2)、这个目标的最新39篇评论;(参数:type=advice.goal,goalID=1)

  订阅的格式:

  1、订阅的目标:

  目标题目

  ×××在什么时候创建了目标×××:

  目标内容(www.43things.com中目标的具体内容只有在网上看,它在这个页面有实现这个目标的相关的广告。学习日记可以考虑这种沟通用户的服务提供者的恰当的沟通方式)。

  2、订阅的日记:

  日记标题

  ×××在什么时候为×××目标写作了日记×××:

  日记内容

  3、订阅的评论:

  评论标题:

  ×××在什么时候评论了目标×××(或评论了目标×××下的日记×××):

  评论内容

  使用rss2.0规范,用rsslibj来生成(实际它可以生成0.92或1.0等规范的,但是没有atom的规范,这个公共库项目在2003年就停止了更新,估计是作者认为这个库已经完全满足它的主要目的了:专门用来生成rss文件),全局订阅单独放在一个页面中;某个目标的订阅分别放在所有目标页面的各个目标的条目中、目标的内容中、目标的日记列表中、目标的日记内容中。

  

2 thoughts on “学习日记rss订阅方案设计(希望得到您的意见或建议)”

  1. 参照例程:http://www.learndiary.com/disDiaryContentAction.do?searchDiaryID=1676&goalID=1676&naviStr=a10a21547

    上面的8种rss文件分别用8个方法来产生,然后在excute方法中根据参数的不同调用不同的方法。

    为了简便起见,只用一个RSSAction.java来执行rss文件的产生。

    另外,好像一个Action在应用中生成后就常驻内存了,这样的话,为节约内存的话,也可以把rss文件生成的类放在util包作为一个工具类GenerateRSS.java,然后,在RSSAction.java中动态调用GenerateRSS.java中相应的方法。这样的做法好像也更符合Action的功能分配,负责程序流程控制,而把程序的业务逻辑处理分离出来。

    ********待续***********

    GenerateRSS.java的伪代码:

    public class GenerateRSS {

        //log class

        private org.apache.commons.logging.Log __log =

    LogFactory.getFactory().getInstance(this.getClass());

        //database classes

        private static final TransContext trans = new TransContext();

        private static final ArticleDB myDB = new ArticleDB(trans);

        private static final DateFormat DATE_PARSER = new SimpleDateFormat("yyyy-MM-dd");

        //private static String fileName = null;

        private static String feedType = null;

        private final List entries = new ArrayList();

        private final List categories = new ArrayList();

        private final SyndFeed feed = new SyndFeedImpl();

        SyndEntry entry;

        SyndContent description;

        SyndCategory category;

       

        //constructor

        public GenerateRSS(){

        }

        //Generate latest 39 diaries of my processGoal

        public void genDiaryProcessGoalRSS(int diaryNum){

            //get the List all the latest 39 diaries of my processGoal

            List diariesList = myDB.getCPageList();

            //add every diary into field "entries"

            while (diariesList has element){

                anEntry=a diary info+the category info;

                entries.add(anEntry);

            }

            //form the channel info object

             Object channel=the channel info;

            //form the feed info

            feed=getFeed(channel);

            

            //output the feed

            outputFeed(feed);

        }   

        private SyndFeed getFeed(Object channelInfo){

            final SyndFeed feed = new SyndFeedImpl();

            feed.setFeedType(feedType);

            feed.setTitle(title);

            feed.setLink(link);

            feed.setDescription(description_loc);

            feed.setCopyright(copyright);

            feed.setEntries(entries);

        }     

           

         private void outputFeed(feed){

              final Writer writer = new FileWriter(xml);

              final SyndFeedOutput output = new SyndFeedOutput();

              output.output(feed,writer);

              writer.close();

         }   

    }

Comments are closed.