Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Issues 78-80, 25 #81

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
83cb9cc
Added site name and short site name to dev.ini and updated templates …
nklonne Jun 1, 2018
3ad8517
Merge branch 'Field_Session' of https://github.com/ColoradoSchoolOfMi…
Jun 1, 2018
69855ec
Image alt and class fixed.
murchison Jun 1, 2018
62b42e1
Set up custom logo loading: Relative path only
Jun 1, 2018
652e5b4
Resolved merge conflict by changing alt to 'Club Logo' and class to '…
Jun 1, 2018
c450a00
Commented out site_name and short_site_name in development.ini to mak…
nklonne Jun 2, 2018
23a2341
Implemented custom logo loading.
Jun 2, 2018
f1f6012
Simplified custom logo loading.
Jun 2, 2018
263c1d8
Implemented custom CSS loading
JadElClemens Jun 2, 2018
447f01c
Documented new config options
JadElClemens Jun 2, 2018
f9b1b39
Fixed documentation on static assets config
JadElClemens Jun 2, 2018
ef1eddb
Really fixed documentation this time
JadElClemens Jun 2, 2018
93220e9
Changes to development.ini items
JadElClemens Jun 6, 2018
a788600
Added site name to config defaults
JadElClemens Jun 6, 2018
9c82e5b
Default value for site.name is now Mozzarella.
Jun 6, 2018
aae73d2
There is now a default image name for the site logo.
Jun 6, 2018
e467d68
Shows site name in place of logo if the file for the logo cannot be f…
Jun 6, 2018
140e84c
Site no longer requires custom_assets config options to be set
JadElClemens Jun 6, 2018
f2fa2ff
Commented out custom assets directory in development.ini.sample and r…
Jun 8, 2018
52a1b9c
Fixed up master.xhtml - no longer uses config-based file locations
JadElClemens Jun 8, 2018
8fe387a
Created basic views and controller for wiki
JadElClemens Jun 8, 2018
d644c3e
Added a link to wiki page
Jun 8, 2018
eafcdfe
Beginning of wiki functionality
JadElClemens Jun 10, 2018
5135258
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
JadElClemens Jun 10, 2018
382434a
Added wiki location config to development.ini.sample
JadElClemens Jun 10, 2018
c20008e
Wiki now adds .rst extension automatically, properly errors when file…
JadElClemens Jun 10, 2018
302e734
Added example config for site.custom_assets
JadElClemens Jun 11, 2018
11cb19e
Added wiki view template
JadElClemens Jun 11, 2018
b3fcb5d
Site now initializes a wiki at the specified location if none exists
JadElClemens Jun 11, 2018
90c2a4f
Removed unnecessary edit and save functions from wiki.py
Jun 11, 2018
a282a02
Wiki repository is now bare
JadElClemens Jun 11, 2018
fa1681d
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
JadElClemens Jun 11, 2018
d590c31
Wiki now accepts positional parameters in URL (/wiki/[pagename] is va…
JadElClemens Jun 11, 2018
5ed344b
Changed wiki controller and template to be in line with running conve…
JadElClemens Jun 11, 2018
0a4a1d4
Partially implemented parsing.
Jun 13, 2018
a4a2d2d
Wiki page now displays in page title
JadElClemens Jun 13, 2018
dec0bb1
removed wiki directory
JadElClemens Jun 13, 2018
8651e63
Cleaned up wiki controller code
JadElClemens Jun 13, 2018
870a305
Added a front page to the wiki.
Jun 16, 2018
8adc66e
Added to the main page a panel about the wiki.
Jun 16, 2018
df096eb
Added info about wiki to README
JadElClemens Jun 16, 2018
bf5c080
Further expanded wiki section in README
JadElClemens Jun 16, 2018
20a6590
Created instructions for Wiki contribution.
Jun 16, 2018
3ad61a4
Wiki revision history now live at /wiki/history/[pagename]
JadElClemens Jun 16, 2018
e988169
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
JadElClemens Jun 16, 2018
d596a6c
Removed wiki dir
JadElClemens Jun 16, 2018
c8ea21b
History page now links back to content page
JadElClemens Jun 16, 2018
539698c
Wiki pages now have a 'links' panel, only includes history page for now
JadElClemens Jun 16, 2018
f115332
revision history page now shows edits in reverse order
JadElClemens Jun 16, 2018
366f0b9
The folder 'wiki' is now ignored.
Jun 16, 2018
81b39f5
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
Jun 16, 2018
3ce08e7
Wiki pages now take their title from the ReST document
JadElClemens Jun 16, 2018
c79b3a2
Index now redirects to FrontPage. FrontPage is now copied from filesy…
JadElClemens Jun 16, 2018
41f1ded
Added a skeleton page for the Page List.
Jun 16, 2018
9385621
Implemented the Page List. TODO: It only lists the name, it doesn't g…
Jun 16, 2018
8ce0381
Slight changes to default wiki frontpage
JadElClemens Jun 17, 2018
ee9c098
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
JadElClemens Jun 17, 2018
0fba5fb
Made wiki pagelist link to pages, files with spaces now supported
JadElClemens Jun 17, 2018
a7fc457
Changed page list to use XML templating rather than filling out a ReS…
JadElClemens Jun 17, 2018
d030827
Cleaned up wiki controller code
JadElClemens Jun 17, 2018
5b761f7
Fixed the auto-initializing an extra PageList page.
Jun 17, 2018
56bb645
Homepage no longer reserves space for banner if banner does not exist
JadElClemens Jun 17, 2018
dfd8763
wiki view page no longer uses containers
JadElClemens Jun 17, 2018
72d81e5
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
JadElClemens Jun 17, 2018
36f5ee8
Removed unnecessary PageList.rst from the wiki-assets directory.
Jun 17, 2018
db1c91e
Merge branch 'fs-wiki' of https://github.com/ColoradoSchoolOfMines/mo…
Jun 17, 2018
de04840
Merge branch 'fs-wiki' into Field_Session
JadElClemens Jun 17, 2018
f1c95ae
Deleted assets dir
JadElClemens Jun 17, 2018
615b2ac
Site configuration values in development.ini.sample are now together.
Jun 21, 2018
93a3ba9
Changed acm-logo CSS class to logo
JadElClemens Jun 21, 2018
a1141bb
Wiki not enabled now results in a 404, imports fixed up, external lin…
JadElClemens Jun 21, 2018
442381b
Merge branch 'fs-wiki' into Field_Session
JadElClemens Jun 21, 2018
a8190ec
Wiki pages no longer use old-style formatting
JadElClemens Jun 21, 2018
f30995d
Began implementing wiki controller in OO manner
JadElClemens Jun 21, 2018
31c0537
Change wiki initialization method
jackrosenthal Oct 23, 2018
3f9090c
fixed initialization of wiki controller
jordannewport Oct 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ pip-log.txt
# paste config files
development.ini
production.ini

# Default wiki directory
wiki.git/
wiki/

# Default assets directory
assets/
23 changes: 23 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,26 @@ Here is an example config for Apache with ``mod_wsgi``:
# Make sure to setup anything else you are using, such as SSL certs
</VirtualHost>

Static Assets
~~~~~~~~~~~~~

The location of site-specific assets for development can be configured in your development config:

.. code:: ini

# Custom Assets Configuration
custom_assets.dir = /path/to/assets/dir
custom_assets.css = relative/path/to/css.file
custom_assets.logo = relative/path/to/logo.file

Wiki
~~~~

Mozzarella includes a wiki that can be enabled by uncommenting the `wiki.repo` option in your configuration.
When visiting the wiki for the first time after enabling it, Mozzarella will generate a bare git repository with a sample
page in it.

.. code:: ini

# Wiki repository location
wiki.repo = /path/to/wiki/dir
3 changes: 3 additions & 0 deletions acmwebsite/config/app_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
# what is the class you want to use to search for users in the database
base_config.sa_auth.user_class = model.User

#Configure site name
base_config['site.name'] = 'Mozzarella'

from tg.configuration.auth import TGAuthMetadata


Expand Down
6 changes: 5 additions & 1 deletion acmwebsite/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"""WSGI middleware initialization for the acm-website application."""
from acmwebsite.config.app_cfg import base_config
from acmwebsite.config.environment import load_environment

# Depot
from depot.manager import DepotManager

from tg.support.statics import StaticsMiddleware

__all__ = ['make_app']

Expand Down Expand Up @@ -34,6 +34,10 @@ def make_app(global_conf, full_stack=True, **app_conf):
"""
app = make_base_app(global_conf, full_stack=True, **app_conf)
app = DepotManager.make_middleware(app)
try:
app = StaticsMiddleware(app, app_conf['site.custom_assets'])
except KeyError:
pass

# Wrap your base TurboGears 2 application with custom middleware here

Expand Down
2 changes: 2 additions & 0 deletions acmwebsite/controllers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from acmwebsite.controllers.schedule import ScheduleController
from acmwebsite.controllers.survey import SurveysController
from acmwebsite.controllers.project import ProjectsController
from acmwebsite.controllers.wiki import WikiPagesController

from sqlalchemy.sql import functions

Expand Down Expand Up @@ -53,6 +54,7 @@ class RootController(BaseController):
error = ErrorController()
contact = ContactController()
projects = ProjectsController()
wiki = WikiPagesController()

def _before(self, *args, **kw):
tmpl_context.project_name = "acmwebsite"
Expand Down
86 changes: 86 additions & 0 deletions acmwebsite/controllers/wiki.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Wiki controller module"""
import os
import tg
import pygit2 as pg

from tg import expose

from acmwebsite.lib.base import BaseController

from pygit2 import Repository,init_repository
from pygit2 import Tree
from pygit2 import Signature

from docutils.core import publish_parts


__all__ = ['WikiController']

class WikiController(BaseController):
"""Controls the wiki"""

def __init__(self, repo, entry):
self.repo = repo
self.entry = entry

@expose('acmwebsite.templates.wiki_view')
def _default(self):
"""Display a specific page"""
settings = {'initial_header_level': 2,
'file_insertion_enabled': 0,
'raw_enabled': 0,
'disable_config': 1,
}

blob = self.repo.get(self.entry.id)
document = publish_parts(blob.data, writer_name='html5', settings_overrides=settings)
return dict(pagename=self.entry.name.strip('.rst'), parts=document)

@expose('acmwebsite.templates.wiki_history')
def history(self):
revision_list = []
last_id = None

#Get a list of commits that include the queried file
for commit in self.repo.walk(self.repo.head.target, pg.GIT_SORT_TIME):
if filename in commit.tree:
entry = commit.tree[filename]
if entry.id != last_id: #Only add to history if it file chnaged.
revision_list.append({"author": commit.author,
"time": commit.commit_time,
"message": commit.message})
last_id = entry.id

if not revision_list: #No commits include file - possibly faulty?
tg.abort(404, "Page not found")
return dict(page=pagename, revisions=revision_list)

class WikiPagesController(BaseController):
def __new__(cls, repo_path=None):
if not repo_path:
repo_path = tg.config.get('wiki.repo')
if not repo_path:
return None

obj = super().__new__(cls)
obj.repo = Repository(repo_path)
return obj

@expose()
def _lookup(self, pagename=None, *args):
entry = None
if pagename:
tb = self.repo.TreeBuilder(self.repo.head.peel(Tree))
entry = tb.get(pagename + '.rst')
if not entry:
tg.abort(404, "Page not found")
return WikiController(self.repo, entry), args

@expose()
def index(self):
tg.redirect('/wiki/FrontPage')

@expose('acmwebsite.templates.wiki_pagelist')
def pagelist(self):
pages = [entry.name[:-4] for entry in self.repo.head.peel(Tree)]
return dict(pages=pages)
Empty file added acmwebsite/public/css/site.css
Empty file.
2 changes: 1 addition & 1 deletion acmwebsite/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
}

/* Logo */
.acm-logo {
.logo {
margin: 20px 0;
max-width: 400px;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/archives.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - Mailing List Archives</title>
<title>${tg.config.get('site.name')} - Mailing List Archives</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/contact.xhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html py:extends="master.xhtml" py:strip="True">
<head py:block="head" py:strip="True">
<title>Mines ACM - Contact</title>
<title>${tg.config.get('site.name')} - Contact</title>
</head>
<body py:block="body" py:strip="True">
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/error.xhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html py:extends="master.xhtml" py:strip="True">
<head py:block="head" py:strip="True">
<title>Mines ACM - Error</title>
<title>${tg.config.get('site.name')} - Error</title>
</head>
<body py:block="body" py:strip="True">
<h1>Error ${code}</h1>
Expand Down
21 changes: 16 additions & 5 deletions acmwebsite/templates/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

<py:extends href="master.xhtml" />
<head py:block="head" py:strip="True">
<title>Mines ACM</title>
<title>${tg.config.get('site.name')}</title>
</head>
<body py:block="body" py:strip="True">
<div class="row">
<div class="col-md-7">
<div py:if="banner is not None" class="home-banner">
<div py:if="banner is not None" class="col-md-7">
<div class="home-banner">
<img class="home-banner-img" src="${banner.photo.url}" />
<small py:if="banner.description" py:content="h.rst(banner.description)"></small>
</div>
</div>
<div class="col-md-5">
<div class="intro-block">
<h2>Mines ACM Student Chapter</h2>
<h2>${tg.config.get('site.name')}</h2>
<p>
The Mines ACM Student Chapter is the local chapter of the <a href="http://www.acm.org" target="_blank">Association for Computing
Machinery</a> at the <a href="http://www.mines.edu" target="_blank">Colorado School of Mines</a>. As a Mozilla Open Source
Expand All @@ -32,7 +32,7 @@
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Join our ACM Chapter!</h3>
<h3 class="panel-title">Join our ${tg.config.get('site.name')}!</h3>
</div>
<div class="panel-body">
<p>To join our ACM chapter, simply show up to our meetings. Newcomers are welcome to all meetings.</p>
Expand All @@ -57,6 +57,17 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">${tg.config.get('site.name')} Wiki</h3>
</div>
<div class="panel-body">
<p>Did you know our website has a wiki? You can go to the wiki homepage <a href="${tg.url('/wiki')}">here</a>
or by clicking on the "wiki" button on the toolbar.</p>
</div>
</div>
</div>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion acmwebsite/templates/login.xhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html py:extends="master.xhtml" py:strip="True">
<head py:block="head" py:strip="True">
<title>Mines ACM - Login</title>
<title>${tg.config.get('site.name')} - Login</title>
</head>
<body py:block="body" py:strip="True">
<h1>Login with MultiPass</h1>
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/mailinglist.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - Mailing List</title>
<title>${tg.config.get('site.name')} - Mailing List</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
4 changes: 3 additions & 1 deletion acmwebsite/templates/master.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
<link id='bs-css' rel="stylesheet" type="text/css" media="screen" href="${tg.url('/css/bootstrap.dark.min.css') if tg.session.get('theme', None) == 'dark' else tg.url('/css/bootstrap.light.min.css')}" />
<link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/css/style.css')}" />
<link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/css/font-awesome.min.css')}" />
<link rel="stylesheet" type="text/css" media="screen" href="${tg.url('/css/site.css')}" />
</head>

<body>
<!-- Navbar -->
<div class="container">
<div class="header-logo">
<a href="${tg.url('/')}">
<img src="${tg.url('/img/full.svg')}" alt="Mines ACM" class="acm-logo" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful ... Was css class adjusted as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed acm-logo to logo in style.css

<img src="/img/full.svg" alt="${tg.config.get('site.name')}" class="logo" />
</a>
</div>
</div>
Expand All @@ -38,6 +39,7 @@
<li class="${('', 'active')[value_of('page') == 'projects']}"><a href="${tg.url('/projects')}">Projects</a></li>
<li class="${('', 'active')[value_of('page') == 'mailinglist']}"><a href="${tg.url('/mailinglist')}">Mailing List</a></li>
<li class="${('', 'active')[value_of('page') == 'contact']}"><a href="${tg.url('/contact')}">Contact</a></li>
<li class="${('', 'active')[value_of('page') == 'wiki']}"><a href="${tg.url('/wiki')}">Wiki</a></li>
</ul>

<ul py:if="not value_of('luser')" class="nav navbar-nav navbar-right">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/message.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - Post: ${message.subject}</title>
<title>${tg.config.get('site.name')} - Post: ${message.subject}</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/profile.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - ${u}</title>
<title>${tg.config.get('site.name')} - ${u}</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/projects.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - Projects</title>
<title>${tg.config.get('site.name')} - Projects</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/schedule.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>Mines ACM - Schedule</title>
<title>${tg.config.get('site.name')} - Schedule</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/survey.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
py:extends="master.xhtml">

<head py:block="head" py:strip="True">
<title>Mines ACM - Survey</title>
<title>${tg.config.get('site.name')} - Survey</title>
</head>

<div py:def="unknown_type(ty)">
Expand Down
2 changes: 1 addition & 1 deletion acmwebsite/templates/survey_results.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
py:extends="master.xhtml">

<head py:block="head" py:strip="True">
<title>Mines ACM - Survey ${survey_id} Responses</title>
<title>${tg.config.get('site.name')} - Survey ${survey_id} Responses</title>
</head>

<body py:block="body" py:strip="True">
Expand Down
40 changes: 40 additions & 0 deletions acmwebsite/templates/wiki_history.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html py:strip=""
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">

<py:extends href="master.xhtml" />

<head py:block="head" py:strip="True">
<title>${tg.config.get('site.name')} Wiki - $page History</title>
</head>

<body py:block="body" py:strip="True">
<py:def function="revision(item)">
<td>
${item["message"]}
</td>
<td>
${item["author"].name}
</td>
<td>
${item["time"]}
</td>
</py:def>


<h1 class="page-header">History: <a href="${tg.url('/wiki/{}'.format(page))}">$page</a></h1>

<table class="table table-striped">
<thead>
<tr>
<th>Commit Message</th>
<th>Author</th>
<th>Commit time</th>
</tr>
</thead>
<tbody>
<tr py:for="entry in revisions">${revision(entry)}</tr>
</tbody>
</table>
</body>
</html>
Loading