Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

things should *really* be back to normal now...

  • Loading branch information...
commit d6416e11d0d4af59e0a0182d058b1643565b2adf 1 parent ac55982
Chris Drackett authored March 26, 2009

Showing 70 changed files with 12 additions and 786 deletions. Show diff stats Hide diff stats

  1. 22  admin.py
  2. 440  default_list.py
  3. 33  functions.py
  4. BIN  img/aim.png
  5. BIN  img/bebo.png
  6. BIN  img/blip.png
  7. BIN  img/catster.png
  8. BIN  img/corkd.png
  9. BIN  img/delicious.png
  10. BIN  img/digg.png
  11. BIN  img/djangopeople.png
  12. BIN  img/dodgeball.png
  13. BIN  img/dogster.png
  14. BIN  img/dopplr.png
  15. BIN  img/facebook.png
  16. BIN  img/flickr.png
  17. BIN  img/fortythreethings.png
  18. BIN  img/foursquare.png
  19. BIN  img/gamercard.png
  20. BIN  img/github.png
  21. BIN  img/goodreads.png
  22. BIN  img/gtalk.png
  23. BIN  img/hi5.png
  24. BIN  img/icq.png
  25. BIN  img/instructables.png
  26. BIN  img/jaiku.png
  27. BIN  img/lastfm.png
  28. BIN  img/librarything.png
  29. BIN  img/linkedin.png
  30. BIN  img/livejournal.png
  31. BIN  img/magnolia.png
  32. BIN  img/metafilter.png
  33. BIN  img/mog.png
  34. BIN  img/msn.png
  35. BIN  img/multiply.png
  36. BIN  img/myspace.png
  37. BIN  img/netvibes.png
  38. BIN  img/newsvine.png
  39. BIN  img/ning.png
  40. BIN  img/orkut.png
  41. BIN  img/pandora.png
  42. BIN  img/plaxo.png
  43. BIN  img/pownce.png
  44. BIN  img/readernaut.png
  45. BIN  img/redbubble.png
  46. BIN  img/reddit.png
  47. BIN  img/seesmic.png
  48. BIN  img/shelfworthy.png
  49. BIN  img/skype.png
  50. BIN  img/sonicliving.png
  51. BIN  img/stumbleupon.png
  52. BIN  img/tabblo.png
  53. BIN  img/technorati.png
  54. BIN  img/tribe.png
  55. BIN  img/tumblr.png
  56. BIN  img/twitter.png
  57. BIN  img/upcoming.png
  58. BIN  img/ustream.png
  59. BIN  img/virb.png
  60. BIN  img/vox.png
  61. BIN  img/wakoopa.png
  62. BIN  img/yahoo.png
  63. BIN  img/youtube.png
  64. BIN  img/zooomr.png
  65. BIN  img/zune.png
  66. 118  models.py
  67. 12  setup.py
  68. 89  templates/elsewhere/example.html
  69. 26  urls.py
  70. 58  views.py
22  admin.py
... ...
@@ -1,22 +0,0 @@
1  
-from django.contrib import admin
2  
-
3  
-from elsewhere.models import *
4  
-
5  
-class ProfileAdmin(admin.ModelAdmin):
6  
-    raw_id_fields = ['user']
7  
-
8  
-class SocialNetworkProfileAdmin(ProfileAdmin):
9  
-    list_display = ('user', 'network', 'username') #, 'date_added')
10  
-
11  
-class InstantMessengerProfileAdmin(ProfileAdmin):
12  
-    list_display = ('user', 'network', 'username') #, 'date_added')
13  
-
14  
-class WebsiteProfileAdmin(ProfileAdmin):
15  
-    list_display = ('user', 'name', 'url') #, 'date_added')
16  
-
17  
-## TODO Not sure why I can't grab date_added from the parent Profile model, need to figure this out.
18  
-
19  
-admin.site.register(Network)
20  
-admin.site.register(SocialNetworkProfile, SocialNetworkProfileAdmin)
21  
-admin.site.register(WebsiteProfile, WebsiteProfileAdmin)
22  
-admin.site.register(InstantMessengerProfile, InstantMessengerProfileAdmin)
440  default_list.py
... ...
@@ -1,440 +0,0 @@
1  
-default_social_networks = [
2  
-    {
3  
-        'name': '43 Things',
4  
-        'url': 'http://www.43things.com/person/%s',
5  
-        'identifier': 'Username',
6  
-        'icon': 'fortythreethings.png',
7  
-        'network_type': 'sn'
8  
-    },
9  
-    {
10  
-        'name': 'Bebo',
11  
-        'url': 'http://www.bebo.com/Profile.jsp?MemberId=%s',
12  
-        'identifier': 'Member ID',
13  
-        'icon': 'bebo.png',
14  
-        'network_type': 'sn'
15  
-    },
16  
-    {
17  
-        'name': 'Blip.tv',
18  
-        'url': 'http://%s.blip.tv',
19  
-        'identifier': 'Username',
20  
-        'icon': 'blip.png',
21  
-        'network_type': 'sn'
22  
-    },
23  
-    {
24  
-        'name': 'Catster',
25  
-        'url': 'http://www.catster.com/cats/%s',
26  
-        'identifier': 'Cat ID',
27  
-        'icon': 'catster.png',
28  
-        'network_type': 'sn'
29  
-    },
30  
-    {
31  
-        'name': 'Corkd',
32  
-        'url': 'http://corkd.com/people/%s',
33  
-        'identifier': 'Username',
34  
-        'icon': 'corkd.png',
35  
-        'network_type': 'sn'
36  
-    },
37  
-    {
38  
-        'name': 'Delicious',
39  
-        'url': 'http://delicious.com/%s',
40  
-        'identifier': 'Username',
41  
-        'icon': 'delicious.png',
42  
-        'network_type': 'sn'
43  
-    },
44  
-    {
45  
-        'name': 'Digg',
46  
-        'url': 'http://digg.com/users/%s',
47  
-        'identifier': 'Username',
48  
-        'icon': 'digg.png',
49  
-        'network_type': 'sn'
50  
-    },
51  
-    {
52  
-        'name': 'Django People',
53  
-        'url': 'http://djangopeople.net/%s',
54  
-        'identifier': 'Username',
55  
-        'icon': 'djangopeople.png',
56  
-        'network_type': 'sn'
57  
-    },
58  
-    {
59  
-        'name': 'Dodgeball',
60  
-        'url': 'http://www.dodgeball.com/user?uid=%s',
61  
-        'identifier': 'User ID',
62  
-        'icon': 'dodgeball.png',
63  
-        'network_type': 'sn'
64  
-    },
65  
-    {
66  
-        'name': 'Dogster',
67  
-        'url': 'http://www.dogster.com/dogs/%s',
68  
-        'identifier': 'Dog ID',
69  
-        'icon': 'dogster.png',
70  
-        'network_type': 'sn'
71  
-    },
72  
-    {
73  
-        'name': 'Dopplr',
74  
-        'url': 'http://www.dopplr.com/traveller/%s',
75  
-        'identifier': 'Username',
76  
-        'icon': 'dopplr.png',
77  
-        'network_type': 'sn'
78  
-    },
79  
-    {
80  
-        'name': 'Facebook',
81  
-        'url': 'http://www.facebook.com/profile.php?id=%s',
82  
-        'identifier': 'User ID',
83  
-        'icon': 'facebook.png',
84  
-        'network_type': 'sn'
85  
-    },
86  
-    {
87  
-        'name': 'Flickr',
88  
-        'url': 'http://www.flickr.com/photos/%s',
89  
-        'identifier': 'Flickr Alias',
90  
-        'icon': 'flickr.png',
91  
-        'network_type': 'sn'
92  
-    },
93  
-    {
94  
-        'name': 'foursquare',
95  
-        'url': 'http://playfoursquare.com/user?uid=%s',
96  
-        'identifier': 'User ID',
97  
-        'icon': 'foursquare.png',
98  
-        'network_type': 'sn'
99  
-    },
100  
-    {
101  
-        'name': 'Gamer Card',
102  
-        'url': 'http://live.xbox.com/en-US/profile/profile.aspx?pp=0&GamerTag=%s',
103  
-        'identifier': 'Gamertag',
104  
-        'icon': 'gamercard.png',
105  
-        'network_type': 'sn'
106  
-    },
107  
-    {
108  
-        'name': 'GitHub',
109  
-        'url': 'http://github.com/%s',
110  
-        'identifier': 'Username',
111  
-        'icon': 'github.png',
112  
-        'network_type': 'sn'
113  
-    },
114  
-    {
115  
-        'name': 'GoodReads',
116  
-        'url': 'http://www.goodreads.com/user/show/%s',
117  
-        'identifier': 'User ID',
118  
-        'icon': 'goodreads.png',
119  
-        'network_type': 'sn'
120  
-    },
121  
-    {
122  
-        'name': 'Hi5',
123  
-        'url': 'http://hi5.com/friend/profile/displayProfile.do?userid=%s',
124  
-        'identifier': 'User ID',
125  
-        'icon': 'hi5.png',
126  
-        'network_type': 'sn'
127  
-    },
128  
-    {
129  
-        'name': 'Instructables',
130  
-        'url': 'http://www.instructables.com/member/%s',
131  
-        'identifier': 'Username',
132  
-        'icon': 'instructables.png',
133  
-        'network_type': 'sn'
134  
-    },
135  
-    {
136  
-        'name': 'Jaiku',
137  
-        'url': 'http://%s.jaiku.com',
138  
-        'identifier': 'Username',
139  
-        'icon': 'jaiku.png',
140  
-        'network_type': 'sn'
141  
-    },
142  
-    {
143  
-        'name': 'Last.fm',
144  
-        'url': 'http://www.last.fm/user/%s',
145  
-        'identifier': 'Username',
146  
-        'icon': 'lastfm.png',
147  
-        'network_type': 'sn'
148  
-    },
149  
-    {
150  
-        'name': 'LibraryThing',
151  
-        'url': 'http://www.librarything.com/profile/%s',
152  
-        'identifier': 'Username',
153  
-        'icon': 'librarything.png',
154  
-        'network_type': 'sn'
155  
-    },
156  
-    {
157  
-        'name': 'LinkedIn',
158  
-        'url': 'http://www.linkedin.com/in/%s',
159  
-        'identifier': 'Full Name (without spaces)',
160  
-        'icon': 'linkedin.png',
161  
-        'network_type': 'sn'
162  
-    },
163  
-    {
164  
-        'name': 'LiveJournal',
165  
-        'url': 'http://%s.livejournal.com',
166  
-        'identifier': 'Username',
167  
-        'icon': 'lj.png',
168  
-        'network_type': 'sn'
169  
-    },
170  
-    {
171  
-        'name': 'Ma.gnolia',
172  
-        'url': 'http://ma.gnolia.com/people/%s',
173  
-        'identifier': 'Username',
174  
-        'icon': 'magnolia.png',
175  
-        'network_type': 'sn'
176  
-    },
177  
-    {
178  
-        'name': 'MetaFilter',
179  
-        'url': 'http://www.metafilter.com/user/%s',
180  
-        'identifier': 'User ID',
181  
-        'icon': 'metafilter.png',
182  
-        'network_type': 'sn'
183  
-    },
184  
-    {
185  
-        'name': 'MOG',
186  
-        'url': 'http://mog.com/%s',
187  
-        'identifier': 'Username',
188  
-        'icon': 'mog.png',
189  
-        'network_type': 'sn'
190  
-    },
191  
-    {
192  
-        'name': 'Multiply',
193  
-        'url': 'http://%s.multiply.com',
194  
-        'identifier': 'Username',
195  
-        'icon': 'multiply.png',
196  
-        'network_type': 'sn'
197  
-    },
198  
-    {
199  
-        'name': 'MySpace',
200  
-        'url': 'http://www.myspace.com/%s',
201  
-        'identifier': 'Username',
202  
-        'icon': 'myspace.png',
203  
-        'network_type': 'sn'
204  
-    },
205  
-    {
206  
-        'name': 'Netvibes',
207  
-        'url': 'http://www.netvibes.com/%s',
208  
-        'identifier': 'Username',
209  
-        'icon': 'netvibes.png',
210  
-        'network_type': 'sn'
211  
-    },
212  
-    {
213  
-        'name': 'Newsvine',
214  
-        'url': 'http://%s.newsvine.com',
215  
-        'identifier': 'Username',
216  
-        'icon': 'newsvine.png',
217  
-        'network_type': 'sn'
218  
-    },
219  
-    {
220  
-        'name': 'Ning',
221  
-        'url': 'http://%s.ning.com',
222  
-        'identifier': 'Network Name',
223  
-        'icon': 'ning.png',
224  
-        'network_type': 'sn'
225  
-    },
226  
-    {
227  
-        'name': 'Orkut',
228  
-        'url': 'http://www.orkut.com/Profile.aspx?uid=%s',
229  
-        'identifier': 'User ID',
230  
-        'icon': 'orkut.png',
231  
-        'network_type': 'sn'
232  
-    },
233  
-    {
234  
-        'name': 'Pandora',
235  
-        'url': 'http://pandora.com/people/%s',
236  
-        'identifier': 'Username',
237  
-        'icon': 'pandora.png',
238  
-        'network_type': 'sn'
239  
-    },
240  
-    {
241  
-        'name': 'Plaxo',
242  
-        'url': 'http://%s.myplaxo.com',
243  
-        'identifier': 'Public Profile ID',
244  
-        'icon': 'plaxo.png',
245  
-        'network_type': 'sn'
246  
-    },
247  
-    {
248  
-        'name': 'Pownce',
249  
-        'url': 'http://pownce.com/%s',
250  
-        'identifier': 'Username',
251  
-        'icon': 'pownce.png',
252  
-        'network_type': 'sn'
253  
-    },
254  
-    {
255  
-        'name': 'Readernaut',
256  
-        'url': 'http://readernaut.com/%s',
257  
-        'identifier': 'Username',
258  
-        'icon': 'readernaut.png',
259  
-        'network_type': 'sn'
260  
-    },
261  
-    {
262  
-        'name': 'RedBubble',
263  
-        'url': 'http://www.redbubble.com/people/%s',
264  
-        'identifier': 'Username',
265  
-        'icon': 'redbubble.png',
266  
-        'network_type': 'sn'
267  
-    },
268  
-    {
269  
-        'name': 'Reddit',
270  
-        'url': 'http://reddit.com/user/%s',
271  
-        'identifier': 'Username',
272  
-        'icon': 'reddit.png',
273  
-        'network_type': 'sn'
274  
-    },
275  
-    {
276  
-        'name': 'Seesmic',
277  
-        'url': 'http://seesmic.com/%s',
278  
-        'identifier': 'Username',
279  
-        'icon': 'seesmic.png',
280  
-        'network_type': 'sn'
281  
-    },
282  
-    {
283  
-        'name': 'Shelfworthy',
284  
-        'url': 'http://shelfworthy.com/%s',
285  
-        'identifier': 'Username',
286  
-        'icon': 'shelfworthy.png',
287  
-        'network_type': 'sn'
288  
-    },
289  
-    {
290  
-        'name': 'SonicLiving',
291  
-        'url': 'http://www.sonicliving.com/user/%s',
292  
-        'identifier': 'User ID',
293  
-        'icon': 'sonicliving.png',
294  
-        'network_type': 'sn'
295  
-    },
296  
-    {
297  
-        'name': 'StumbleUpon',
298  
-        'url': 'http://%s.stumbleupon.com',
299  
-        'identifier': 'Username',
300  
-        'icon': 'stumbleupon.png',
301  
-        'network_type': 'sn'
302  
-    },
303  
-    {
304  
-        'name': 'Tabblo',
305  
-        'url': 'http://www.tabblo.com/studio/person/%s',
306  
-        'identifier': 'Username',
307  
-        'icon': 'tabblo.png',
308  
-        'network_type': 'sn'
309  
-    },
310  
-    {
311  
-        'name': 'TagWorld',
312  
-        'url': 'http://www.tagworld.com/%s',
313  
-        'identifier': 'Username',
314  
-        'icon': '',
315  
-        'network_type': 'sn'
316  
-    },
317  
-    {
318  
-        'name': 'Technorati',
319  
-        'url': 'http://technorati.com/people/technorati/%s',
320  
-        'identifier': 'Username',
321  
-        'icon': 'technorati.png',
322  
-        'network_type': 'sn'
323  
-    },
324  
-    {
325  
-        'name': 'Tribe',
326  
-        'url': 'http://people.tribe.net/%s',
327  
-        'identifier': 'Username',
328  
-        'icon': 'tribe.png',
329  
-        'network_type': 'sn'
330  
-    },
331  
-    {
332  
-        'name': 'Tumblr',
333  
-        'url': 'http://%s.tumblr.com',
334  
-        'identifier': 'Username',
335  
-        'icon': 'tumblr.png',
336  
-        'network_type': 'sn'
337  
-    },
338  
-    {
339  
-        'name': 'Twitter',
340  
-        'url': 'http://twitter.com/%s',
341  
-        'identifier': 'Username',
342  
-        'icon': 'twitter.png',
343  
-        'network_type': 'sn'
344  
-    },
345  
-    {
346  
-        'name': 'Upcoming',
347  
-        'url': 'http://upcoming.yahoo.com/user/%s',
348  
-        'identifier': 'User ID',
349  
-        'icon': 'upcoming.png',
350  
-        'network_type': 'sn'
351  
-    },
352  
-    {
353  
-        'name': 'Ustream.TV',
354  
-        'url': 'http://www.ustream.tv/%s',
355  
-        'identifier': 'Username',
356  
-        'icon': 'ustream.png',
357  
-        'network_type': 'sn'
358  
-    },
359  
-    {
360  
-        'name': 'Virb',
361  
-        'url': 'http://www.virb.com/%s',
362  
-        'identifier': 'Username',
363  
-        'icon': 'virb.png',
364  
-        'network_type': 'sn'
365  
-    },
366  
-    {
367  
-        'name': 'Vox',
368  
-        'url': 'http://%s.vox.com',
369  
-        'identifier': 'Username',
370  
-        'icon': 'vox.png',
371  
-        'network_type': 'sn'
372  
-    },
373  
-    {
374  
-        'name': 'Wakoopa',
375  
-        'url': 'http://wakoopa.com/%s',
376  
-        'identifier': 'Username',
377  
-        'icon': 'wakoopa.png',
378  
-        'network_type': 'sn'
379  
-    },
380  
-    {
381  
-        'name': 'YouTube',
382  
-        'url': 'http://www.youtube.com/user/%s',
383  
-        'identifier': 'Username',
384  
-        'icon': 'youtube.png',
385  
-        'network_type': 'sn'
386  
-    },
387  
-    {
388  
-        'name': 'Zooomr',
389  
-        'url': 'http://www.zooomr.com/photos/%s',
390  
-        'identifier': 'Username',
391  
-        'icon': 'zooomr.png',
392  
-        'network_type': 'sn'
393  
-    },
394  
-    {
395  
-        'name': 'Zune',
396  
-        'url': 'http://social.zune.net/member/%s',
397  
-        'identifier': 'Username',
398  
-        'icon': 'zune.png',
399  
-        'network_type': 'sn'
400  
-    },
401  
-]
402  
-
403  
-default_im_networks = [
404  
-    {
405  
-        'name': 'AIM',
406  
-        'url': 'aim:goim?screenname=%s',
407  
-        'icon': 'aim.png',
408  
-        'network_type': 'im'
409  
-    },
410  
-    {
411  
-        'name': 'GTalk',
412  
-        'url': 'gtalk:chat?jid=%s',
413  
-        'icon': 'gtalk.png',
414  
-        'network_type': 'im'
415  
-    },
416  
-    {
417  
-        'name': 'ICQ',
418  
-        'url': 'http://www.icq.com/people/about_me.php?to=%s',
419  
-        'icon': 'icq.png',
420  
-        'network_type': 'im'
421  
-    },
422  
-    {
423  
-        'name': 'MSN',
424  
-        'url': 'msnim:chat?contact=%s',
425  
-        'icon': 'msn.png',
426  
-        'network_type': 'im'
427  
-    },
428  
-    {
429  
-        'name': 'Skype',
430  
-        'url': 'skype:%s?chat',
431  
-        'icon': 'skype.png',
432  
-        'network_type': 'im'
433  
-    },
434  
-    {
435  
-        'name': 'Y!',
436  
-        'url': 'ymsgr:sendim?%s',
437  
-        'icon': 'yahoo.png',
438  
-        'network_type': 'im'
439  
-    },
440  
-]
33  functions.py
... ...
@@ -1,33 +0,0 @@
1  
-from default_list import *
2  
-from elsewhere.models import SocialNetwork, InstantMessenger
3  
-
4  
-# this function will fill the database with default data (stored in default_list.py)
5  
-
6  
-def fill_db():
7  
-    '''This is a function so it doesn't get called automatically on import; 
8  
-    instead it's called at the end of urls.py, but could potentially be called
9  
-    from anywhere that gets read in only once.'''
10  
-
11  
-    for item in default_social_networks: # fill social networks
12  
-        if item.has_key('identifier'):
13  
-            ident = item['identifier']
14  
-        else:
15  
-            ident = ''
16  
-
17  
-        SocialNetwork.objects.get_or_create(name=item['name'], defaults={
18  
-            'url': item['url'],
19  
-            'identifier': ident,
20  
-            'icon': item['icon']
21  
-        })
22  
-
23  
-    for item in default_im_networks: # fill IM networks
24  
-        if item.has_key('identifier'):
25  
-            ident = item['identifier']
26  
-        else:
27  
-            ident = ''
28  
-
29  
-        InstantMessenger.objects.get_or_create(name=item['name'], defaults={
30  
-            'url': item['url'],
31  
-            'identifier': ident,
32  
-            'icon': item['icon']
33  
-        })
BIN  img/aim.png
BIN  img/bebo.png
BIN  img/blip.png
BIN  img/catster.png
BIN  img/corkd.png
BIN  img/delicious.png
BIN  img/digg.png
BIN  img/djangopeople.png
BIN  img/dodgeball.png
BIN  img/dogster.png
BIN  img/dopplr.png
BIN  img/facebook.png
BIN  img/flickr.png
BIN  img/fortythreethings.png
BIN  img/foursquare.png
BIN  img/gamercard.png
BIN  img/github.png
BIN  img/goodreads.png
BIN  img/gtalk.png
BIN  img/hi5.png
BIN  img/icq.png
BIN  img/instructables.png
BIN  img/jaiku.png
BIN  img/lastfm.png
BIN  img/librarything.png
BIN  img/linkedin.png
BIN  img/livejournal.png
BIN  img/magnolia.png
BIN  img/metafilter.png
BIN  img/mog.png
BIN  img/msn.png
BIN  img/multiply.png
BIN  img/myspace.png
BIN  img/netvibes.png
BIN  img/newsvine.png
BIN  img/ning.png
BIN  img/orkut.png
BIN  img/pandora.png
BIN  img/plaxo.png
BIN  img/pownce.png
BIN  img/readernaut.png
BIN  img/redbubble.png
BIN  img/reddit.png
BIN  img/seesmic.png
BIN  img/shelfworthy.png
BIN  img/skype.png
BIN  img/sonicliving.png
BIN  img/stumbleupon.png
BIN  img/tabblo.png
BIN  img/technorati.png
BIN  img/tribe.png
BIN  img/tumblr.png
BIN  img/twitter.png
BIN  img/upcoming.png
BIN  img/ustream.png
BIN  img/virb.png
BIN  img/vox.png
BIN  img/wakoopa.png
BIN  img/yahoo.png
BIN  img/youtube.png
BIN  img/zooomr.png
BIN  img/zune.png
118  models.py
... ...
@@ -1,118 +0,0 @@
1  
-from datetime import datetime
2  
-
3  
-from django import forms
4  
-from django.db import models
5  
-from django.core.cache import cache
6  
-from django.contrib.auth.models import User
7  
-from django.utils.translation import ugettext_lazy as _
8  
-from django.core.urlresolvers import reverse
9  
-from django.contrib import admin
10  
-
11  
-GOOGLE_PROFILE_URL = 'http://www.google.com/s2/favicons?domain_url=%s'
12  
-
13  
-class Network(models.Model):
14  
-    """ Model for storing networks. """
15  
-
16  
-    name = models.CharField(max_length=100)
17  
-    url = models.URLField()
18  
-    identifier = models.CharField(max_length=100)
19  
-    icon = models.CharField(max_length=100, blank=True)
20  
-
21  
-    class Meta:
22  
-        abstract = True
23  
-
24  
-    def __unicode__(self):
25  
-        return self.name
26  
-
27  
-## TODO the full SocialNetwork and InstantMessenger lists should probably be cached.
28  
-
29  
-class SocialNetwork(Network):
30  
-    class Meta:
31  
-        verbose_name_plural = 'social networks'
32  
-
33  
-class InstantMessenger(Network):
34  
-    class Meta:
35  
-        verbose_name_plural = 'instant messanger networks'
36  
-
37  
-class Profile(models.Model):
38  
-    """ Common profile functions. """
39  
-
40  
-    date_added = models.DateTimeField(_('date added'), auto_now_add=True)
41  
-    date_verified = models.DateTimeField(_('date verified'), default=datetime.now)
42  
-    is_verified = models.BooleanField(default=False)
43  
-
44  
-    class Meta:
45  
-        abstract = True
46  
-
47  
-    def _get_name(self):
48  
-        # Profile display name
49  
-        return self.network.name
50  
-    name = property(_get_name)
51  
-
52  
-    def _get_url(self):
53  
-        # Profile URL with username
54  
-        return self.network.url
55  
-    url = property(_get_url)
56  
-    
57  
-    def _get_icon_name(self):
58  
-        # Icon name
59  
-        return self.network.icon
60  
-    icon_name = property(_get_icon_name)
61  
-
62  
-    def _get_icon(self):
63  
-        # Icon URL or link to Google icon service
64  
-        if self.icon_name:
65  
-            return reverse('elsewhere_img', args=[self.icon_name])
66  
-        return GOOGLE_PROFILE_URL % self.url
67  
-    icon = property(_get_icon)
68  
-
69  
-
70  
-class SocialNetworkProfile(Profile):
71  
-    user = models.ForeignKey(User, db_index=True, related_name='social_network_profiles')
72  
-    network = models.ForeignKey(SocialNetwork, db_index=True)
73  
-    username = models.CharField(max_length=64)
74  
-    
75  
-    def __unicode__(self):
76  
-        return self.network_id
77  
-
78  
-class SocialNetworkForm(forms.ModelForm):
79  
-
80  
-    class Meta:
81  
-        model = SocialNetworkProfile
82  
-        fields = ('network', 'username')
83  
-
84  
-
85  
-class InstantMessengerProfile(Profile):
86  
-    user = models.ForeignKey(User, db_index=True, related_name='instant_messenger_profiles')
87  
-    network = models.ForeignKey(InstantMessenger, db_index=True)
88  
-    username = models.CharField(max_length=64)
89  
-
90  
-    def __unicode__(self):
91  
-        return self.username
92  
-
93  
-class InstantMessengerForm(forms.ModelForm):
94  
-
95  
-    class Meta:
96  
-        model = InstantMessengerProfile
97  
-        fields = ('network', 'username')
98  
-
99  
-
100  
-class WebsiteProfile(models.Model):
101  
-    user = models.ForeignKey(User, db_index=True, related_name='website_profiles')
102  
-    name = models.CharField(max_length=64)
103  
-    url = models.URLField(verify_exists=True)
104  
-
105  
-    def __unicode__(self):
106  
-        return self.url
107  
-
108  
-    def _get_icon(self):
109  
-        # No known icons! Just return the Google service URL.
110  
-        return GOOGLE_PROFILE_URL % self.url
111  
-    icon = property(_get_icon)
112  
-
113  
-
114  
-class WebsiteForm(forms.ModelForm):
115  
-
116  
-    class Meta:
117  
-        model = WebsiteProfile
118  
-        fields = ('name', 'url')
12  setup.py
... ...
@@ -0,0 +1,12 @@
  1
+#!/usr/bin/env python
  2
+
  3
+from distutils.core import setup
  4
+
  5
+setup(name='django-elsewhere',
  6
+      version='1.0',
  7
+      description='Formerly Django-PSN (Portable Social Networks) and originally created for Pownce.',
  8
+      author='Leah Culver',
  9
+      author_email='leah@sixapart.com',
  10
+      url='http://github.com/leah/django-elsewhere/tree/master',
  11
+      packages=['elsewhere'],
  12
+      )
89  templates/elsewhere/example.html
... ...
@@ -1,89 +0,0 @@
1  
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
2  
-	"http://www.w3.org/TR/html4/loose.dtd">
3  
-<html>
4  
-<head>
5  
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6  
-    <title>Elsewhere</title>
7  
-</head>
8  
-<body>
9  
-
10  
-<h1>Elsewhere</h1>
11  
-
12  
-<h2>Social Networks</h2>
13  
-{% if request.user.social_network_profiles.all %}
14  
-    <ul>
15  
-    {% for profile in request.user.social_network_profiles.all %}
16  
-        <li>
17  
-            <img src="{{ profile.icon }}" alt="{{ profile.name }}">
18  
-            <a href="{{ profile.url }}" rel="me">{{ profile.name }}</a>
19  
-            <form id="delete-network-{{ profile.id }}" method="post" action=".">
20  
-                <input type="hidden" name="delete_id" value="{{ profile.id }}">
21  
-                <input type="submit" name="delete-sn-form" value="Delete" class="button">
22  
-            </form>
23  
-        </li>
24  
-    {% endfor %}
25  
-    </ul>
26  
-{% else %}
27  
-    <p>No social network profiles.</p>
28  
-{% endif %}
29  
-
30  
-<h3>Add a Social Network</h3>
31  
-<form method="post" action=".">
32  
-    {{ sn_form.as_p }}
33  
-    <p><input type="submit" name="sn-form" value="Add Social Network" class="button"></p>
34  
-</form>
35  
-
36  
-<br>
37  
-
38  
-<h2>Instant Messengers</h2>
39  
-{% if request.user.instant_messenger_profiles.all %}
40  
-    <ul>
41  
-    {% for profile in request.user.instant_messenger_profiles.all %}
42  
-        <li>
43  
-            <img src="{{ profile.icon }}" alt="{{ profile.name }}">
44  
-            {{ profile.name }}: <a href="{{ profile.url }}">{{ profile.username }}</a>
45  
-            <form id="delete-messenger-{{ profile.id }}" method="post" action=".">
46  
-                <input type="hidden" name="delete_id" value="{{ profile.id }}">
47  
-                <input type="submit" name="delete-im-form" value="Delete" class="button">
48  
-            </form>
49  
-        </li>
50  
-    {% endfor %}
51  
-    </ul>
52  
-{% else %}
53  
-    <p>No instant messenger profiles.</p>
54  
-{% endif %}
55  
-
56  
-<h3>Add an Instant Messenger</h3>
57  
-<form method="post" action=".">
58  
-    {{ im_form.as_p }}
59  
-    <p><input type="submit" name="im-form" value="Add Instant Messenger" class="button"></p>
60  
-</form>
61  
-
62  
-<br>
63  
-
64  
-<h2>Websites</h2>
65  
-{% if request.user.website_profiles.all %}
66  
-    <ul>
67  
-    {% for profile in request.user.website_profiles.all %}
68  
-        <li>
69  
-            <img src="{{ profile.icon }}" alt="{{ profile.name }}">
70  
-            <a href="{{ profile.url }}" rel="me">{{ profile.name }}</a>
71  
-            <form id="delete-website-{{ profile.id }}" method="post" action=".">
72  
-                <input type="hidden" name="delete_id" value="{{ profile.id }}">
73  
-                <input type="submit" name="delete-w-form" value="Delete" class="button">
74  
-            </form>
75  
-        </li>
76  
-    {% endfor %}
77  
-    </ul>
78  
-{% else %}
79  
-    <p>No website profiles.</p>
80  
-{% endif %}
81  
-
82  
-<h3>Add a Website</h3>
83  
-<form method="post" action=".">
84  
-    {{ w_form.as_p }}
85  
-    <p><input type="submit" name="w-form" value="Add Website" class="button"></p>
86  
-</form>
87  
-
88  
-</body>
89  
-</html>
26  urls.py
... ...
@@ -1,26 +0,0 @@
1  
-import settings
2  
-import os
3  
-
4  
-from django.conf.urls.defaults import *
5  
-from django.contrib import admin
6  
-
7  
-from elsewhere.functions import fill_db
8  
-
9  
-admin.autodiscover()
10  
-
11  
-urlpatterns = patterns('elsewhere.views',
12  
-    (r'^$', 'example'),
13  
-)
14  
-
15  
-if settings.DEBUG:
16  
-
17  
-    CUR_DIR = os.path.dirname(__file__)
18  
-    IMG_PATH = 'img/'
19  
-    IMG_DIR = os.path.join(CUR_DIR, "img")
20  
-
21  
-    urlpatterns += patterns('django.views',
22  
-        url(r'^%s(?P<path>.*)' % IMG_PATH, 'static.serve', {'document_root': IMG_DIR}, name='elsewhere_img')
23  
-    )
24  
-
25  
-# fill the database if it hasn't been filled already
26  
-fill_db()
58  views.py
... ...
@@ -1,58 +0,0 @@
1  
-from django.http import HttpResponse, HttpResponseRedirect, HttpResponseServerError
2  
-from django.template import RequestContext
3  
-from django.contrib.auth.decorators import login_required
4  
-from django.shortcuts import render_to_response
5  
-
6  
-from elsewhere.models import *
7  
-
8  
-
9  
-@login_required
10  
-def example(request):
11  
-    if request.method == 'POST':
12  
-
13  
-        new_data = request.POST.copy()
14  
-
15  
-        # Add forms
16  
-        if new_data.get('sn-form') or new_data.get('im-form') or new_data.get('w-form'):
17  
-
18  
-            if new_data.get('sn-form'):
19  
-                form = SocialNetworkForm(new_data)
20  
-            elif new_data.get('im-form'):
21  
-                form = InstantMessengerForm(new_data)
22  
-            elif new_data.get('w-form'):
23  
-                form = WebsiteForm(new_data)
24  
-
25  
-            if form.is_valid():
26  
-                profile = form.save(commit=False)
27  
-                profile.user = request.user
28  
-                profile.save()
29  
-                return HttpResponseRedirect(request.path)
30  
-            else:
31  
-                ## TODO should probably show the errors
32  
-                print form.errors
33  
-
34  
-        # Delete forms
35  
-        elif new_data.get('delete-sn-form') or new_data.get('delete-im-form') or new_data.get('delete-w-form'):
36  
-            delete_id = request.POST['delete_id']
37  
-
38  
-            if new_data.get('delete-sn-form'):
39  
-                request.user.social_network_profiles.get(id=delete_id).delete()
40  
-            elif new_data.get('delete-im-form'):
41  
-                request.user.instant_messenger_profiles.get(id=delete_id).delete()
42  
-            elif new_data.get('delete-w-form'):
43  
-                request.user.website_profiles.get(id=delete_id).delete()
44  
-
45  
-            return HttpResponseRedirect(request.path)
46  
-
47  
-        # WTF?
48  
-        else:
49  
-            return HttpResponseServerError
50  
-
51  
-    # Create blank forms
52  
-    sn_form = SocialNetworkForm()
53  
-    im_form = InstantMessengerForm()
54  
-    w_form = WebsiteForm()
55  
-
56  
-    return render_to_response('elsewhere/example.html', {
57  
-        'sn_form': sn_form, 'im_form': im_form, 'w_form': w_form,
58  
-    }, context_instance=RequestContext(request))

0 notes on commit d6416e1

Please sign in to comment.
Something went wrong with that request. Please try again.