Skip to content

Commit

Permalink
Implement IRC userlist page
Browse files Browse the repository at this point in the history
This page dynamically reads currently connected IRC usernames from
/var/tmp/irc_userlist which is filled by the IRC bot.
  • Loading branch information
eht16 committed Jan 5, 2014
1 parent 91acbed commit d82a171
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
2 changes: 2 additions & 0 deletions geany/settings.py
Expand Up @@ -399,6 +399,8 @@

NIGHTLYBUILDS_BASE_DIR = '/path/to/nightly/builds'

IRC_USER_LIST_FILE = '/var/tmp/irc_userlist'


LOGGING = {
'version': 1,
Expand Down
6 changes: 6 additions & 0 deletions geany/templates/pages/richtextpage.html
Expand Up @@ -6,6 +6,9 @@

<div class="well">

{% block content_before %}
{% endblock %}

{% block richtext_content %}

{# render the content as template, e.g. to replace {{ geany_latest_version }} #}
Expand All @@ -14,6 +17,9 @@
{# display #}
{{ evaluated_content|richtext_filter|safe }}

{% block content_after %}
{% endblock %}

{% endblock %}

</div>
Expand Down
25 changes: 25 additions & 0 deletions geany/templates/pages/support/irc.html
@@ -0,0 +1,25 @@
{% extends "pages/richtextpage.html" %}

{% load geany_tags %}

{% block content_after %}

{% get_irc_userlist as irc_userlist %}

<h2>Users</h2>

<p>Currently {{ irc_userlist|length }} users are connected:</p>

<div class="row">
{% for username in irc_userlist %}
<div class="span2">{{ username }}</div>

{% if forloop.counter|divisibleby:4 %}
</div>
<div class="row">
{% endif %}
{% endfor %}
</div>


{% endblock %}
25 changes: 22 additions & 3 deletions geany/templatetags/geany_tags.py
Expand Up @@ -3,18 +3,22 @@
# 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 django import template
from django.conf import settings
from mezzanine.template import Library
import logging

register = template.Library()
register = Library()
logger = logging.getLogger(__name__)


########################################################################
Expand Down Expand Up @@ -51,3 +55,18 @@ def do_evaluate(parser, token):
raise template.TemplateSyntaxError(u'%r tag requires a single argument' %
token.contents.split()[1])
return EvaluateNode(variable, target_var_name)


#----------------------------------------------------------------------
@register.as_tag
def get_irc_userlist():
user_list = list()
try:
with open(settings.IRC_USER_LIST_FILE) as file_h:
user_list = file_h.readlines()
except IOError, e:
logger.error(u'An error occurred reading IRC user list: %s', unicode(e), exc_info=True)

# remove newline characters
user_list = [username.strip() for username in user_list]
return sorted(user_list)

0 comments on commit d82a171

Please sign in to comment.