Skip to content

Commit

Permalink
Merge branch 'ctxt_proc'
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Oordt committed Apr 6, 2010
2 parents f178ac9 + af78110 commit 94a6d50
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/_sources/getting_started.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Then in ``urls.py``\ : ::

urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(os.path.basedir(__file__), 'media2')}),
{'document_root': os.path.join(os.path.dirname(__file__), 'media2')}),
)


Expand Down
12 changes: 11 additions & 1 deletion docs/_sources/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ For example, to combine three CSS files into one ``combo.css`` file::
.. note::
File combinations are done before anything else, so make the destination path for combination files be in a directory configured in a ``from`` key in :ref:`STATIC_MEDIA_COPY_PATHS`.

The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.
The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.

.. _static_url:

STATIC_URL
==========

In order to segregate user uploaded content from the site content, you can use the ``STATIC_URL`` and the static url ``staticmediamgr.context_processor.static_url`` to keep things separate.

The default is ``STATIC_URL = MEDIA_URL``

2 changes: 1 addition & 1 deletion docs/getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h2>Local Development vs. Production<a class="headerlink" href="#local-developme
<p>Then in <tt class="docutils literal"><span class="pre">urls.py</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">urlpatterns</span> <span class="o">+=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
<span class="p">(</span><span class="s">r&#39;^media/(?P&lt;path&gt;.*)$&#39;</span><span class="p">,</span> <span class="s">&#39;django.views.static.serve&#39;</span><span class="p">,</span>
<span class="p">{</span><span class="s">&#39;document_root&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basedir</span><span class="p">(</span><span class="n">__file__</span><span class="p">),</span> <span class="s">&#39;media2&#39;</span><span class="p">)}),</span>
<span class="p">{</span><span class="s">&#39;document_root&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">__file__</span><span class="p">),</span> <span class="s">&#39;media2&#39;</span><span class="p">)}),</span>
<span class="p">)</span>
</pre></div>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h1>Welcome to Static Media Manager&#8217;s documentation!<a class="headerlink"
<li class="toctree-l2"><a class="reference external" href="settings.html#static-media-js-compression-cmd">STATIC_MEDIA_JS_COMPRESSION_CMD</a></li>
<li class="toctree-l2"><a class="reference external" href="settings.html#static-media-app-media-path">STATIC_MEDIA_APP_MEDIA_PATH</a></li>
<li class="toctree-l2"><a class="reference external" href="settings.html#static-media-file-combinations">STATIC_MEDIA_FILE_COMBINATIONS</a></li>
<li class="toctree-l2"><a class="reference external" href="settings.html#static-url">STATIC_URL</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference external" href="css_compression.html">CSS Compression</a><ul>
Expand Down
4 changes: 2 additions & 2 deletions docs/objects.inv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Version: 0.4
staticmediamgr.utils mod reference/utils.html
staticmediamgr.utils.copy_app_media function reference/utils.html
staticmediamgr.utils.copy function reference/utils.html
staticmediamgr.utils.copydir function reference/utils.html
staticmediamgr.utils.compress_copy function reference/utils.html
staticmediamgr.utils.combine_files function reference/utils.html
staticmediamgr.utils.copydir function reference/utils.html
staticmediamgr.utils.copy function reference/utils.html
2 changes: 1 addition & 1 deletion docs/reference/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ <h1>Utilities Reference<a class="headerlink" href="#module-staticmediamgr.utils"

<dl class="function">
<dt id="staticmediamgr.utils.copy_app_media">
<tt class="descclassname">staticmediamgr.utils.</tt><tt class="descname">copy_app_media</tt><big>(</big><em>destination='/Users/coordt/Projects/django-staticmediamgr/media2'</em><big>)</big><a class="headerlink" href="#staticmediamgr.utils.copy_app_media" title="Permalink to this definition"></a></dt>
<tt class="descclassname">staticmediamgr.utils.</tt><tt class="descname">copy_app_media</tt><big>(</big><em>destination='/Users/coordt/.virtualenvs/bombay_test/src/staticmedia/media2'</em><big>)</big><a class="headerlink" href="#staticmediamgr.utils.copy_app_media" title="Permalink to this definition"></a></dt>
<dd>Copy each application&#8217;s media files to the path specified in
<tt class="docutils literal"><span class="pre">STATIC_MEDIA_APP_MEDIA_PATH</span></tt>. Won&#8217;t do any of the django.contrib
applications.</dd></dl>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<li class="toctree-l2"><a class="reference external" href="#static-media-js-compression-cmd">STATIC_MEDIA_JS_COMPRESSION_CMD</a></li>
<li class="toctree-l2"><a class="reference external" href="#static-media-app-media-path">STATIC_MEDIA_APP_MEDIA_PATH</a></li>
<li class="toctree-l2"><a class="reference external" href="#static-media-file-combinations">STATIC_MEDIA_FILE_COMBINATIONS</a></li>
<li class="toctree-l2"><a class="reference external" href="#static-url">STATIC_URL</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference external" href="css_compression.html">CSS Compression</a></li>
Expand Down Expand Up @@ -154,6 +155,11 @@ <h3>This Page</h3>
</div>
<p>The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.</p>
</div>
<div class="section" id="static-url">
<span id="id9"></span><h2>STATIC_URL<a class="headerlink" href="#static-url" title="Permalink to this headline"></a></h2>
<p>In order to segregate user uploaded content from the site content, you can use the <tt class="docutils literal"><span class="pre">STATIC_URL</span></tt> and the static url <tt class="docutils literal"><span class="pre">staticmediamgr.context_processor.static_url</span></tt> to keep things separate.</p>
<p>The default is <tt class="docutils literal"><span class="pre">STATIC_URL</span> <span class="pre">=</span> <span class="pre">MEDIA_URL</span></tt></p>
</div>
</div>


Expand Down
12 changes: 11 additions & 1 deletion docs_src/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ For example, to combine three CSS files into one ``combo.css`` file::
.. note::
File combinations are done before anything else, so make the destination path for combination files be in a directory configured in a ``from`` key in :ref:`STATIC_MEDIA_COPY_PATHS`.

The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.
The original files are not touched and the destination file can safely reside with them. The default setting is an empty dictionary.

.. _static_url:

STATIC_URL
==========

In order to segregate user uploaded content from the site content, you can use the ``STATIC_URL`` and the static url ``staticmediamgr.context_processor.static_url`` to keep things separate.

The default is ``STATIC_URL = MEDIA_URL``

4 changes: 4 additions & 0 deletions staticmediamgr/context_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from settings import STATIC_URL

def static_url(request):
return {'STATIC_URL': STATIC_URL}
9 changes: 8 additions & 1 deletion staticmediamgr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@
#: MEDIA_ROOT+'/css/coolui.css'],
#: }
#: **Default:** ``{}``
FILE_COMBINATIONS = getattr(settings, 'STATIC_MEDIA_FILE_COMBINATIONS', {})
FILE_COMBINATIONS = getattr(settings, 'STATIC_MEDIA_FILE_COMBINATIONS', {})

#: In order to segregate user uploaded content from the site content, you can
#: use the ``STATIC_URL`` and the static url ``staticmediamgr.context_processor.static_url``
#: to keep things separate.
#:
#: **Default:** STATIC_URL = MEDIA_URL
STATIC_URL = getattr(settings, 'STATIC_URL', settings.MEDIA_URL)
1 change: 1 addition & 0 deletions staticmediamgr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def copy_app_media(destination=settings.APP_MEDIA_PATH):
mod = importlib.import_module(app)
app_media_path = os.path.join(os.path.abspath(mod.__path__[0]), 'media')
if os.path.exists(app_media_path) and os.path.isdir(app_media_path) and not os.path.exists(os.path.join(app_media_path, '__init__.py')):
print "Copying %s's media to %s" % (app, destination)
copy(app_media_path, destination, purge=False, replace_files=False)


Expand Down

0 comments on commit 94a6d50

Please sign in to comment.