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 Unified Diffs Ignore Whitespace Patch

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

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

    return dict(login_form=login_form)


def logout():
    response.cookies["nb_cookie"] = ""
    response.cookies["nb_cookie"]["expires"] = -10
    response.cookies["nb_cookie"]["path"] = "/"
    redirect(URL("index"))







<












19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35
36
37
        Field("password", "password", requires=IS_NOT_EMPTY())
    )
    if login_form.accepts(request):
        try:
            results = newsblur.login(login_form.vars["username"], login_form.vars["password"])
            response.cookies["nb_cookie"] = newsblur.cookies["newsblur_sessionid"]
            response.cookies["nb_cookie"]["path"] = "/"

            redirect(URL("index"))
        except Exception as ex:
            login_form.insert(-1, ex.message)

    return dict(login_form=login_form)


def logout():
    response.cookies["nb_cookie"] = ""
    response.cookies["nb_cookie"]["expires"] = -10
    response.cookies["nb_cookie"]["path"] = "/"
    redirect(URL("index"))

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

5
6
7
8
9
10
11

12
13
def view():
    stories = newsblur.feed(request.args[0])["stories"]
    feeds = newsblur.feeds(flat=True)["feeds"]
    feed = [feed for feed in feeds.itervalues() if feed["id"]==int(request.args[0])][0]
    return dict(stories=stories, feed=feed)

def mark_read():

    newsblur.mark_feed_as_read(request.vars["feed"])
    redirect(URL("default", "index"))







>
|

5
6
7
8
9
10
11
12
13
14
def view():
    stories = newsblur.feed(request.args[0])["stories"]
    feeds = newsblur.feeds(flat=True)["feeds"]
    feed = [feed for feed in feeds.itervalues() if feed["id"]==int(request.args[0])][0]
    return dict(stories=stories, feed=feed)

def mark_read():
    if len(request.args) > 0:
        newsblur.mark_feed_as_read(request.args[0])
    redirect(URL("default", "index"))

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

1
2
3
4
5
6
7
8




# -*- coding: utf-8 -*-

from pprint import pprint

def view():
    stories = newsblur.feed(request.vars["feed_id"])["stories"]
    story = [story for story in stories if story["id"]==request.vars["story"]][0]
    return dict(story=story)











|
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
# -*- coding: utf-8 -*-

from pprint import pprint

def view():
    stories = newsblur.feed(request.vars["feed_id"])["stories"]
    story = [story for story in stories if story["id"]==request.vars["story"]][0]
    return dict(story=story, feed_id=request.vars["feed_id"])

def mark_read():
    results = newsblur.mark_story_as_read(request.vars["story_id"], request.vars["feed_id"])
    redirect(URL("default", "index"))

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

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        Login as an existing user.
        If a user has no password set, you cannot just send any old password. 
        Required parameters, username and password, must be of string type.
        '''

        url = nb_url + 'api/login'
        results = requests.post(url, data={"username": username, "password": password})
        print "results.cookies =", results.cookies
        print type(results.cookies)
        self.cookies = results.cookies
        results = simplejson.loads(results.content)
        if results["authenticated"] is False:
            raise Exception("The newsblur credentials you provided are invalid")
        return results

    def logout(self, ):







<
<







19
20
21
22
23
24
25


26
27
28
29
30
31
32
        Login as an existing user.
        If a user has no password set, you cannot just send any old password. 
        Required parameters, username and password, must be of string type.
        '''

        url = nb_url + 'api/login'
        results = requests.post(url, data={"username": username, "password": password})


        self.cookies = results.cookies
        results = simplejson.loads(results.content)
        if results["authenticated"] is False:
            raise Exception("The newsblur credentials you provided are invalid")
        return results

    def logout(self, ):

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

1
2
3
4
5
6
7
8
9
10
11
12
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

<h1>{{= feed["feed_title"] }}</h1>
<a href="{{= URL("mark_read", vars=dict(feed=feed["id"])) }}"> Mark feed as read</a>

{{ for story in stories: }}
    <a href="{{= URL(c="stories", f="view", vars=dict(story=story["id"], feed_id=feed["id"])) }}"><h2>{{= story["story_title"] }}</h2></a>
{{ pass }}

{{block left_sidebar}}New Left Sidebar Content{{end}}
{{block right_sidebar}}New Right Sidebar Content{{end}}




|







1
2
3
4
5
6
7
8
9
10
11
12
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

<h1>{{= feed["feed_title"] }}</h1>
<a href="{{= URL("mark_read", args=[feed["id"]]) }}"> Mark feed as read</a>

{{ for story in stories: }}
    <a href="{{= URL(c="stories", f="view", vars=dict(story=story["id"], feed_id=feed["id"])) }}"><h2>{{= story["story_title"] }}</h2></a>
{{ pass }}

{{block left_sidebar}}New Left Sidebar Content{{end}}
{{block right_sidebar}}New Right Sidebar Content{{end}}

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

1
2
3
4

5
6
7
8
9
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

<a href="{{= story["story_permalink"] }}"><h1>{{= story["story_title"] }}</h1></a>


{{= XML(story["story_content"]) }}

{{block left_sidebar}}New Left Sidebar Content{{end}}
{{block right_sidebar}}New Right Sidebar Content{{end}}




>





1
2
3
4
5
6
7
8
9
10
{{left_sidebar_enabled=right_sidebar_enabled=False}}
{{extend 'layout.html'}}

<a href="{{= story["story_permalink"] }}"><h1>{{= story["story_title"] }}</h1></a>
<a href="{{= URL("mark_read", vars=dict(story_id=story["id"], feed_id=feed_id)) }}">Mark story as read</a>

{{= XML(story["story_content"]) }}

{{block left_sidebar}}New Left Sidebar Content{{end}}
{{block right_sidebar}}New Right Sidebar Content{{end}}