Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bf3e39e

Browse files
committedJan 21, 2015
Version 1.0.0
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent fca08f8 commit bf3e39e

23 files changed

+201
-1048
lines changed
 

‎AUTHORS.rst ‎AUTHORS

File renamed without changes.

‎CHANGELOG.rst

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Appendix B. Changelog
33
=====================
44

5+
v1.0.0
6+
------
7+
8+
* User documentation
9+
* Form validation
10+
* Redis for storing data
11+
* Rebuilding the site, using RQ as a task queue
12+
513
v0.6.0
614
------
715

‎MANIFEST.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
graft comet
2-
include README.rst LICENSE CHANGELOG.rst setup.py setup.cfg setup_virtualenv.sh requirements.txt
2+
graft docs
3+
include README.rst AUTHORS LICENSE CHANGELOG.rst setup.py setup.cfg requirements.txt
34
global-exclude __pycache__ *.pyc

‎README.rst

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,10 @@
22
Comet CMS
33
=========
44

5-
The goal of the ``comet_cms`` project is to make Nikola accessible for non-programmers, casual users, and all other people that don’t feel comfortable using the command line.
5+
Making Nikola accessible for non-programmers, casual users, and all other
6+
people that don’t feel comfortable using the command line.
67

78
Setup
89
-----
910

10-
1. Install Nikola from git.
11-
2. Install Comet from git.
12-
3. Add to your CSS on the Nikola side:
13-
<https://github.com/Voog/wysihtml/blob/master/examples/css/stylesheet.css>
14-
4. Run ``nikola build``
15-
16-
Setup for the test repo (this one): ``./setup_virtualenv.sh``
17-
18-
Usage
19-
-----
20-
21-
Run with ``comet``.
22-
23-
Default credentials: admin / admin.
11+
Setting up Comet CMS is described in `the documentation <http://comet-cms.readthedocs.org/en/latest/admin/setup/>`_.

‎SITE/conf.py

-840
This file was deleted.

‎SITE/files/assets/css/custom.css

-133
This file was deleted.

‎comet/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any
@@ -29,4 +29,4 @@
2929

3030
__all__ = ['__version__']
3131

32-
__version__ = '0.6.0'
32+
__version__ = '1.0.0'

‎comet/__main__.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any
@@ -30,7 +30,6 @@
3030
3131
Usage:
3232
comet devserver [-b | --browser] [-p <port> | --port=<port>]
33-
comet init [directory]
3433
comet write_users
3534
comet -h | --help
3635
comet --version
@@ -42,6 +41,8 @@
4241
-p <port>, --port=<port> Port to use [default: 8001].
4342
"""
4443

44+
from __future__ import unicode_literals
45+
4546
import comet
4647
import comet.utils
4748
import sys
@@ -52,32 +53,30 @@
5253

5354

5455
def main():
55-
u"""The main function."""
56-
arguments = docopt.docopt(__doc__, version=u'Comet CMS v{0}'.format(
56+
"""The main function."""
57+
arguments = docopt.docopt(__doc__, version='Comet CMS v{0}'.format(
5758
comet.__version__))
58-
if arguments[u'init']:
59-
sys.exit(init(arguments))
60-
elif arguments[u'write_users']:
59+
if arguments['write_users']:
6160
sys.exit(write_users(arguments))
62-
elif arguments[u'devserver']:
61+
elif arguments['devserver']:
6362
sys.exit(devserver(arguments))
6463

6564

6665
def init(arguments):
67-
u"""Run comet init."""
66+
"""Run comet init."""
6867
import comet.init
6968
return comet.init.init()
7069

7170

7271
def write_users(arguments):
73-
u"""Write users to the DB."""
72+
"""Write users to the DB."""
7473
import comet.init
7574
u = comet.utils.ask("Redis URL", "redis://localhost:6379/0")
7675
return comet.init.write_users(u)
7776

7877

7978
def devserver(arguments):
80-
u"""Run a development server."""
79+
"""Run a development server."""
8180
import comet.web
8281
if comet.web.app:
8382
port = int(arguments['--port'])
@@ -88,7 +87,7 @@ def devserver(arguments):
8887
if arguments['--browser']:
8988
webbrowser.open(url)
9089

91-
comet.web.app.logger.info(u"Comet CMS running @ {0}".format(url))
90+
comet.web.app.logger.info("Comet CMS running @ {0}".format(url))
9291
comet.web.app.run('localhost', port, debug=True)
9392
return 0
9493
else:

‎comet/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any

‎comet/init.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any
@@ -34,7 +34,8 @@
3434

3535
def init():
3636
"""Initialize a site."""
37-
print("ERROR: Not implemented.")
37+
print("Please read the documentation and set up manually.")
38+
print("http://comet-cms.readthedocs.org/en/latest/admin/setup/")
3839
return 255
3940

4041

‎comet/tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any

‎comet/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any

‎comet/web.py

+34-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Comet CMS v0.6.0
3+
# Comet CMS v1.0.0
44
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
55

66
# Permission is hereby granted, free of charge, to any
@@ -118,7 +118,8 @@ def configure_site():
118118

119119
app.secret_key = _site.config.get('COMET_SECRET_KEY')
120120
app.config['COMET_URL'] = _site.config.get('COMET_URL')
121-
app.config['REDIS_URL'] = _site.config.get('COMET_REDIS_URL', 'redis://localhost:6379/0')
121+
app.config['REDIS_URL'] = _site.config.get('COMET_REDIS_URL',
122+
'redis://localhost:6379/0')
122123
db = redis.StrictRedis.from_url(app.config['REDIS_URL'])
123124
q = rq.Queue(connection=db)
124125

@@ -130,6 +131,8 @@ def configure_site():
130131
'en': (
131132
(app.config['NIKOLA_URL'],
132133
'<i class="fa fa-globe"></i> Back to website'),
134+
('http://comet-cms.readthedocs.org/en/latest/user/',
135+
'<i class="fa fa-question-circle"></i> Comet CMS Help'),
133136
)
134137
}
135138
_site.GLOBAL_CONTEXT['navigation_links'] = _site.config['NAVIGATION_LINKS']
@@ -206,9 +209,11 @@ def generate_menu():
206209
:rtype: str
207210
"""
208211
if db.get('site:needs_rebuild') not in ('0', '-1'):
209-
return """<li><li><a href="/rebuild"><i class="fa fa-fw fa-warning"></i> <strong>Rebuild</strong></a></li>"""
212+
return ('</li><li><a href="/rebuild"><i class="fa fa-fw '
213+
'fa-warning"></i> <strong>Rebuild</strong></a></li>')
210214
else:
211-
return """<li><li><a href="/rebuild"><i class="fa fa-fw fa-cog"></i> Rebuild</a></li>"""
215+
return ('</li><li><a href="/rebuild"><i class="fa fa-fw '
216+
'fa-cog"></i> Rebuild</a></li>')
212217

213218

214219
def generate_menu_alt():
@@ -461,7 +466,7 @@ def login():
461466
code = 401
462467
else:
463468
if check_password(user.password,
464-
request.form['password']) and user.is_active:
469+
request.form['password']) and user.is_active:
465470
login_user(user, remember=('remember' in request.form))
466471
return redirect('/')
467472
else:
@@ -496,10 +501,6 @@ def index():
496501
497502
:param int all: Whether or not should show all posts
498503
"""
499-
if not os.path.exists(os.path.join(_site.config["OUTPUT_FOLDER"],
500-
'assets')):
501-
return redirect('/setup')
502-
503504
context = {'postform': NewPostForm(),
504505
'pageform': NewPageForm(),
505506
'delform': DeleteForm()}
@@ -539,15 +540,6 @@ def index():
539540
return render('comet_index.tmpl', context)
540541

541542

542-
# TODO: delete (with redirects) as soon as `comet init` exists
543-
@app.route('/setup')
544-
def setup():
545-
"""TEMPORARY setup function."""
546-
ns = not os.path.exists(os.path.join(_site.config["OUTPUT_FOLDER"],
547-
'assets'))
548-
return render("comet_setup.tmpl", context={'needs_setup': ns})
549-
550-
551543
@app.route('/edit/<path:path>', methods=['GET', 'POST'])
552544
@login_required
553545
def edit(path):
@@ -563,6 +555,13 @@ def edit(path):
563555
if post is None:
564556
return error("No such post or page.", 404, '/edit/' + path)
565557

558+
current_auid = int(post.meta('author.uid') or current_user.uid)
559+
560+
if (not current_user.can_edit_all_posts
561+
and current_auid != current_user.uid):
562+
return error("Cannot edit posts of other users.", 401,
563+
'/edit/' + path)
564+
566565
if request.method == 'POST':
567566
meta = {}
568567
for k, v in request.form.items():
@@ -576,7 +575,7 @@ def edit(path):
576575
if (not current_user.can_transfer_post_authorship
577576
or not author_change_success):
578577
meta['author'] = post.meta('author') or current_user.realname
579-
meta['author.uid'] = post.meta('author.uid') or current_user.uid
578+
meta['author.uid'] = str(current_auid)
580579

581580
twofile = post.is_two_file
582581
onefile = not twofile
@@ -611,7 +610,7 @@ def edit(path):
611610
if active == '1':
612611
users.append((u, realname))
613612
context['users'] = sorted(users)
614-
context['current_auid'] = int(post.meta('author.uid') or current_user.uid)
613+
context['current_auid'] = current_auid
615614
context['title'] = 'Editing {0}'.format(post.title())
616615
context['permalink'] = '/edit/' + path
617616
context['is_html'] = post.compiler.name == 'html'
@@ -629,6 +628,13 @@ def delete():
629628
return error("No such post or page.", 404, '/delete')
630629
if not form.validate():
631630
return error("Bad Request", 400, '/delete')
631+
632+
current_auid = int(post.meta('author.uid') or current_user.uid)
633+
634+
if (not current_user.can_edit_all_posts
635+
and current_auid != current_user.uid):
636+
return error("Cannot edit posts of other users.", 401, '/delete')
637+
632638
os.unlink(path)
633639
if post.is_two_file:
634640
meta_path = os.path.splitext(path)[0] + '.meta'
@@ -673,6 +679,10 @@ def api_rebuild():
673679
def rebuild():
674680
"""Rebuild the site with a nice UI."""
675681
scan_site() # for good measure
682+
if not current_user.can_rebuild_site:
683+
return error('You are not permitted to rebuild the site.</p>'
684+
'<p class="lead">Contact an administartor for '
685+
'more information.', 401, '/rebuild')
676686
db.set('site:needs_rebuild', '-1')
677687
if not q.fetch_job('build') and not q.fetch_job('orphans'):
678688
b = q.enqueue_call(func=comet.tasks.build,
@@ -746,14 +756,16 @@ def new(obj):
746756
if obj == 'post':
747757
f = NewPostForm()
748758
if f.validate():
749-
_site.commands.new_post(title=title, author=current_user.realname,
759+
_site.commands.new_post(title=title,
760+
author=current_user.realname,
750761
content_format='html')
751762
else:
752763
return error("Bad Request", 400, '/new/' + obj)
753764
elif obj == 'page':
754765
f = NewPageForm()
755766
if f.validate():
756-
_site.commands.new_page(title=title, author=current_user.realname,
767+
_site.commands.new_page(title=title,
768+
author=current_user.realname,
757769
content_format='html')
758770
else:
759771
return error("Bad Request", 400, '/new/' + obj)

‎docs/admin/setup.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ As such, you must configure Nikola first before you start Comet.
1818
Virtualenv
1919
==========
2020

21-
Create a virtualenv in ``/var/comet`` and instal Comet in it.
21+
Create a virtualenv in ``/var/comet`` and install Comet in it.
2222

2323
.. code-block:: console
2424

‎docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '0.6.0'
58+
version = '1.0.0'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '0.6.0'
60+
release = '1.0.0'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.
@@ -245,7 +245,7 @@
245245
# dir menu entry, description, category)
246246
texinfo_documents = [
247247
('index', 'CometCMS', 'Comet CMS Documentation',
248-
'Chris Warrick and the Comet contributors', 'CometCMS', 'One line description of project.',
248+
'Chris Warrick and the Comet contributors', 'CometCMS', 'A CMS for Nikola.',
249249
'Miscellaneous'),
250250
]
251251

‎docs/user/00-getting-started.rst

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Getting Started
2+
===============
3+
4+
When you access the Comet CMS instance, you first need to log in by using your
5+
username and password, which were provided by the administrator. The first
6+
thing you should do is visiting the :doc:`Account <50-account>` page and change
7+
your password to secure your account.
8+
9+
When you are done securing your account, you can start working.
10+
11+
On the :doc:`Index <10-index>` page, there are two sections: Posts and Pages.
12+
You can create new posts or edit existing ones. Depending on the permissions
13+
you were given by the administrator, you may or may not be able to edit posts
14+
created by other users — this may cause an empty list to be displayed. If you
15+
can see posts by others, but would like to hide them, use the buttons on the
16+
top of the page to switch between display modes.
17+
18+
Each post displays :doc:`Edit <20-edit>` and :doc:`Delete <30-delete>` buttons,
19+
which can be used to alter contents.
20+
21+
After performing changes, you need to :doc:`Rebuild <40-rebuild>` the page in
22+
order to make them visible to the world. Sometimes, you may not be able to
23+
perform a rebuild yourself and may need the assistance of someone else. Please
24+
check with your organization for more information.

‎docs/user/10-index.rst

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Index Page
2+
==========
3+
4+
On the top of the index page, you can switch between displaying only your own
5+
posts and displaying posts of all authors.
6+
7+
.. note:: Permissions
8+
9+
In order to view posts of other authors, you must have the “can edit others’
10+
posts” permission.
11+
12+
In addition, you can set the default view in the :doc:`Account <50-account>`
13+
section.
14+
15+
Below, Posts and Pages are displayed in separate columns. On the top of
16+
each column, you can create posts by typing their title in the field.
17+
18+
.. warning::
19+
20+
The post URL will be set based on the post title. It cannot be changed
21+
later!
22+
23+
All the posts are displayed under the creation field. You can :doc:`edit <20-edit>` or :doc:`delete <30-delete>`
24+
them.

‎docs/user/20-edit.rst

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Editing posts
2+
=============
3+
4+
.. note:: Permissions
5+
6+
You need the “can edit others’ posts” permission to edit posts of other
7+
users. You can always edit your own posts.
8+
9+
The *Edit* view lets you make modifications to posts.
10+
11+
The topmost field is the title of the post. You can always change it.
12+
Remember that the post URL will **not** change, as it is set in stone during post
13+
creation.
14+
15+
The next line features four fields: date, author, tags and category.
16+
17+
.. note:: Permissions
18+
19+
Post author may be changed only if you have the “transfer post authorship”
20+
permission.
21+
22+
Tags are comma-separated. A post can have only **one** category. Many date
23+
formats are accepted. The default format used is ``yyyy-mm-dd hh:mm:ss UTC±hh:mm``,
24+
(the last element being the timezone) but if you fill in your own format, it
25+
will usually work.
26+
27+
The next line is the editor toolbar (which also features the Save button). Underneath
28+
it, the post content is displayed in a box. You can edit it in any way you
29+
like. The editor handles formatting for you, but you can click the ``</>`` button
30+
to edit the HTML source.

‎docs/user/30-delete.rst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Deleting posts
2+
==============
3+
4+
.. note:: Permissions
5+
6+
You need the “can edit others’ posts” permission to delete posts of other
7+
users. You can always delete your own posts.
8+
9+
Clicking on the red *Delete* button under a post will delete the post after
10+
confirming with the user.
11+
12+
.. warning::
13+
14+
Deleting a post is **permanent**.

‎docs/user/40-rebuild.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Rebuilding the site
2+
===================
3+
4+
To have the changes show up on the page, you must rebuild the site.
5+
6+
When the site is in need of rebuilding, the menu bar displays an exclamation
7+
mark next to the Rebuild option, the word **Rebuild** also appears in bold.
8+
9+
Clicking on the Rebuild button will initiate a rebuild. The progress will be
10+
displayed.
11+
12+
If an error occurs, you will see the output. The error will be displayed
13+
in the Advanced information box. If you cannot understand and solve the
14+
problem yourself, contact your administrator.
15+
16+
.. note:: Permissions
17+
18+
In order to rebuild the site, you need the “can rebuild site” permission.
19+

‎docs/user/50-account.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Account
2+
=======
3+
4+
You can edit your account in the Account tab. You can change your real name,
5+
e-mail and password. You can also set the preferences.
6+
7+
.. note::
8+
9+
The real name is not changed on the posts already created.
10+
11+
.. note::
12+
13+
If you want to change your username, or reset your password, you must
14+
contact an administrator.
15+
16+
.. note:: Permissions
17+
18+
In order to enable the “Show me posts by other users by default” preference, you must
19+
first have the “can edit others’ posts” permission.

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
setup(name='comet-cms',
7-
version='0.6.0',
7+
version='1.0.0',
88
description='Getting rid of the dinosaurs (WordPress and friends).',
99
keywords='comet',
1010
author='Chris Warrick, Roberto Alsina, Henry Hirsch et al.',

‎setup_virtualenv.sh

-13
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.