WIP on config

config-feature
Özcan Oğuz 5 years ago
parent 12bc2c7f04
commit c4293e28d3
  1. 19
      README.md
  2. 27
      mediagoblin-oyd/__init__.py

@ -2,3 +2,22 @@ MediaGoblin for ÖYD
===================
A simple plugin for https://medya.oyd.org.tr derived from LibrePlanet
## Installation
Copy `mediagoblin-oyd` directory to `$MEDIAGOBLIN_HOME/mediagoblin/plugins`
Add `[[mediagoblin.plugins.mediagoblin-oyd]]` to `mediagoblin.ini` file
## Usage
Example config:
```
[[mediagoblin.plugins.mediagoblin-oyd]]
name = type, tag
```
Valid type inputs are `image, video, audio, pdf, raw_image, ascii, stl`
Please sure that you enabled these filetypes in your `mediagoblin.ini` file.
In this configuration, `name` will be the shortcode for your category. You can use
this as `{{ media_grid(request, name) }}` in your templates such as `root.html`.

@ -74,26 +74,27 @@ def lp_media_for_type(db, type, tag=None, max_items=MAX_HOME_ITEMS_DEFAULT):
@user_not_banned
def frontpage_view(request):
config = get_config('mediagoblin.plugins.mediagoblin-oyd')
categories = config.items()
images = lp_media_for_type(request.db, u'mediagoblin.media_types.image', None, MAX_HOME_ALL_PHOTO_ITEMS)
videos = lp_media_for_type(request.db, u'mediagoblin.media_types.video', None, MAX_HOME_ALL_VIDEO_ITEMS)
logolar = lp_media_for_type(request.db, u'mediagoblin.media_types.image', "logo", MAX_HOME_LP_ITEMS)
bultenler = lp_media_for_type(request.db, u'mediagoblin.media_types.pdf', "bulten", MAX_HOME_LP_ITEMS)
yayinlar = lp_media_for_type(request.db, u'mediagoblin.media_types.pdf', "yayin", MAX_HOME_LP_ITEMS)
names = []
for name, (type, tag) in categories:
globals()[name] = lp_media_for_type(request.db, u'mediagoblin.media_types.{}'.format(type), tag, MAX_HOME_FEATURED_ITEMS)
names.append(name)
# logolar = lp_media_for_type(request.db, u'mediagoblin.media_types.image', "logo", MAX_HOME_LP_ITEMS)
# bultenler = lp_media_for_type(request.db, u'mediagoblin.media_types.pdf', "bulten", MAX_HOME_LP_ITEMS)
# yayinlar = lp_media_for_type(request.db, u'mediagoblin.media_types.pdf', "yayin", MAX_HOME_LP_ITEMS)
featured_images = lp_media_for_type(request.db, u'mediagoblin.media_types.image', FEATURED_TAG, MAX_HOME_FEATURED_ITEMS)
featured_videos = lp_media_for_type(request.db, u'mediagoblin.media_types.video', FEATURED_TAG, MAX_HOME_FEATURED_ITEMS)
send_dict = {'images': images, 'videos': videos, 'featured_videos': featured_videos, 'allow_registration': mg_globals.app_config["allow_registration"]}
for item in names:
send_dict[item] = item
return render_to_response(
request, 'oyd/root.html',
{'images': images,
'videos': videos,
'logolar': logolar,
'bultenler': bultenler,
'yayinlar': yayinlar,
'featured_images': featured_images,
'featured_videos': featured_videos,
'allow_registration': mg_globals.app_config["allow_registration"]})
send_dict)
def frontpage_view_hook():
return frontpage_view

Loading…
Cancel
Save