MobileBlur

Check-in [da2e9d5879]
Login

Check-in [da2e9d5879]

Overview
Comment:Added a button to mark a story as read
Timelines: family | ancestors | descendants | both | develop
Files: files | file ages | folders
SHA1: da2e9d587913fc93b5a834d1bc8bfb757ac1a288
User & Date: spiffy on 2011-11-20 23:29:30.636
Other Links: branch diff | manifest | tags
Context
2011-11-20
23:48
[450ab2dd15] Read stories are now a different color from unread stories check-in: 137407b6e5 user: spiffy tags: develop
23:29
Added a button to mark a story as read check-in: da2e9d5879 user: spiffy tags: develop
22:51
Added a logout button check-in: 678f5259f2 user: spiffy tags: develop
Changes
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
19
20
21
22
23
24
25

26
27
28
29
30
31
32







-







        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)


1
2
3
4
5
6
7
8
9
10
11

12

13
1
2
3
4
5
6
7
8
9
10
11
12

13
14











+
-
+

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

from pprint import pprint

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.vars["feed"])
        newsblur.mark_feed_as_read(request.args[0])
    redirect(URL("default", "index"))
1
2
3
4
5
6
7
8





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)
    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"))
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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})
        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, ):
1
2
3
4
5

6
7
8
9
10
11
12
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>
<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}}
1
2
3
4

5
6
7
8
9
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}}