First commit!

master
David Thompson 9 years ago
commit 724f8731f7
  1. 2
      .gitignore
  2. 1
      AUTHORS
  3. 69
      COPYING
  4. 4
      README.md
  5. 73
      mediagoblin_libreplanet/__init__.py
  6. 32
      mediagoblin_libreplanet/templates/libreplanet/listing.html
  7. 60
      mediagoblin_libreplanet/templates/libreplanet/root.html
  8. 46
      mediagoblin_libreplanet/views.py
  9. 26
      setup.py

2
.gitignore vendored

@ -0,0 +1,2 @@
*.pyc
/mediagoblin_libreplanet.egg-info/

@ -0,0 +1 @@
David Thompson <davet@gnu.org>

@ -0,0 +1,69 @@
=========
COPYING
=========
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program, in the file ``licenses/AGPLv3.txt``.
If not, see <http://www.gnu.org/licenses/>.
Translation files located under ``mediagoblin/i18n/`` directory tree
are free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
You should have received a copy of the GNU Affero General Public
License along with this program, in the file ``licenses/AGPLv3.txt``.
If not, see <http://www.gnu.org/licenses/>.
JavaScript files located in the ``mediagoblin/`` directory tree
are free software: you can redistribute and/or modify them under the
terms of the GNU Affero General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
You should have received a copy of the GNU Lesser General Public
License along with this program, in the file ``licenses/LGPLv3.txt``.
If not, see <http://www.gnu.org/licenses/>.
Documentation files located in the ``docs/`` directory tree and all
original documentation theme CSS and assets (including image files)
are released under a CC0 license. To the extent possible under law,
the author(s) have dedicated all copyright and related and neighboring
rights to these files to the public domain worldwide. These files are
distributed without any warranty.
You should have received a copy of the CC0 license in the file
``licenses/CC0_1.0.txt``. If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
CSS, images and video located in the ``mediagoblin/`` directory tree are
released under a CC0 license. To the extent possible under law, the author(s)
have dedicated all copyright and related and neighboring rights to these
files to the public domain worldwide. These files are distributed without
any warranty.
You should have received a copy of the CC0 license in the file
``licenses/CC0_1.0.txt``. If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
Additional library software has been made available in the ``extlib/``
directory. All of it is Free Software and can be distributed under
liberal terms, but those terms may differ in detail from the AGPL's
particulars. See each package's license file in the extlib directory
for additional terms.

@ -0,0 +1,4 @@
MediaGoblin for LibrePlanet
===========================
A simple plugin for https://media.libreplanet.org

@ -0,0 +1,73 @@
# MediaGoblin for LibrePlanet
# Copyright (C) 2015 David Thompson <davet@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from mediagoblin import mg_globals
from mediagoblin.tools.pluginapi import get_config, register_template_path, register_routes
from mediagoblin.db.models import MediaEntry
from mediagoblin.db.util import media_entries_for_tag_slug
from mediagoblin.tools.pagination import Pagination
from mediagoblin.tools.response import render_to_response
from mediagoblin.decorators import uses_pagination, user_not_banned
PLUGIN_DIR = os.path.dirname(__file__)
MAX_HOME_ITEMS = 20
LP_TAG = 'libreplanet2014'
_log = logging.getLogger(__name__)
# This is the function that gets called when the setup
# hook fires.
def setup_plugin():
_log.info("Setting up Libreplanet...")
# Register the template path.
register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
def lp_media_for_type(db, type):
return media_entries_for_tag_slug(db, 'libreplanet2015').\
filter(MediaEntry.media_type == type).\
order_by(MediaEntry.created.desc()).\
limit(MAX_HOME_ITEMS)
@user_not_banned
def frontpage_view(request):
images = lp_media_for_type(request.db, u'mediagoblin.media_types.image')
videos = lp_media_for_type(request.db, u'mediagoblin.media_types.video')
return render_to_response(
request, 'libreplanet/root.html',
{'images': images,
'videos': videos,
'allow_registration': mg_globals.app_config["allow_registration"]})
def frontpage_view_hook():
return frontpage_view
register_routes([('all-videos', '/videos',
'mediagoblin_libreplanet.views:video_listing'),
('all-photos', '/photos',
'mediagoblin_libreplanet.views:image_listing')
])
# This is a dict that specifies which hooks this plugin uses.
# This one only uses one hook: setup.
hooks = {
'setup': setup_plugin,
'frontpage_view': frontpage_view_hook
}

@ -0,0 +1,32 @@
{#
# MediaGoblin for LibrePlanet
# Copyright (C) 2011, 2012 MediaGoblin contributors
# Copyright (C) 2015 David Thompson <davet@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "mediagoblin/base.html" %}
{% from "mediagoblin/utils/object_gallery.html" import object_gallery %}
{% block title %}
{{ title }} &mdash; {{ super() }}
{% endblock %}
{% block mediagoblin_content -%}
<h1>{{ title }}</h1>
{{ object_gallery(request, media_entries, pagination) }}
{% endblock %}

@ -0,0 +1,60 @@
{#
# MediaGoblin for LibrePlanet
# Copyright (C) 2011, 2012 MediaGoblin contributors
# Copyright (C) 2015 David Thompson <davet@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "mediagoblin/base.html" %}
{% from "mediagoblin/utils/object_gallery.html" import media_grid %}
{% set feed_url = request.urlgen('mediagoblin.listings.atom_feed') %}
{% block mediagoblin_head -%}
{% set feed_url = request.urlgen('mediagoblin.listings.atom_feed') -%}
<link rel="alternate" type="application/atom+xml" href="{{ feed_url }}">
{%- endblock mediagoblin_head %}
{% block mediagoblin_content %}
<h1>{% trans %}LibrePlanet{% endtrans %}</h1>
<img class="right_align" src="//static.fsf.org/nosvn/libreplanet/2015/graphical_assets/lp-logo-for-gmg.svg" />
<p>
{% trans %}The videos on this site were recorded during&nbsp;
<a href="http://libreplanet.org">LibrePlanet</a>, an annual
conference for free software enthusiasts held by the Free
Software Foundation in Cambridge, MA. This site is running
<a href="http://mediagoblin.org">MediaGoblin</a>, a great piece
of free media hosting software.{% endtrans %}
</p>
<div class="clear"></div>
<h2>{% trans %}Videos{% endtrans %}</h2>
{{ media_grid(request, videos) }}
<div class="clear"></div>
<p>
<a href="/videos">View all LibrePlanet videos</a>
</p>
<h2>{% trans %}Photos{% endtrans %}</h2>
{{ media_grid(request, images) }}
<div class="clear"></div>
<p>
<a href="/photos">View all LibrePlanet photos</a>
</p>
{#- Need to set feed_url within this block so template can use it. -#}
{%- set feed_url = feed_url -%}
{%- include "mediagoblin/utils/feed_link.html" -%}
{% endblock %}

@ -0,0 +1,46 @@
# MediaGoblin for LibrePlanet
# Copyright (C) 2015 David Thompson <davet@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from mediagoblin import mg_globals
from mediagoblin.db.models import MediaEntry
from mediagoblin.db.util import media_entries_for_tag_slug
from mediagoblin.tools.pagination import Pagination
from mediagoblin.tools.response import render_to_response
from mediagoblin.decorators import uses_pagination
def type_listing(type, title, request, page):
cursor = MediaEntry.query.\
filter(MediaEntry.media_type == type).\
order_by(MediaEntry.created.desc())
pagination = Pagination(page, cursor)
media_entries = pagination()
return render_to_response(
request,
'libreplanet/listing.html',
{'title': title,
'media_entries': media_entries,
'pagination': pagination})
@uses_pagination
def image_listing(request, page):
return type_listing(u'mediagoblin.media_types.image', 'Photos', request, page)
@uses_pagination
def video_listing(request, page):
return type_listing(u'mediagoblin.media_types.video', 'Videos', request, page)

@ -0,0 +1,26 @@
# MediaGoblin for LibrePlanet
# Copyright (C) 2015 David Thompson <davet@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup, find_packages
setup(
name='mediagoblin_libreplanet',
version='0.1',
packages=find_packages(),
include_package_data=True,
install_requires=[],
license='AGPLv3',
)
Loading…
Cancel
Save