Public Controllers¶
MediaCore provides a robust frontend, but if it does not suit your needs you can easily revise it or even completely replace it, while still maintaining the benefits of the admin interface.
Media¶
Publicly Facing Media Controllers
- class mediacore.controllers.media.MediaController(*args, **kwargs)¶
Media actions – for both regular and podcast media
- comment(*args, **kwargs)¶
Post a comment from PostCommentForm.
Parameter: slug – The media slug Returns: Redirect to view() page for media. Renders: string
- explore(*args, **kwargs)¶
Display the most recent 15 media.
Return type: Dict
Returns: - latest
Latest media
- popular
Latest media
Renders: media/explore.html
- index(*args, **kwargs)¶
List media with pagination.
The media paginator may be accessed in the template with c.paginators.media, see webhelpers.paginate.Page.
Parameters: - page (int) – Page number, defaults to 1.
- show (unicode or None) – ‘latest’, ‘popular’ or ‘featured’
- q (unicode or None) – A search query to filter by
- tag (unicode or None) – A tag slug to filter for
Return type: dict
Returns: - media
The list of Media instances for this page.
- result_count
The total number of media items for this query
- search_query
The query the user searched for, if any
Renders: media/index.html
- rate(slug, **kwargs)¶
Say ‘I like this’ for the given media.
Parameter: slug – The media slug Return type: unicode Returns: The new number of likes Renders: string
- serve(id, slug, container, environ, start_response, **kwargs)¶
Serve a MediaFile binary.
Parameters: - id (int) – File ID
- slug (The file container) – The media slug
Raises webob.exc.HTTPNotFound: If no file exists for the given params.
Raises webob.exc.HTTPNotAcceptable: If an Accept header field is present, and if the mimetype of the requested file doesn’t match, then a 406 (not acceptable) response is returned.
Renders: string
- view(*args, **kwargs)¶
Display the media player, info and comments.
Parameters: - slug – The slug to lookup
- podcast_slug – The slug for podcast this media belongs to. Although not necessary for looking up the media, it tells us that the podcast slug was specified in the URL and therefore we reached this action by the preferred route.
Rtype dict: Returns: Renders: media/view.html
Podcasts¶
- class mediacore.controllers.podcasts.PodcastsController(*args, **kwargs)¶
Podcast Series Controller
This handles episode collections, individual episodes are handled as regular media by mediacore.controllers.media.
- feed(*args, **kwargs)¶
Serve the feed as RSS 2.0.
If feedburner_url is specified for this podcast, we redirect there if the useragent does not contain ‘feedburner’, as described here: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464
Parameter: feedburner_bypass – If true, the redirect to feedburner is disabled.
Return type: Dict
Returns: Renders: podcasts/feed.xml XML
Renders: podcasts/feed.xml
- index(*args, **kwargs)¶
List podcasts and podcast media.
Our custom paginate decorator allows us to have fewer podcast episodes display on the first page than on the rest with the items_first_page param. See mediacore.lib.custompaginate.CustomPage.
Parameter: page (int) – Page number, defaults to 1.
Return type: dict
Returns: - podcasts
The Podcast instance
Renders: podcasts/index.html
Error Messages¶
- class mediacore.controllers.error.ErrorController(*args, **kwargs)¶
Generates error documents as and when they are required.
The ErrorDocuments middleware forwards to ErrorController when error related status codes are returned from the application.
This behaviour can be altered by changing the parameters to the ErrorDocuments middleware in your config/middleware.py file.
- document(*args, **kwargs)¶
Render the error document for the general public.
Essentially, when an error occurs, a second request is initiated for the URL /error/document. The URL is set on initialization of the pylons.middleware.StatusCodeRedirect object, and can be overridden in tg.configuration.add_error_middleware(). Also, before this method is called, some potentially useful environ vars are set in pylons.middleware.StatusCodeRedirect.__call__() (access them via tg.request.environ).
Return type: Dict
Returns: - prefix
The environ SCRIPT_NAME.
- vars
A dict containing the first 2 KB of the original request.
- code
Integer error code thrown by the original request, but it can also be overriden by setting tg.request.params['code'].
- message
A message to display to the user. Pulled from tg.request.params['message'].
Renders: error.html
- report(email='', description='', **kwargs)¶
Email a support request that’s been submitted on document().
Redirects back to the root URL /.
Renders: string