MobileBlur

Check-in [da2e9d5879]
Login
Overview
SHA1:da2e9d587913fc93b5a834d1bc8bfb757ac1a288
Date: 2011-11-20 23:29:30
User: spiffy
Comment:Added a button to mark a story as read
Timelines: family | ancestors | descendants | both | develop
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2011-11-20
23:48
[137407b6e5] [450ab2dd15] Read stories are now a different color from unread stories (user: spiffy, tags: develop)
23:29
[da2e9d5879] Added a button to mark a story as read (user: spiffy, tags: develop)
22:51
[678f5259f2] Added a logout button (user: spiffy, tags: develop)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified applications/mobileblur/controllers/default.py from [359e777bf1] to [667cfb0951].

    19     19           Field("password", "password", requires=IS_NOT_EMPTY())
    20     20       )
    21     21       if login_form.accepts(request):
    22     22           try:
    23     23               results = newsblur.login(login_form.vars["username"], login_form.vars["password"])
    24     24               response.cookies["nb_cookie"] = newsblur.cookies["newsblur_sessionid"]
    25     25               response.cookies["nb_cookie"]["path"] = "/"
    26         -            print "cookie =", newsblur.cookies
    27     26               redirect(URL("index"))
    28     27           except Exception as ex:
    29     28               login_form.insert(-1, ex.message)
    30     29   
    31     30       return dict(login_form=login_form)
    32     31   
    33     32   
    34     33   def logout():
    35     34       response.cookies["nb_cookie"] = ""
    36     35       response.cookies["nb_cookie"]["expires"] = -10
    37     36       response.cookies["nb_cookie"]["path"] = "/"
    38     37       redirect(URL("index"))

Modified applications/mobileblur/controllers/feeds.py from [b47f0eada4] to [353169fb7a].

     5      5   def view():
     6      6       stories = newsblur.feed(request.args[0])["stories"]
     7      7       feeds = newsblur.feeds(flat=True)["feeds"]
     8      8       feed = [feed for feed in feeds.itervalues() if feed["id"]==int(request.args[0])][0]
     9      9       return dict(stories=stories, feed=feed)
    10     10   
    11     11   def mark_read():
    12         -    newsblur.mark_feed_as_read(request.vars["feed"])
           12  +    if len(request.args) > 0:
           13  +        newsblur.mark_feed_as_read(request.args[0])
    13     14       redirect(URL("default", "index"))

Modified applications/mobileblur/controllers/stories.py from [59984e848a] to [fbf9de8ba7].

     1      1   # -*- coding: utf-8 -*-
     2      2   
     3      3   from pprint import pprint
     4      4   
     5      5   def view():
     6      6       stories = newsblur.feed(request.vars["feed_id"])["stories"]
     7      7       story = [story for story in stories if story["id"]==request.vars["story"]][0]
     8         -    return dict(story=story)
            8  +    return dict(story=story, feed_id=request.vars["feed_id"])
            9  +
           10  +def mark_read():
           11  +    results = newsblur.mark_story_as_read(request.vars["story_id"], request.vars["feed_id"])
           12  +    redirect(URL("default", "index"))

Modified applications/mobileblur/modules/newsblur.py from [a487a766ef] to [df40c3d1a1].

    19     19           Login as an existing user.
    20     20           If a user has no password set, you cannot just send any old password. 
    21     21           Required parameters, username and password, must be of string type.
    22     22           '''
    23     23   
    24     24           url = nb_url + 'api/login'
    25     25           results = requests.post(url, data={"username": username, "password": password})
    26         -        print "results.cookies =", results.cookies
    27         -        print type(results.cookies)
    28     26           self.cookies = results.cookies
    29     27           results = simplejson.loads(results.content)
    30     28           if results["authenticated"] is False:
    31     29               raise Exception("The newsblur credentials you provided are invalid")
    32     30           return results
    33     31   
    34     32       def logout(self, ):

Modified applications/mobileblur/views/feeds/view.html from [3646a45d79] to [ea3619c2f3].

     1      1   {{left_sidebar_enabled=right_sidebar_enabled=False}}
     2      2   {{extend 'layout.html'}}
     3      3   
     4      4   <h1>{{= feed["feed_title"] }}</h1>
     5         -<a href="{{= URL("mark_read", vars=dict(feed=feed["id"])) }}"> Mark feed as read</a>
            5  +<a href="{{= URL("mark_read", args=[feed["id"]]) }}"> Mark feed as read</a>
     6      6   
     7      7   {{ for story in stories: }}
     8      8       <a href="{{= URL(c="stories", f="view", vars=dict(story=story["id"], feed_id=feed["id"])) }}"><h2>{{= story["story_title"] }}</h2></a>
     9      9   {{ pass }}
    10     10   
    11     11   {{block left_sidebar}}New Left Sidebar Content{{end}}
    12     12   {{block right_sidebar}}New Right Sidebar Content{{end}}

Modified applications/mobileblur/views/stories/view.html from [859afcf521] to [c0c8c655df].

     1      1   {{left_sidebar_enabled=right_sidebar_enabled=False}}
     2      2   {{extend 'layout.html'}}
     3      3   
     4      4   <a href="{{= story["story_permalink"] }}"><h1>{{= story["story_title"] }}</h1></a>
            5  +<a href="{{= URL("mark_read", vars=dict(story_id=story["id"], feed_id=feed_id)) }}">Mark story as read</a>
     5      6   
     6      7   {{= XML(story["story_content"]) }}
     7      8   
     8      9   {{block left_sidebar}}New Left Sidebar Content{{end}}
     9     10   {{block right_sidebar}}New Right Sidebar Content{{end}}