Browse Source

Move portal plugin to seperate repo

Peter Justin 7 years ago
parent
commit
a3f4e1b058

+ 0 - 64
flaskbb/plugins/portal/__init__.py

@@ -1,64 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    flaskbb.plugins.portal
-    ~~~~~~~~~~~~~~~~~~~~~~
-
-    A Portal Plugin for FlaskBB.
-
-    :copyright: (c) 2014 by the FlaskBB Team.
-    :license: BSD, see LICENSE for more details.
-"""
-from flask_plugins import connect_event
-
-from flaskbb.plugins import FlaskBBPlugin
-from flaskbb.utils.populate import (create_settings_from_fixture,
-                                    delete_settings_from_fixture)
-from flaskbb.forum.models import Forum
-
-from .views import portal, inject_portal_link
-
-__plugin__ = "PortalPlugin"
-
-
-def available_forums():
-    forums = Forum.query.order_by(Forum.id.asc()).all()
-    return [(forum.id, forum.title) for forum in forums]
-
-
-fixture = (
-    ('plugin_portal', {
-        'name': "Portal Settings",
-        "description": "Configure the portal",
-        "settings": (
-            ('plugin_portal_forum_ids', {
-                'value': [1],
-                'value_type': "selectmultiple",
-                'name': "Forum IDs",
-                'description': ("The forum ids from which forums the posts "
-                                "should be displayed on the portal."),
-                'extra': {"choices": available_forums, "coerce": int}
-            }),
-            ('plugin_portal_recent_topics', {
-                'value': 10,
-                'value_type': "integer",
-                'name': "Number of Recent Topics",
-                'description': "The number of topics in Recent Topics.",
-                'extra': {"min": 1},
-            }),
-        ),
-    }),
-)
-
-
-class PortalPlugin(FlaskBBPlugin):
-    settings_key = 'plugin_portal'
-
-    def setup(self):
-        self.register_blueprint(portal, url_prefix="/portal")
-        connect_event("before-first-navigation-element", inject_portal_link)
-
-    def install(self):
-        create_settings_from_fixture(fixture)
-
-    def uninstall(self):
-        delete_settings_from_fixture(fixture)

+ 0 - 9
flaskbb/plugins/portal/info.json

@@ -1,9 +0,0 @@
-{
-    "identifier": "portal",
-    "name": "Portal Plugin",
-    "author": "sh4nks",
-    "website": "http://flaskbb.org",
-    "license": "BSD",
-    "description": "This Plugin provides a simple portal for FlaskBB.",
-    "version": "0.1"
-}

+ 0 - 204
flaskbb/plugins/portal/templates/index.html

@@ -1,204 +0,0 @@
-{% extends theme("layout.html") %}
-
-{% block css %}
-  {{  super() }}
-
-  <style>
-  /* news posts */
-  .portal-info {
-      font-size:15px;
-      color:#999999;
-      padding: 0;
-      margin-top:5px;
-      margin-bottom:10px;
-      margin-right: 0px;
-      margin-left: 0px;
-  }
-  .portal-info ul {
-      list-style-type:none;
-  }
-  .portal-info li {
-      display:inline;
-      padding-right:10px;
-  }
-
-  .portal-info a {
-      color:#999999;
-  }
-  .portal-content h1,
-  .portal-content h2,
-  .portal-content h3,
-  .portal-content h4,
-  .portal-content h5 {
-      font-weight:500;
-  }
-  .portal-content img {
-      max-width:100%;
-      max-height:100%;
-  }
-
-  /* recent topics */
-  .portal-topic:not(:first-child) {
-    padding-top: 5px;
-    clear: both;
-    border-top: 1px solid #ddd;
-  }
-
-  .portal-topic-name {
-    float: left;
-  }
-
-  .portal-topic-updated-by {
-    float: right;
-  }
-
-  .portal-topic-updated {
-    color:#999999;
-    clear: both;
-    float: right;
-  }
-
-  /* stats */
-  .portal-stats {
-    color:#999999;
-  }
-  .portal-stats:not(:first-child) {
-    padding-top: 5px;
-    clear: both;
-  }
-
-  .portal-stats-left {
-    float: left;
-  }
-
-  .portal-stats-right {
-    float: right;
-  }
-  </style>
-{% endblock %}
-
-{% block content %}
-<div class="row">
-
-  <!-- Left -->
-  <div class="col-md-8">
-    <div class="panel panel-default panel-widget">
-      <div class="panel-heading panel-widget-heading">
-        <h3 class="panel-title">News</h3>
-      </div>
-      <div class="panel-body panel-widget-body" style="padding-top: 0px">
-
-      {% for topic in news.items %}
-        <h1><a href="{{ topic.url }}">{{ topic.title }}</a></h1>
-        <ul class="portal-info">
-            <li><i class="fa fa-calendar"></i> {{ topic.date_created|format_date('%b %d %Y') }}</li>
-            <li><i class="fa fa-user"></i> <a href="{{ url_for('user.profile', username=topic.user.username) }}">{{ topic.user.username }}</a></li>
-            <li><i class="fa fa-comment"></i> <a href="{{ topic.url }}">Comments ({{ topic.post_count }})</a></li>
-        </ul>
-        <div class="portal-content">
-            {{ topic.first_post.content | markup | safe }}<br />
-        </div>
-        {% if not loop.last %}<hr>{% endif %}
-      {% endfor %}
-
-      </div> <!-- /.panel-body -->
-    </div>
-
-  </div>
-
-  <!-- Right -->
-  <div class="col-md-4">
-    <div class="panel panel-default panel-widget">
-      <div class="panel-heading panel-widget-heading">
-        <h3 class="panel-title">Recent Topics</h3>
-      </div>
-      <div class="panel-body panel-widget-body">
-      {% for topic in recent_topics %}
-
-          <div class="portal-topic">
-            <div class="portal-topic-name">
-              <a href="{{ topic.url }}">{{ topic.title | truncate(length=45) }}</a>
-            </div>
-            <div class="portal-topic-updated-by">
-              <a href="{{ url_for('user.profile', username=topic.user.username) }}">{{ topic.user.username }}</a>
-            </div>
-            <div class="portal-topic-updated">
-              {{ topic.last_updated | time_since }}
-            </div>
-          </div> <!-- /.topic -->
-
-      {% endfor %}
-      </div>
-    </div>
-
-    <div class="panel panel-default panel-widget">
-      <div class="panel-heading panel-widget-heading">
-        <h3 class="panel-title">Statistics</h3>
-      </div>
-      <div class="panel-body panel-widget-body">
-
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Topics
-              </div>
-              <div class="portal-stats-right">
-                {{ topic_count }}
-              </div>
-            </div>
-
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Posts
-              </div>
-              <div class="portal-stats-right">
-                {{ post_count }}
-              </div>
-            </div>
-
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Registered Users
-              </div>
-              <div class="portal-stats-right">
-                {{ user_count }}
-              </div>
-            </div>
-
-            {% if newest_user %}
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Newest User
-              </div>
-              <div class="portal-stats-right">
-                <a href="{{ newest_user.url }}">{{ newest_user.username }}</a>
-              </div>
-            </div>
-            {% endif %}
-
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Online Users
-              </div>
-
-              <div class="portal-stats-right">
-                {{ online_users }}
-              </div>
-            </div>
-
-            {% if config["REDIS_ENABLED"] %}
-            <div class="portal-stats">
-              <div class="portal-stats-left">
-                Guests online
-              </div>
-
-              <div class="portal-stats-right">
-                {{ online_guests }}
-              </div>
-            </div>
-            {% endif %}
-      </div>
-    </div>
-  </div>
-
-</div>
-{% endblock %}

+ 0 - 5
flaskbb/plugins/portal/templates/navigation_snippet.html

@@ -1,5 +0,0 @@
-<li {% if 'portal.index' == request.endpoint %}class="active"{% endif %}>
-    <a href={{ url_for('portal.index') }}>
-        <i class="fa fa-home"></i> Portal
-    </a>
-</li>

+ 0 - 24
flaskbb/plugins/portal/translations/de/LC_MESSAGES/messages.po

@@ -1,24 +0,0 @@
-# German translations for PROJECT.
-# Copyright (C) 2015 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2015-01-05 21:38+0100\n"
-"PO-Revision-Date: 2015-01-05 21:38+0100\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: de <LL@li.org>\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 1.3\n"
-
-#: /home/peter/Development/flaskbb/flaskbb/plugins/portal/views.py:26
-msgid ""
-"Please install the plugin first to configure the forums which should be "
-"displayed"
-msgstr "Bitte installieren sie das Plugin zuerst. Danach können sie es in der Administration konfigurieren."

+ 0 - 25
flaskbb/plugins/portal/translations/en/LC_MESSAGES/messages.po

@@ -1,25 +0,0 @@
-# English translations for PROJECT.
-# Copyright (C) 2015 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2015-02-13 14:26+0100\n"
-"PO-Revision-Date: 2015-01-05 21:38+0100\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: en <LL@li.org>\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 1.3\n"
-
-#: /home/peter/Development/flaskbb/flaskbb/plugins/portal/views.py:26
-msgid ""
-"Please install the plugin first to configure the forums which should be "
-"displayed"
-msgstr "Please install the plugin first in order to configure which forums are displayed."
-

+ 0 - 25
flaskbb/plugins/portal/translations/messages.pot

@@ -1,25 +0,0 @@
-# Translations template for PROJECT.
-# Copyright (C) 2016 ORGANIZATION
-# This file is distributed under the same license as the PROJECT project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2016-06-09 11:35+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.2.0\n"
-
-#: /Users/peter/Development/flaskbb/flaskbb/plugins/portal/views.py:36
-msgid ""
-"Please install the plugin first to configure the forums which should be "
-"displayed."
-msgstr ""
-

+ 0 - 73
flaskbb/plugins/portal/views.py

@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    flaskbb.plugins.portal.views
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    This module contains the portal view.
-
-    :copyright: (c) 2014 by the FlaskBB Team.
-    :license: BSD, see LICENSE for more details.
-"""
-from flask import Blueprint, current_app, flash, request
-from flask_babelplus import gettext as _
-from flask_login import current_user
-
-from flaskbb.utils.helpers import render_template
-from flaskbb.forum.models import Topic, Post, Forum
-from flaskbb.user.models import User, Group
-from flaskbb.utils.helpers import time_diff, get_online_users
-from flaskbb.utils.settings import flaskbb_config
-
-portal = Blueprint("portal", __name__, template_folder="templates")
-
-
-def inject_portal_link():
-    return render_template("navigation_snippet.html")
-
-
-@portal.route("/")
-def index():
-    page = request.args.get('page', 1, type=int)
-
-    try:
-        forum_ids = flaskbb_config["PLUGIN_PORTAL_FORUM_IDS"]
-    except KeyError:
-        forum_ids = []
-        flash(_("Please install the plugin first to configure the forums "
-                "which should be displayed."), "warning")
-
-    group_ids = [group.id for group in current_user.groups]
-    forums = Forum.query.filter(Forum.groups.any(Group.id.in_(group_ids)))
-
-    # get the news forums - check for permissions
-    news_ids = [f.id for f in forums.filter(Forum.id.in_(forum_ids)).all()]
-    news = Topic.query.filter(Topic.forum_id.in_(news_ids)).\
-        order_by(Topic.id.desc()).\
-        paginate(page, flaskbb_config["TOPICS_PER_PAGE"], True)
-
-    # get the recent topics from all to the user available forums (not just the
-    # configured ones)
-    all_ids = [f.id for f in forums.all()]
-    recent_topics = Topic.query.filter(Topic.forum_id.in_(all_ids)).\
-        order_by(Topic.last_updated.desc()).\
-        limit(flaskbb_config.get("PLUGIN_PORTAL_RECENT_TOPICS", 10))
-
-    user_count = User.query.count()
-    topic_count = Topic.query.count()
-    post_count = Post.query.count()
-    newest_user = User.query.order_by(User.id.desc()).first()
-
-    # Check if we use redis or not
-    if not current_app.config["REDIS_ENABLED"]:
-        online_users = User.query.filter(User.lastseen >= time_diff()).count()
-        online_guests = None
-    else:
-        online_users = len(get_online_users())
-        online_guests = len(get_online_users(guest=True))
-
-    return render_template("index.html", news=news,
-                           recent_topics=recent_topics,
-                           user_count=user_count, topic_count=topic_count,
-                           post_count=post_count, newest_user=newest_user,
-                           online_guests=online_guests,
-                           online_users=online_users)