Merge branch 'master' of http://git.gitorious.org/mediagoblin/mediagoblin
This commit is contained in:
commit
88bcdcd7d2
22
destroy_environment.py
Executable file
22
destroy_environment.py
Executable file
@ -0,0 +1,22 @@
|
||||
#!./bin/python
|
||||
|
||||
import pymongo
|
||||
import sys, os
|
||||
|
||||
print "*** WARNING! ***"
|
||||
print " Running this will destroy your mediagoblin database,"
|
||||
print " remove all your media files in user_dev/, etc."
|
||||
|
||||
drop_it = raw_input(
|
||||
'Are you SURE you want to destroy your environment? (if so, type "yes")> ')
|
||||
|
||||
if not drop_it == 'yes':
|
||||
sys.exit(1)
|
||||
|
||||
conn = pymongo.Connection()
|
||||
conn.drop_database('mediagoblin')
|
||||
|
||||
os.popen('rm -rf user_dev/media')
|
||||
os.popen('rm -rf user_dev/beaker')
|
||||
|
||||
print "removed all your stuff! okay, now re-run ./bin/buildout"
|
@ -95,6 +95,34 @@ changed. To do that, run::
|
||||
need to do this when you've made code changes.
|
||||
|
||||
|
||||
Running the server
|
||||
==================
|
||||
|
||||
Run::
|
||||
|
||||
./bin/paster serve mediagoblin.ini --reload
|
||||
|
||||
|
||||
Running celeryd
|
||||
===============
|
||||
|
||||
You need to do this if you want your media to process and actually
|
||||
show up. It's probably a good idea in development to have the web
|
||||
server (above) running in one terminal and celeryd in another window.
|
||||
|
||||
Run::
|
||||
|
||||
CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_celery ./bin/celeryd
|
||||
|
||||
|
||||
Running the test suite
|
||||
======================
|
||||
|
||||
Run::
|
||||
|
||||
./bin/nosetests
|
||||
|
||||
|
||||
Wiping your environment for a clean-slate
|
||||
-----------------------------------------
|
||||
|
||||
@ -117,25 +145,9 @@ Delete the following directories:
|
||||
|
||||
.. YouCanHelp::
|
||||
|
||||
If you're familiar with MongoDB and bash, we'd love to get a bash
|
||||
script that removes all the GNU MediaGoblin data from an existing
|
||||
MongoDB instance. Let us know!
|
||||
|
||||
|
||||
Running the server
|
||||
==================
|
||||
|
||||
Run::
|
||||
|
||||
./bin/paster serve mediagoblin.ini --reload
|
||||
|
||||
|
||||
Running the test suite
|
||||
======================
|
||||
|
||||
Run::
|
||||
|
||||
./bin/nosetests
|
||||
If you're familiar with MongoDB, we'd love to get a `script that
|
||||
removes all the GNU MediaGoblin data from an existing instance
|
||||
<http://bugs.foocorp.net/issues/296>`_. Let us know!
|
||||
|
||||
|
||||
Quickstart for Django programmers
|
||||
|
@ -74,11 +74,16 @@ class MediaEntry(Document):
|
||||
'tags': [unicode],
|
||||
'state': unicode,
|
||||
|
||||
# For now let's assume there can only be one main file queued
|
||||
# at a time
|
||||
'queued_media_file': [unicode],
|
||||
|
||||
# A dictionary of logical names to filepaths
|
||||
'media_files': dict,
|
||||
|
||||
# The following should be lists of lists, in appropriate file
|
||||
# record form
|
||||
'media_files': list,
|
||||
'attachment_files': list,
|
||||
'queue_files': list,
|
||||
|
||||
# This one should just be a single file record
|
||||
'thumbnail_file': [unicode]}
|
||||
|
@ -29,11 +29,11 @@ def process_media_initial(media_id):
|
||||
entry = database.MediaEntry.one(
|
||||
{'_id': mongokit.ObjectId(media_id)})
|
||||
|
||||
queued_filepath = entry['queue_files'].pop()
|
||||
queued_filepath = entry['queued_media_file']
|
||||
queued_file = queue_store.get_file(queued_filepath, 'r')
|
||||
|
||||
with queued_file:
|
||||
thumb = Image(queued_file)
|
||||
thumb = Image.open(queued_file)
|
||||
thumb.thumbnail(THUMB_SIZE, Image.ANTIALIAS)
|
||||
|
||||
thumb_filepath = public_store.get_unique_filepath(
|
||||
@ -44,7 +44,22 @@ def process_media_initial(media_id):
|
||||
with public_store.get_file(thumb_filepath, 'w') as thumb_file:
|
||||
thumb.save(thumb_file, "JPEG")
|
||||
|
||||
queue_store.delete(queued_filepath)
|
||||
entry.setdefault('media_files', []).append(thumb_filepath)
|
||||
entry.state = 'processed'
|
||||
# we have to re-read because unlike PIL, not everything reads
|
||||
# things in string representation :)
|
||||
queued_file = queue_store.get_file(queued_filepath, 'rb')
|
||||
|
||||
with queued_file:
|
||||
main_filepath = public_store.get_unique_filepath(
|
||||
['media_entries',
|
||||
unicode(entry['_id']),
|
||||
queued_filepath[-1]])
|
||||
|
||||
with public_store.get_file(main_filepath, 'wb') as main_file:
|
||||
main_file.write(queued_file.read())
|
||||
|
||||
queue_store.delete_file(queued_filepath)
|
||||
media_files_dict = entry.setdefault('media_files', {})
|
||||
media_files_dict['thumb'] = thumb_filepath
|
||||
media_files_dict['main'] = main_filepath
|
||||
entry['state'] = u'processed'
|
||||
entry.save()
|
||||
|
@ -22,6 +22,7 @@ from werkzeug.utils import secure_filename
|
||||
|
||||
from mediagoblin.decorators import require_active_login
|
||||
from mediagoblin.submit import forms as submit_forms
|
||||
from mediagoblin.process_media import process_media_initial
|
||||
|
||||
|
||||
@require_active_login
|
||||
@ -52,7 +53,6 @@ def submit_start(request):
|
||||
# Now store generate the queueing related filename
|
||||
queue_filepath = request.app.queue_store.get_unique_filepath(
|
||||
['media_entries',
|
||||
unicode(request.user['_id']),
|
||||
unicode(entry['_id']),
|
||||
secure_filename(request.POST['file'].filename)])
|
||||
|
||||
@ -64,9 +64,12 @@ def submit_start(request):
|
||||
queue_file.write(request.POST['file'].file.read())
|
||||
|
||||
# Add queued filename to the entry
|
||||
entry.setdefault('queue_files', []).append(queue_filepath)
|
||||
entry['queued_media_file'] = queue_filepath
|
||||
entry.save(validate=True)
|
||||
|
||||
# queue it for processing
|
||||
process_media_initial.delay(unicode(entry['_id']))
|
||||
|
||||
# redirect
|
||||
return exc.HTTPFound(
|
||||
location=request.urlgen("mediagoblin.submit.success"))
|
||||
|
@ -36,4 +36,18 @@
|
||||
</p>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{# temporarily, an "image gallery" that isn't one really ;) #}
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
{% for entry in media_entries %}
|
||||
<li>
|
||||
<img src="{{ request.app.public_store.file_url(
|
||||
entry['media_files']['thumb']) }}" />
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -22,11 +22,15 @@ import wtforms
|
||||
from mediagoblin import models
|
||||
|
||||
def root_view(request):
|
||||
media_entries = request.db.MediaEntry.find(
|
||||
{u'state': u'processed'})
|
||||
|
||||
template = request.template_env.get_template(
|
||||
'mediagoblin/root.html')
|
||||
return Response(
|
||||
template.render(
|
||||
{'request': request}))
|
||||
{'request': request,
|
||||
'media_entries': media_entries}))
|
||||
|
||||
|
||||
class ImageSubmitForm(wtforms.Form):
|
||||
|
Loading…
x
Reference in New Issue
Block a user