/[theodore]/snips/ajax.cgi


UCC Code Repository

Contents of /snips/ajax.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations) (download)
Tue Jul 1 13:46:22 2008 UTC (11 years, 1 month ago) by theodore
File size: 1937 byte(s)


1 #!/usr/bin/python
2 import snips
3 """
4 Here we retrieve the blog and any arguments
5 Defaults are assigned here
6 """
7 form = cgi.FieldStorage()
8
9 if form.has_key('action'):
10 action = form['action'].value
11 if action == "Save Changes" or action == "And Save It":
12
13 if action == 'Save Changes':
14 if form.has_key('snip_id'):
15 snip_id = form['snip_id'].value
16 else:
17 snips.print_error("No snip id to update")
18 snips.update_current_snip(snip_id, code, description, language, tags)
19 elif action == 'And Save It':
20 snips.submit_new_snip(code, description, language, tags)
21 elif action == 'Add your 2 cents':
22 if form.has_key('snip_id'):
23 snip_id = form['snip_id'].value
24 else:
25 snips.print_error("No snip id to add comment too")
26
27 if form.has_key('comment'):
28 comment = form['comment'].value
29 else:
30 snips.print_error("No comment to add given")
31
32 if form.has_key('author'):
33 author = form['author'].value
34 else:
35 author = "Anonymous"
36
37 snips.submit_comment(snip_id, author, comment)
38 else:
39 snips.print_error("No legal action found")
40
41 elif form.has_key('revert'):
42 revert = form['revert'].value
43 if form.has_key('to'):
44 tovalue = form['to'].value
45 else:
46 snips.print_error("I need to know what version to revert to")
47 snips.revert_snip(revert, tovalue)
48
49 elif form.has_key('edit'):
50 snip_index = int(form['edit'].value)
51 snips.edit_snip(snip_index)
52
53 elif form.has_key('editsnip'):
54 snip_index = int(form['editsnip'].value)
55 snips.edit_snip(snip_index)
56
57 elif form.has_key('addcomment'):
58 snip_index = int(form['addcomment'].value)
59 snips.add_comment(snip_index)
60
61 elif form.has_key('viewcomments'):
62 snip_index = int(form['viewcomments'].value)
63 snips.view_comments(snip_index)
64
65 elif form.has_key('page'):
66 page = form['page'].value
67 if page == 'latest':
68 snips.latest_snips()
69 elif page == 'tags':
70 snips.show_all_tags()
71 elif page =='home':
72 snips.display_home()
73 else:
74 snips.display_home()
75
76 else:
77 snips.display_home()

Properties

Name Value
svn:executable *

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26