/[theodore]/snips/index.cgi


UCC Code Repository

Contents of /snips/index.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 48 - (show annotations) (download)
Sat Jun 28 09:58:29 2008 UTC (12 years, 2 months ago) by theodore
File size: 2777 byte(s)
add stuff before drunken code


1 #!/usr/bin/python
2 import cgi
3 import cgitb; cgitb.enable()
4 import snips
5
6 """
7 Here we retrieve the blog and any arguments
8 Defaults are assigned here
9 """
10 form = cgi.FieldStorage()
11
12 if form.has_key('new'):
13 snips.new_snip()
14
15 elif form.has_key('snip'):
16 snip_index = int(form['snip'].value)
17 snips.print_snip(snip_index)
18
19 elif form.has_key('snipstory'):
20 snip_index = int(form['snipstory'].value)
21 snips.print_snipstory(snip_index)
22
23 elif form.has_key('tag'):
24 tag = form['tag'].value
25 snips.view_tag(tag)
26
27 elif form.has_key('submit'):
28 action = form['submit'].value
29 if action == "Save Changes" or action == "And Save It":
30 if form.has_key('code'):
31 code = form['code'].value
32 else:
33 snips.print_error("Each snip needs a description")
34 if form.has_key('tags'):
35 tags = snips.tagify(form['tags'].value)
36 else:
37 tags = []
38 if form.has_key('text'):
39 description = form['text'].value
40 # description = sanitise(form['text'].value)
41 else:
42 snips.print_error("Each snip needs a description")
43 if form.has_key('language'):
44 language = form['language'].value
45 else:
46 language = ''
47
48 if action == 'Save Changes':
49 if form.has_key('snip_id'):
50 snip_id = form['snip_id'].value
51 else:
52 snips.print_error("No snip id to update")
53 snips.update_current_snip(snip_id, code, description, language, tags)
54 elif action == 'And Save It':
55 snips.submit_new_snip(code, description, language, tags)
56 elif action == 'Add your 2 cents':
57 if form.has_key('snip_id'):
58 snip_id = form['snip_id'].value
59 else:
60 snips.print_error("No snip id to add comment too")
61
62 if form.has_key('comment'):
63 comment = form['comment'].value
64 else:
65 snips.print_error("No comment to add given")
66
67 if form.has_key('author'):
68 author = form['author'].value
69 else:
70 author = "Anonymous"
71
72 snips.submit_comment(snip_id, author, comment)
73 else:
74 snips.print_error("No legal action found")
75
76 elif form.has_key('revert'):
77 revert = form['revert'].value
78 if form.has_key('to'):
79 tovalue = form['to'].value
80 else:
81 snips.print_error("I need to know what version to revert to")
82 snips.revert_snip(revert, tovalue)
83
84 elif form.has_key('edit'):
85 snip_index = int(form['edit'].value)
86 snips.edit_snip(snip_index)
87
88 elif form.has_key('editsnip'):
89 snip_index = int(form['editsnip'].value)
90 snips.edit_snip(snip_index)
91
92 elif form.has_key('addcomment'):
93 snip_index = int(form['addcomment'].value)
94 snips.add_comment(snip_index)
95
96 elif form.has_key('viewcomments'):
97 snip_index = int(form['viewcomments'].value)
98 snips.view_comments(snip_index)
99
100 elif form.has_key('page'):
101 page = form['page'].value
102 if page == 'latest':
103 snips.latest_snips()
104 elif page == 'tags':
105 snips.show_all_tags()
106 elif page =='home':
107 snips.display_home()
108 else:
109 snips.display_home()
110
111 else:
112 snips.display_home()

Properties

Name Value
svn:executable *

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26