| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # Copyright (C) 2007 Samalyse SARL |
|---|
| 3 | # Copyright (c) 2007-2011 Parisson SARL |
|---|
| 4 | |
|---|
| 5 | # This software is a computer program whose purpose is to backup, analyse, |
|---|
| 6 | # transcode and stream any audio content with its metadata over a web frontend. |
|---|
| 7 | |
|---|
| 8 | # This software is governed by the CeCILL license under French law and |
|---|
| 9 | # abiding by the rules of distribution of free software. You can use, |
|---|
| 10 | # modify and/ or redistribute the software under the terms of the CeCILL |
|---|
| 11 | # license as circulated by CEA, CNRS and INRIA at the following URL |
|---|
| 12 | # "http://www.cecill.info". |
|---|
| 13 | |
|---|
| 14 | # As a counterpart to the access to the source code and rights to copy, |
|---|
| 15 | # modify and redistribute granted by the license, users are provided only |
|---|
| 16 | # with a limited warranty and the software's author, the holder of the |
|---|
| 17 | # economic rights, and the successive licensors have only limited |
|---|
| 18 | # liability. |
|---|
| 19 | |
|---|
| 20 | # In this respect, the user's attention is drawn to the risks associated |
|---|
| 21 | # with loading, using, modifying and/or developing or reproducing the |
|---|
| 22 | # software by the user in light of its specific status of free software, |
|---|
| 23 | # that may mean that it is complicated to manipulate, and that also |
|---|
| 24 | # therefore means that it is reserved for developers and experienced |
|---|
| 25 | # professionals having in-depth computer knowledge. Users are therefore |
|---|
| 26 | # encouraged to load and test the software's suitability as regards their |
|---|
| 27 | # requirements in conditions enabling the security of their systems and/or |
|---|
| 28 | # data to be ensured and, more generally, to use and operate it in the |
|---|
| 29 | # same conditions as regards security. |
|---|
| 30 | |
|---|
| 31 | # The fact that you are presently reading this means that you have had |
|---|
| 32 | # knowledge of the CeCILL license and that you accept its terms. |
|---|
| 33 | # |
|---|
| 34 | # Authors: Olivier Guilyardi <olivier@samalyse.com> |
|---|
| 35 | # Guillaume Pellerin <yomguy@parisson.com> |
|---|
| 36 | |
|---|
| 37 | from django.conf.urls.defaults import * |
|---|
| 38 | from telemeta.models import MediaItem, MediaCollection, MediaItemMarker |
|---|
| 39 | from telemeta.web.base import GeneralView, AdminView, CollectionView, ItemView, \ |
|---|
| 40 | InstrumentView, PlaylistView, ProfileView, GeoView, \ |
|---|
| 41 | LastestRevisionsFeed |
|---|
| 42 | from jsonrpc import jsonrpc_site |
|---|
| 43 | import os.path |
|---|
| 44 | import telemeta.config |
|---|
| 45 | |
|---|
| 46 | telemeta.config.check() |
|---|
| 47 | |
|---|
| 48 | # initialization |
|---|
| 49 | general_view = GeneralView() |
|---|
| 50 | admin_view = AdminView() |
|---|
| 51 | collection_view = CollectionView() |
|---|
| 52 | item_view = ItemView() |
|---|
| 53 | instrument_view = InstrumentView() |
|---|
| 54 | playlist_view = PlaylistView() |
|---|
| 55 | profile_view = ProfileView() |
|---|
| 56 | geo_view = GeoView() |
|---|
| 57 | |
|---|
| 58 | # query sets for Django generic views |
|---|
| 59 | all_items = { 'queryset': MediaItem.objects.enriched().order_by('code', 'old_code') } |
|---|
| 60 | all_collections = { 'queryset': MediaCollection.objects.enriched(), } |
|---|
| 61 | |
|---|
| 62 | # CREM collections |
|---|
| 63 | all_collections_unpublished = { 'queryset': MediaCollection.objects.filter(code__contains='_I_'), } |
|---|
| 64 | all_collections_published = { 'queryset': MediaCollection.objects.filter(code__contains='_E_'), } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | # ID's regular expressions |
|---|
| 68 | export_extensions = "|".join(item_view.list_export_extensions()) |
|---|
| 69 | |
|---|
| 70 | htdocs = os.path.dirname(__file__) + '/htdocs' |
|---|
| 71 | |
|---|
| 72 | urlpatterns = patterns('', |
|---|
| 73 | url(r'^$', general_view.index, name="telemeta-home"), |
|---|
| 74 | |
|---|
| 75 | # items |
|---|
| 76 | url(r'^items/$', 'django.views.generic.list_detail.object_list', |
|---|
| 77 | dict(all_items, paginate_by=20, template_name="telemeta/mediaitem_list.html"), |
|---|
| 78 | name="telemeta-items"), |
|---|
| 79 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/$', item_view.item_detail, |
|---|
| 80 | name="telemeta-item-detail"), |
|---|
| 81 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', item_view.item_detail, |
|---|
| 82 | {'template': 'telemeta/mediaitem_detail_dc.html'}, |
|---|
| 83 | name="telemeta-item-dublincore"), |
|---|
| 84 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/dc/xml/$', item_view.item_detail, |
|---|
| 85 | {'format': 'dublin_core_xml'}, |
|---|
| 86 | name="telemeta-item-dublincore-xml"), |
|---|
| 87 | url(r'^items/download/(?P<public_id>[A-Za-z0-9._-]+)\.(?P<extension>' |
|---|
| 88 | + export_extensions + ')$', |
|---|
| 89 | item_view.item_export, |
|---|
| 90 | name="telemeta-item-export"), |
|---|
| 91 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/visualize/(?P<visualizer_id>[0-9a-z_]+)/(?P<width>[0-9A-Z]+)x(?P<height>[0-9A-Z]+)/$', |
|---|
| 92 | item_view.item_visualize, |
|---|
| 93 | name="telemeta-item-visualize"), |
|---|
| 94 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/analyze/xml/$', |
|---|
| 95 | item_view.item_analyze_xml, |
|---|
| 96 | name="telemeta-item-analyze-xml"), |
|---|
| 97 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/item_xspf.xml$', |
|---|
| 98 | item_view.item_playlist, |
|---|
| 99 | dict(template="telemeta/mediaitem_xspf.xml", mimetype="application/xspf+xml"), |
|---|
| 100 | name="telemeta-item-xspf"), |
|---|
| 101 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', item_view.item_edit, |
|---|
| 102 | dict(template='telemeta/mediaitem_edit.html'), name="telemeta-item-edit"), |
|---|
| 103 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', item_view.item_copy, |
|---|
| 104 | dict(template='telemeta/mediaitem_copy.html'), name="telemeta-item-copy"), |
|---|
| 105 | url(r'^item/add/$', item_view.item_add, |
|---|
| 106 | dict(template='telemeta/mediaitem_add.html'), name="telemeta-item-add"), |
|---|
| 107 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/player/(?P<width>[0-9]+)x(?P<height>[0-9]+)/$', item_view.item_detail, |
|---|
| 108 | dict(template='telemeta/mediaitem_player.html'), name="telemeta-item-player"), |
|---|
| 109 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/performances/$', item_view.item_performances_edit, |
|---|
| 110 | dict(template='telemeta/mediaitem_performances_edit.html'), name="telemeta-item-performances_edit"), |
|---|
| 111 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/keywords/$', item_view.item_keywords_edit, |
|---|
| 112 | dict(template='telemeta/mediaitem_keywords_edit.html'), name="telemeta-item-keywords_edit"), |
|---|
| 113 | url(r'^items/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', item_view.item_delete, name="telemeta-item-delete"), |
|---|
| 114 | |
|---|
| 115 | # Markers |
|---|
| 116 | url(r'^markers/(?P<marker_id>[A-Za-z0-9]+)/$', item_view.item_detail, name="telemeta-item-detail-marker"), |
|---|
| 117 | |
|---|
| 118 | # collections |
|---|
| 119 | url(r'^collections/$', 'django.views.generic.list_detail.object_list', |
|---|
| 120 | dict(all_collections, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections"), |
|---|
| 121 | url(r'^collections_unpublished/$', 'django.views.generic.list_detail.object_list', |
|---|
| 122 | dict(all_collections_unpublished, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections-unpublished"), |
|---|
| 123 | url(r'^collections_published/$', 'django.views.generic.list_detail.object_list', |
|---|
| 124 | dict(all_collections_published, paginate_by=20, template_name="telemeta/collection_list.html"), name="telemeta-collections-published"), |
|---|
| 125 | url(r'^collections/?page=(?P<page>[0-9]+)$', |
|---|
| 126 | 'django.views.generic.list_detail.object_list', |
|---|
| 127 | dict(all_collections, paginate_by=20)), |
|---|
| 128 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/$', collection_view.collection_detail, |
|---|
| 129 | dict(template="telemeta/collection_detail.html"), name="telemeta-collection-detail"), |
|---|
| 130 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/dc/$', collection_view.collection_detail, |
|---|
| 131 | dict(template="telemeta/collection_detail_dc.html"), name="telemeta-collection-dublincore"), |
|---|
| 132 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/collection_xspf.xml$', |
|---|
| 133 | collection_view.collection_playlist, |
|---|
| 134 | dict(template="telemeta/collection_xspf.xml", mimetype="application/xspf+xml"), |
|---|
| 135 | name="telemeta-collection-xspf"), |
|---|
| 136 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/collection.m3u$', |
|---|
| 137 | collection_view.collection_playlist, |
|---|
| 138 | dict(template="telemeta/collection.m3u", mimetype="audio/mpegurl"), |
|---|
| 139 | name="telemeta-collection-m3u"), |
|---|
| 140 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', collection_view.collection_edit, |
|---|
| 141 | dict(template='telemeta/collection_edit.html'), name="telemeta-collection-edit"), |
|---|
| 142 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/copy/$', collection_view.collection_copy, |
|---|
| 143 | dict(template='telemeta/collection_edit.html'), name="telemeta-collection-copy"), |
|---|
| 144 | url(r'^collections/add/$', collection_view.collection_add, |
|---|
| 145 | dict(template='telemeta/collection_add.html'), name="telemeta-collection-add"), |
|---|
| 146 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/add_item/$', item_view.item_add, |
|---|
| 147 | dict(template='telemeta/mediaitem_add.html'), name="telemeta-collection-additem"), |
|---|
| 148 | url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/delete/$', collection_view.item_delete, name="telemeta-collection-delete"), |
|---|
| 149 | |
|---|
| 150 | # search |
|---|
| 151 | url(r'^search/$', general_view.search, name="telemeta-search"), |
|---|
| 152 | url(r'^search/collections/$', general_view.search, {'type': 'collections'}, |
|---|
| 153 | name="telemeta-search-collections"), |
|---|
| 154 | url(r'^search/items/$', general_view.search, {'type': 'items'}, |
|---|
| 155 | name="telemeta-search-items"), |
|---|
| 156 | url(r'^search/criteria/$', general_view.edit_search, name="telemeta-search-criteria"), |
|---|
| 157 | url(r'^complete_location/$', general_view.complete_location, name="telemeta-complete-location"), |
|---|
| 158 | |
|---|
| 159 | # administration |
|---|
| 160 | url(r'^admin/$', admin_view.admin_index, name="telemeta-admin"), |
|---|
| 161 | url(r'^admin/general/$', admin_view.admin_general, name="telemeta-admin-general"), |
|---|
| 162 | url(r'^admin/enumerations/$', admin_view.admin_enumerations, name="telemeta-admin-enumerations"), |
|---|
| 163 | url(r'^admin/users/$', admin_view.admin_users, name="telemeta-admin-users"), |
|---|
| 164 | |
|---|
| 165 | # instruments administration |
|---|
| 166 | url(r'^admin/instruments/$', |
|---|
| 167 | instrument_view.edit_instrument , |
|---|
| 168 | name="telemeta-instrument-edit"), |
|---|
| 169 | url(r'^admin/instruments/add/$', |
|---|
| 170 | instrument_view.add_to_instrument, |
|---|
| 171 | name="telemeta-instrument-add"), |
|---|
| 172 | url(r'^admin/instruments/update/$', |
|---|
| 173 | instrument_view.update_instrument, |
|---|
| 174 | name="telemeta-instrument-update"), |
|---|
| 175 | url(r'^admin/instruments/' |
|---|
| 176 | + r'(?P<value_id>[0-9]+)/$', |
|---|
| 177 | instrument_view.edit_instrument_value, |
|---|
| 178 | name="telemeta-instrument-record-edit"), |
|---|
| 179 | url(r'^admin/instruments/' |
|---|
| 180 | + r'(?P<value_id>[0-9]+)/update/$', |
|---|
| 181 | instrument_view.update_instrument_value, |
|---|
| 182 | name="telemeta-instrument-record-update"), |
|---|
| 183 | |
|---|
| 184 | # enumerations administration |
|---|
| 185 | url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/$', |
|---|
| 186 | admin_view.edit_enumeration , |
|---|
| 187 | name="telemeta-enumeration-edit"), |
|---|
| 188 | url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/add/$', |
|---|
| 189 | admin_view.add_to_enumeration, |
|---|
| 190 | name="telemeta-enumeration-add"), |
|---|
| 191 | url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/update/$', |
|---|
| 192 | admin_view.update_enumeration, |
|---|
| 193 | name="telemeta-enumeration-update"), |
|---|
| 194 | url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/' |
|---|
| 195 | + r'(?P<value_id>[0-9]+)/$', |
|---|
| 196 | admin_view.edit_enumeration_value, |
|---|
| 197 | name="telemeta-enumeration-record-edit"), |
|---|
| 198 | url(r'^admin/enumerations/(?P<enumeration_id>[0-9a-z]+)/' |
|---|
| 199 | + r'(?P<value_id>[0-9]+)/update/$', |
|---|
| 200 | admin_view.update_enumeration_value, |
|---|
| 201 | name="telemeta-enumeration-record-update"), |
|---|
| 202 | |
|---|
| 203 | # Geographic browsing |
|---|
| 204 | url(r'^geo/$', geo_view.list_continents, name="telemeta-geo-continents"), |
|---|
| 205 | url(r'^geo/(?P<continent>[a-z_]+)/$', geo_view.list_countries, |
|---|
| 206 | name="telemeta-geo-countries"), |
|---|
| 207 | url(r'^geo/collections/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', |
|---|
| 208 | geo_view.list_country_collections, |
|---|
| 209 | name="telemeta-geo-country-collections"), |
|---|
| 210 | url(r'^geo/items/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', |
|---|
| 211 | geo_view.list_country_items, |
|---|
| 212 | name="telemeta-geo-country-items"), |
|---|
| 213 | url(r'^geo/country_info/(?P<id>[0-9a-z]+)/$', |
|---|
| 214 | geo_view.country_info, name="telemeta-country-info"), |
|---|
| 215 | |
|---|
| 216 | # CSS+Images (FIXME: for developement only) |
|---|
| 217 | url(r'^css/(?P<path>.*)$', 'django.views.static.serve', |
|---|
| 218 | {'document_root': htdocs+'/css'}, |
|---|
| 219 | name="telemeta-css"), |
|---|
| 220 | url(r'images/(?P<path>.*)$', 'django.views.static.serve', |
|---|
| 221 | {'document_root': htdocs+'/images'}, |
|---|
| 222 | name="telemeta-images"), |
|---|
| 223 | url(r'^js/(?P<path>.*)$', 'django.views.static.serve', |
|---|
| 224 | {'document_root': htdocs+'/js'}, |
|---|
| 225 | name="telemeta-js"), |
|---|
| 226 | url(r'^swf/(?P<path>.*)$', 'django.views.static.serve', |
|---|
| 227 | {'document_root': htdocs+'/swf'}, |
|---|
| 228 | name="telemeta-swf"), |
|---|
| 229 | url(r'^timeside/(?P<path>.*)$', 'django.views.static.serve', |
|---|
| 230 | {'document_root': htdocs+'/timeside'}, |
|---|
| 231 | name="telemeta-timeside"), |
|---|
| 232 | |
|---|
| 233 | # Flat pages |
|---|
| 234 | url(r'^pages/(?P<path>.*)$', general_view.render_flatpage, name="telemeta-flatpage"), |
|---|
| 235 | |
|---|
| 236 | # OAI-PMH Data Provider |
|---|
| 237 | url(r'^oai/.*$', general_view.handle_oai_request, name="telemeta-oai"), |
|---|
| 238 | |
|---|
| 239 | # Authentication |
|---|
| 240 | url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'}, |
|---|
| 241 | name="telemeta-login"), |
|---|
| 242 | url(r'^logout/$', general_view.logout, name="telemeta-logout"), |
|---|
| 243 | |
|---|
| 244 | # Users |
|---|
| 245 | url(r'^users/$', general_view.users, name="telemeta-users"), |
|---|
| 246 | |
|---|
| 247 | # Profiles |
|---|
| 248 | url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/$', profile_view.profile_detail, name="telemeta-profile-detail"), |
|---|
| 249 | url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/edit/$', profile_view.profile_edit, name="telemeta-profile-edit"), |
|---|
| 250 | |
|---|
| 251 | # Registration |
|---|
| 252 | url(r'^accounts/password_change/$', 'django.contrib.auth.views.password_change', {'template_name': 'telemeta/registration/password_change_form.html'}, name="telemeta-password-change"), |
|---|
| 253 | url(r'^accounts/password_change_done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'telemeta/registration/password_change_done.html'}, name="telemeta-password-change-done"), |
|---|
| 254 | |
|---|
| 255 | url(r'^accounts/password_reset/$', 'django.contrib.auth.views.password_reset', {'template_name': 'telemeta/registration/password_reset_form.html', 'email_template_name': 'telemeta/registration/password_reset_email.html'}, name="telemeta-password-reset"), |
|---|
| 256 | url(r'^accounts/password_reset_done/$', 'django.contrib.auth.views.password_reset_done', {'template_name': 'telemeta/registration/password_reset_done.html'}, name="telemeta-password-reset-done"), |
|---|
| 257 | url(r'^accounts/password_reset_confirm/(?P<uidb36>[A-Za-z0-9._-]+)/(?P<token>[A-Za-z0-9._-]+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name': 'telemeta/registration/password_reset_confirm.html'}, name="telemeta-password-reset-confirm"), |
|---|
| 258 | url(r'^accounts/password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete', {'template_name': 'telemeta/registration/password_reset_complete.html'}, name="telemeta-password-reset-complete"), |
|---|
| 259 | url(r'^accounts/password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete', {'template_name': 'telemeta/registration/password_reset_complete.html'}, name="telemeta-password-reset-complete"), |
|---|
| 260 | |
|---|
| 261 | # JSON RPC |
|---|
| 262 | url(r'json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'), |
|---|
| 263 | # for the graphical browser/web console only, omissible |
|---|
| 264 | # url(r'json/browse/', 'jsonrpc.views.browse', name="jsonrpc_browser"), |
|---|
| 265 | |
|---|
| 266 | # Playlists |
|---|
| 267 | url(r'^playlists/(?P<public_id>[a-zA-Z0-9]+)/(?P<resource_type>[a-zA-Z0-9]+)/csv/$', playlist_view.playlist_csv_export, name="telemeta-playlist-csv-export"), |
|---|
| 268 | |
|---|
| 269 | # RSS feeds |
|---|
| 270 | url(r'^rss/$', LastestRevisionsFeed(), name="telemeta-rss"), |
|---|
| 271 | |
|---|
| 272 | ) |
|---|
| 273 | |
|---|
| 274 | |
|---|