Osiloke Emoekpere avatar Osiloke Emoekpere committed e2788c9 Merge

merge with enhancements

Comments (0)

Files changed (41)

 syntax: glob
 uploads
+_build*
 *.pyc
 .idea
 *.db
 d657494eefc28b5112738e332b2f2b365d0f551a 0.1.0dev
+753e208ff7791a4752aca63d1711dd61d62ba577 v1.5
 OVERVIEW
 ========= 
-:Author: Osi Emoekpere (http://osiloke.blogspot.com, http://twitter.com/osilocks)
+:Author: Osi Emoekpere (http://osiloke.com, http://twitter.com/osilocks)
 
 :info: This app extends mezzanine applications by provides an interface for adding dynamic custom content like a twitter mentions widget or slideshow to mezzanine pages.
 
 * Easy and full frontend modification of widgets i.e Adding, Editing and Deleting widgets
 * Configuration options for each widget
 * Multisite support
+* Sortable Widgets
+* Mutual exclusivity from django app loader
 * Bootstrap theme integration
 
 Requirements
 ============
-mezzanine 1.x.x (I'm not sure if 1.0 is backwards compatible)
+
+Python
+~~~~~~
+mezzanine 1.x.x
 django-classy-tags
 
+Javascript 
+~~~~~~~~~~
+Bootstrap Tooltip
+Jquery Django Admin Form
+underscore
+jQuery UI
+
+Please use widget/widget_loader.html as a reference to add the neccessary js if you do not want to use the {% widget_loader %} tag.
+
 METHODOLOGY
 ===========
 Widgets are placed in the specified slot. Slots are just placeholders inside django templates where widgets are rendered.
 
 python manage.py createdb --noinput
 
-The gallery page has a couple of widgets, so take a look at that first.
+This will create a demo mezzanine applciation, To test out mezzanine widgets go to any mezzanine page (about, gallery etc) and click the `add widget` button to add a new widget. 
+
+Run tests from the example folder with::
+
+python manage.py test widget --settings=test_settings
 
 TODO
 ====
 * Better presentation of widget list in frontend.
-* Sorting and swapping widgets
-* More render options
+* More render options, like provide template for widget list wrap
+* Bootstrap theme integration
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MezzanineWidgets.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MezzanineWidgets.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/MezzanineWidgets"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MezzanineWidgets"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+# -*- coding: utf-8 -*-
+#
+# Mezzanine Widgets documentation build configuration file, created by
+# sphinx-quickstart on Mon Nov  5 03:24:19 2012.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Mezzanine Widgets'
+copyright = u'2012, Osiloke Emoekpere'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.5.0'
+# The full version, including alpha/beta/rc tags.
+release = '0.5.0alpha'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'MezzanineWidgetsdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'MezzanineWidgets.tex', u'Mezzanine Widgets Documentation',
+   u'Osiloke Emoekpere', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'mezzaninewidgets', u'Mezzanine Widgets Documentation',
+     [u'Osiloke Emoekpere'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'MezzanineWidgets', u'Mezzanine Widgets Documentation',
+   u'Osiloke Emoekpere', 'MezzanineWidgets', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'

docs/frontend.rst

+****************************************************
+Frontend Widget Management
+****************************************************
+
+===================
+Widget Option Forms
+===================
+Mezzanine widgets allows you to provide extra options which can be used to provide further configuration for your widget.
+These options can be modified from the frontend django app by clicking the edit link in the admin toolbar.
+
+==============
+Widget Toolbar
+==============
+Mezzanine widgets was created to be easily managed from the frontend of a basic mezzanine site. The frontend interface allows various functions to be performed on a widget such as adding, editing, deleting or ordering a widget. These functions are available in the widget toolbar.
+
+Adding a widget
+~~~~~~~~~~~~~~~
+
+Editing a widget
+~~~~~~~~~~~~~~~
+
+Ordering a widget
+~~~~~~~~~~~~~~~~~
+.. Mezzanine Widgets documentation master file, created by
+   sphinx-quickstart on Mon Nov  5 03:24:19 2012.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to Mezzanine Widgets's documentation!
+=============================================
+
+Table of contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   overview.rst
+   page-widgets.rst
+   frontend.rst
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\MezzanineWidgets.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\MezzanineWidgets.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end

docs/overview.rst

+****************************************************
+Overview
+****************************************************
+This app extends mezzanine applications by provides an interface for adding dynamic custom content like a twitter mentions widget or slideshow to mezzanine pages.
+
+Features
+--------
+* Easy and full frontend modification of widgets i.e Adding, Editing and Deleting widgets
+* Configuration options for each widget
+* Multisite support
+* Bootstrap theme integration
+
+Requirements
+------------
+mezzanine 1.x
+django-classy-tags
+
+Methodology
+===========
+Widgets are placed in the specified slot. Slots are just placeholders inside django templates where widgets are rendered.
+They are not stored in the database. As a result, a template designer does not worry about syncing the database
+every time he wants to create a `slot` in a template. On the other hand, the end user must be aware of the `slots` available for
+widgets.
+
+Widget Classes contain the logic used to render each widget and are dynamically loaded at runtime using the same autoloading magic
+used for django admin.
+
+Setup
+=====
+Add the widget app to your installed apps after all mezzanine apps in your ``settings.py``::
+
+   INSTALLED_APPS = (
+       ...
+       'widget',
+       ...
+   )
+
+Usage
+=====
+
+Page Widgets
+------------
+The widget app searches all apps in loaded in django for a file named `page_widgets.py`. This file contains code which describe
+how a widget should be rendered. An example widget which displays the addthis links is shown below::
+
+    class SocialLogosWidget(WidgetClassBase):
+        template = "widgets/social.html"
+
+        def render(self, context, slot, queryset, **kwargs):
+            return context
+
+        class Meta:
+            name = _("Social Logos")
+            author = 'Progweb Team'
+
+This widget just renders the social.html template which contains the addthis links.
+
+Widgets can also have options. A widget which shows mentions of a twitter user is shown below::
+
+    class TwitterMentionsWidgets(WidgetClassBase):
+        "Displays recent messages for a twitter account, Uses"
+        template = "widgets/twitter_mentions.html"
+
+        options = [
+            opt(name="Tag", required=True, help_text="#Tag to list"),
+            opt(name="Limit", default=3, help_text="Number of tweets to show"),
+        ]
+
+        def render(self, context, **kwargs):
+            return context
+
+        class Meta:
+            name = "Twitter Mentions"
+            author = 'Progweb Team'
+
+
+Widgets are not used in the application until they are registered::
+
+    widget_pool.register_widget(SocialLogosWidget)
+    widget_pool.register_widget(TwitterMentionsWidgets)
+
+The template variable can either be the path to a template file or a string with the template definition
+
+
+Rendering
+---------
+Render widgets on a page by first including the widget tag library::
+
+	{% load widget_tags %}
+
+You will need to load the javascript code which is used to manipulate widgets. The following should go in your base template::
+
+    {% widget_loader %}
+
+.. note:: This should come after all other javascript declarations. Please make sure you have jquery declared.
+
+The following snippet will render widgets which are assigned to the footer slot.::
+
+	{% render_widgets "footer" %}
+
+
+Adding Widgets
+--------------
+It is really easy to add widgets from the frontend site. Just look for the `Add Widget` link and click it. You will get a
+list of widgets to choose from. If the widget has options, you will be able to enter them. Try adding the twitter mentions widget.
+
+.. note:: Widgets can only be modified on mezzanine pages (for now).
+
+Example Project
+===============
+Install the widgets app by running::
+
+python setup.py install #From the `widget` folder
+
+Change directory to the example app and run::
+
+python manage.py createdb --noinput
+
+The gallery page has a couple of widgets, so take a look at that first.
+
+TODO
+====
+* Better presentation of widget list in frontend.
+* Sorting and swapping widgets
+* More render options

docs/page-widgets.rst

+****************************************************
+Creating Page Widgets
+****************************************************
+
+=============
+Basic Widgets
+=============
+
+================
+Advanced Widgets
+================

example/requirements/project.txt

-Mezzanine==0.12
+mezzanine-widgets

example/settings.py

 # MEZZANINE SETTINGS #
 ######################
 
-# The following settings are already defined in mezzanine.conf.defaults
-# with default values, but are common enough to be put here, commented
-# out, for convenient overriding.
+# The following settings are already defined with default values in
+# the ``defaults.py`` module within each of Mezzanine's apps, but are
+# common enough to be put here, commented out, for convenient
+# overriding. Please consult the settings documentation for a full list
+# of settings Mezzanine implements:
+# http://mezzanine.jupo.org/docs/configuration.html#default-settings
 
 # Controls the ordering and grouping of the admin menu.
 #
-# from django.utils.translation import ugettext as _
 # ADMIN_MENU_ORDER = (
-#     (_("Content"), ("pages.Page", "blog.BlogPost",
-#        "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
-#     (_("Site"), ("sites.Site", "redirects.Redirect", "conf.Setting")),
-#     (_("Users"), ("auth.User", "auth.Group",)),
+#     ("Content", ("pages.Page", "blog.BlogPost",
+#        "generic.ThreadedComment", ("Media Library", "fb_browse"),)),
+#     ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
+#     ("Users", ("auth.User", "auth.Group",)),
 # )
 
 # A three item sequence, each containing a sequence of template tags
 #     ("mezzanine_tags.recent_actions",),
 # )
 
+# A sequence of templates used by the ``page_menu`` template tag. Each
+# item in the sequence is a three item sequence, containing a unique ID
+# for the template, a label for the template, and the template path.
+# These templates are then available for selection when editing which
+# menus a page should appear in. Note that if a menu template is used
+# that doesn't appear in this setting, all pages will appear in it.
+
+# PAGE_MENU_TEMPLATES = (
+#     (1, "Top navigation bar", "pages/menus/dropdown.html"),
+#     (2, "Left-hand tree", "pages/menus/tree.html"),
+#     (3, "Footer", "pages/menus/footer.html"),
+# )
+
 # A sequence of fields that will be injected into Mezzanine's (or any
 # library's) models. Each item in the sequence is a four item sequence.
 # The first two items are the dotted path to the model and its field
 # field instance. When specifying the field class, the path
 # ``django.models.db.`` can be omitted for regular Django model fields.
 #
-# from django.utils.translation import ugettext as _
 # EXTRA_MODEL_FIELDS = (
 #     (
 #         # Dotted path to field.
 #         # Dotted path to field class.
 #         "somelib.fields.ImageField",
 #         # Positional args for field class.
-#         (_("Image"),),
+#         ("Image",),
 #         # Keyword args for field class.
-#         {"blank": True, "upload_to: "blog"},
+#         {"blank": True, "upload_to": "blog"},
 #     ),
 #     # Example of adding a field to *all* of Mezzanine's content types:
 #     (
 #         "mezzanine.pages.models.Page.another_field",
 #         "IntegerField", # 'django.db.models.' is implied if path is omitted.
-#         (_("Another name"),),
+#         ("Another name",),
 #         {"blank": True, "default": 1},
 #     ),
 # )
 #
 # BLOG_USE_FEATURED_IMAGE = True
 
-# Turns on accounts for website visitors. Will add the
-# LOGIN_URL/LOGOUT_URL values to urlpatterns, and show login/logout
-# links in templates/includes/user_panel.html. Defaults to False.
-#
-# ACCOUNTS_ENABLED = True
-
-# If ``True``, users will be automatically redirected to HTTPS
-# for the URLs specified by the ``SSL_FORCE_URL_PREFIXES`` setting.
-#
-# SSL_ENABLED = True
-
-# Host name that the site should always be accessed via that matches
-# the SSL certificate.
-#
-# SSL_FORCE_HOST = "www.example.com"
-
-# Sequence of URL prefixes that will be forced to run over
-# SSL when ``SSL_ENABLED`` is ``True``. i.e.
-# ('/admin', '/example') would force all URLs beginning with
-# /admin or /example to run over SSL. Defaults to:
-#
-# SSL_FORCE_URL_PREFIXES = ("/admin", "/account")
-
 # If True, the south application will be automatically added to the
-# INSTALLED_APPS setting. This setting is not defined in
-# mezzanine.conf.defaults as is the case with the above settings.
+# INSTALLED_APPS setting.
 USE_SOUTH = True
 
 
 # timezone as the operating system.
 # If running in a Windows environment this must be set to the same as your
 # system time zone.
-TIME_ZONE = ""
+TIME_ZONE = None
+
+# If you set this to True, Django will use timezone-aware datetimes.
+USE_TZ = True
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
     "django.template.loaders.app_directories.Loader",
 )
 
-# URLs used for login/logout when ACCOUNTS_ENABLED is set to True.
-LOGIN_URL = "/account/"
-LOGOUT_URL = "/account/logout/"
+AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+    "django.contrib.staticfiles.finders.FileSystemFinder",
+    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
+#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
 
 
 #############
 
 DATABASES = {
     "default": {
-        # "postgresql_psycopg2", "postgresql", "mysql", "sqlite3" or "oracle".
-        "ENGINE": "",
+        # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
+        "ENGINE": "django.db.backends.",
         # DB name or path to database file if using sqlite3.
         "NAME": "",
         # Not used with sqlite3.
         "PASSWORD": "",
         # Set to empty string for localhost. Not used with sqlite3.
         "HOST": "",
-         # Set to empty string for default. Not used with sqlite3.
+        # Set to empty string for default. Not used with sqlite3.
         "PORT": "",
     }
 }
     "mezzanine.twitter",
     "widget",
     "widgets",
+    #"mezzanine.accounts",
     #"mezzanine.mobile",
 )
 
     "django.core.context_processors.static",
     "django.core.context_processors.media",
     "django.core.context_processors.request",
+    "django.core.context_processors.tz",
     "mezzanine.conf.context_processors.settings",
 )
 
 # List of middleware classes to use. Order is important; in the request phase,
-# this middleware classes will be applied in the order given, and in the
+# these middleware classes will be applied in the order given, and in the
 # response phase the middleware will be applied in reverse order.
 MIDDLEWARE_CLASSES = (
+    "mezzanine.core.middleware.UpdateCacheMiddleware",
     "django.contrib.sessions.middleware.SessionMiddleware",
     "django.contrib.auth.middleware.AuthenticationMiddleware",
     "django.contrib.redirects.middleware.RedirectFallbackMiddleware",
-    "mezzanine.core.middleware.DeviceAwareUpdateCacheMiddleware",
     "django.middleware.common.CommonMiddleware",
     "django.middleware.csrf.CsrfViewMiddleware",
     "django.contrib.messages.middleware.MessageMiddleware",
+    "mezzanine.core.request.CurrentRequestMiddleware",
     "mezzanine.core.middleware.TemplateForDeviceMiddleware",
-    "mezzanine.core.middleware.DeviceAwareFetchFromCacheMiddleware",
+    "mezzanine.core.middleware.TemplateForHostMiddleware",
     "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
+    "mezzanine.core.middleware.SitePermissionMiddleware",
     # Uncomment the following if using any of the SSL settings:
     # "mezzanine.core.middleware.SSLRedirectMiddleware",
+    "mezzanine.pages.middleware.PageMiddleware",
+    "mezzanine.core.middleware.FetchFromCacheMiddleware",
 )
 
 # Store these package names here as they may change in the future since
 PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
 PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
 
-
 #########################
 # OPTIONAL APPLICATIONS #
 #########################
 OPTIONAL_APPS = (
     "debug_toolbar",
     "django_extensions",
+    "compressor",
     PACKAGE_NAME_FILEBROWSER,
     PACKAGE_NAME_GRAPPELLI,
 )
 
 DEBUG_TOOLBAR_CONFIG = {"INTERCEPT_REDIRECTS": False}
 
+###################
+# DEPLOY SETTINGS #
+###################
 
+# These settings are used by the default fabfile.py provided.
+# Check fabfile.py for defaults.
+
+# FABRIC = {
+#     "SSH_USER": "", # SSH username
+#     "SSH_PASS":  "", # SSH password (consider key-based authentication)
+#     "SSH_KEY_PATH":  "", # Local path to SSH key file, for key-based auth
+#     "HOSTS": [], # List of hosts to deploy to
+#     "VIRTUALENV_HOME":  "", # Absolute remote path for virtualenvs
+#     "PROJECT_NAME": "", # Unique identifier for project
+#     "REQUIREMENTS_PATH": "", # Path to pip requirements, relative to project
+#     "GUNICORN_PORT": 8000, # Port gunicorn will listen on
+#     "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8"
+#     "LIVE_HOSTNAME": "www.example.com", # Host for public site.
+#     "REPO_URL": "", # Git or Mercurial remote repo URL for the project
+#     "DB_PASS": "", # Live database password
+#     "ADMIN_PASS": "", # Live admin user password
+# }
+
+ALLOWED_HOSTS = '*'
 ##################
 # LOCAL SETTINGS #
 ##################
 
 # set_dynamic_settings() will rewrite globals based on what has been
 # defined so far, in order to provide some better defaults where
-# applicable.
-from mezzanine.utils.conf import set_dynamic_settings
-set_dynamic_settings(globals())
+# applicable. We also allow this settings module to be imported
+# without Mezzanine installed, as the case may be when using the
+# fabfile, where setting the dynamic settings below isn't strictly
+# required.
+try:
+    from mezzanine.utils.conf import set_dynamic_settings
+except ImportError:
+    pass
+else:
+    set_dynamic_settings(globals())

example/templates/base.html

 <title>{% block meta_title %}{% endblock %}{% if settings.SITE_TITLE %} | {{ settings.SITE_TITLE }}{% endif %}</title>
 
 {% if "mezzanine.blog"|is_installed %}
-<link rel="alternate" type="application/rss+xml" title="RSS" href="{% url blog_post_feed "rss" %}">
-<link rel="alternate" type="application/atom+xml" title="Atom" href="{% url blog_post_feed "atom" %}">
+<link rel="alternate" type="application/rss+xml" title="RSS" href="{% url "blog_post_feed" "rss" %}">
+<link rel="alternate" type="application/atom+xml" title="Atom" href="{% url "blog_post_feed" "atom" %}">
 {% endif %}
 
 <link rel="stylesheet" href="{{ STATIC_URL }}css/bootstrap.css">
 <div class="container">
     {% if settings.SITE_TITLE %}<a class="brand" href="/">{{ settings.SITE_TITLE }}</a>{% endif %}
     {% if settings.SITE_TAGLINE %}<p class="tagline">{{ settings.SITE_TAGLINE }}</p>{% endif %}
-    <form action="{% url search %}" class="navbar-search pull-right">
+    <form action="{% url "search" %}" class="navbar-search pull-right">
     <input class="search-query" placeholder="{% trans "Search" %}" type="text" name="q" value="{{ request.REQUEST.q }}">
     </form>
     {% page_menu "pages/menus/primary.html" %}
     {% block main %}{% endblock %}
 </div>
 
-<div class="span3 right">
+<div class="span3 right"> 
     {% include "includes/user_panel.html" %}
     <div class="panel">
     {% block right_panel %}
 </div>
 
 </div>
-</div>
+</div> 
 
 <footer>
 <div class="container">
     Theme by <a href="http://twitter.github.com/bootstrap/">Bootstrap</a>
     {% if "mezzanine.mobile"|is_installed %}
     <span class="separator">|</span>
-    <a href="{% url set_device "mobile" %}?next={{ request.path }}">{% trans "View Mobile Site" %}</a>
+    <a href="{% url "set_device" "mobile" %}?next={{ request.path }}">{% trans "View Mobile Site" %}</a>
     {% endif %}
 </p>
 </div>

example/templates/pages/page.html

 {% endblock %}
 
 {% block main %}
-{% endblock %}
+{% endblock %}

example/test_settings.py

+from settings import *
+DATABASE_ENGINE = 'django.db.backends.sqlite3'

example/widgets/fixtures/initial_data.json

-[{"pk": 2, "model": "blog.blogpost", "fields": {"status": 2, "allow_comments": false, "description": "Wow, blogging is great!", "title": "Another Blogy", "rating_average": 0.0, "categories": [], "site": 1, "keywords_string": "", "content": "Wow, blogging is great!", "rating_count": 0, "comments_count": 0, "user": 1, "featured_image": null, "short_url": null, "publish_date": "2012-03-04 19:02:31", "slug": "another-blogy", "expiry_date": null}}, {"pk": 1, "model": "blog.blogpost", "fields": {"status": 2, "allow_comments": false, "description": "I want to blog", "title": "First Blogy", "rating_average": 0.0, "categories": [], "site": 1, "keywords_string": "", "content": "I want to blog", "rating_count": 0, "comments_count": 0, "user": 1, "featured_image": null, "short_url": null, "publish_date": "2012-03-04 18:54:29", "slug": "first-blogy", "expiry_date": null}}, {"pk": 1, "model": "widget.widget", "fields": {"status": 2, "expiry_date": null, "acts_on": "", "_order": 0, "author": "Progweb Team", "widgetslot": "main", "display_title": "Social Logos", "widget_class": "sociallogoswidget", "site": 1, "widget_file_title": "", "publish_date": "2012-03-03 14:59:47", "user": 1, "active": true, "page": 8, "page_less": false}}, {"pk": 5, "model": "widget.widget", "fields": {"status": 2, "expiry_date": null, "acts_on": "", "_order": 1, "author": "Progweb Team", "widgetslot": "right", "display_title": "bloglistwidget_3", "widget_class": "bloglistwidget", "site": 1, "widget_file_title": "", "publish_date": "2012-03-04 18:56:55", "user": 1, "active": true, "page": null, "page_less": true}}, {"pk": 6, "model": "widget.widget", "fields": {"status": 2, "expiry_date": null, "acts_on": "", "_order": 2, "author": "Progweb Team", "widgetslot": "right", "display_title": "twittermentionswidgets_3", "widget_class": "twittermentionswidgets", "site": 1, "widget_file_title": "", "publish_date": "2012-03-04 19:29:10", "user": 1, "active": true, "page": null, "page_less": true}}, {"pk": 1, "model": "widget.widgetoptionentry", "fields": {"widget": 6, "name": "Tag", "value": "#mezzanine"}}, {"pk": 2, "model": "widget.widgetoptionentry", "fields": {"widget": 6, "name": "Limit", "value": "5"}}]

example/widgets/templates/widgets/blogposts.html

 <h6>
     {% trans "Posted by" %}:
     {% with blog_post.user as author %}
-    <a href="{% url blog_post_list_author author %}">{{ author.get_full_name|default:author.username }}</a>
+    <a href="{% url "blog_post_list_author" author %}">{{ author.get_full_name|default:author.username }}</a>
     {% endwith %}
     {% if blog_post.category_list %}
     {% trans "in" %}
     {% for category in blog_post.category_list %}
-    <a href="{% url blog_post_list_category category.slug %}">{{ category }}</a>
+    <a href="{% url "blog_post_list_category" category.slug %}">{{ category }}</a>
     {% endfor %}
     {% endif %}
     {{ blog_post.publish_date|timesince }} {% trans "ago" %}
 
 class WidgetAdmin(OwnableAdmin):
     inlines = [OptionsAdmin,]
-    list_display = ("display_title", "status", "widgetslot", "admin_link")
+    list_display = ("display_title", "status", "widgetslot", "admin_link", "page_less")
     list_display_links = ("display_title",)
-    list_editable = ("status",)
+    list_editable = ("status", "page_less",)
     list_filter = ("status","widgetslot",)
-    search_fields = ("display_title","widget_class",)
+    search_fields = ("display_title","widget_class", "page_less",)
     date_hierarchy = "publish_date"
     radio_fields = {"status": admin.HORIZONTAL}
     fieldsets = (
         (None, {"fields": ["page","display_title", "status",
             ("publish_date", "expiry_date"), ]}),
-        (_("Widget"), {"fields": ("widgetslot", "widget_class")}),
+        (_("Widget"), {"fields": ("widgetslot", "widget_class", "page_less")}),
     )
     
     def save_model(self, request, obj, form, change):

widget/defaults.py

+from mezzanine.conf import register_setting
+
+from django.utils.translation import ugettext as _
+
+#register_setting(
+#    name="IMAGE_FIELD_WIDGET_CLASS",
+#    description=_("Dotted package path and class name of the widget to use "
+#                  "for the image fields`."),
+#    editable=False,
+#    default="django.forms.FileInput",
+#)
+
+register_setting(
+    name="RESTRICTED_WIDGETS",
+    label="Restricted Widgets",
+    description=_("Widgets which cannot be added by a client "),
+    editable=False,
+    append=True,
+    default=[
+        "TestWidget"
+    ],
+)
+
+register_setting(
+    name="WIDGET_PERMISSION_HANDLER",
+    label="Widget Permission Handler",
+    description=_("A class which handles permissions for widgets"),
+    editable=False,
+    default=None,
+)
         super(PageWidgetClass, self).__init__(*args, **kwargs)
 
     def formfield(self, form_class=forms.CharField, **kwargs):
-        # This is a fairly standard way to set up some defaults
-#        while letting the caller override them.
         defaults = {'form_class': PageWidgetClassField}
-#        if self.choices:
-#            defaults = {'choices': self.choices}
-#        else:
-#            defaults = {'form_class': PageWidgetClassField}
         defaults.update(kwargs)
         return super(PageWidgetClass, self).formfield(**defaults)
 
-from datetime import datetime
-from os.path import join
+from django import forms
+from django.forms.widgets import HiddenInput
 
-from django import forms
-from mezzanine.core.models import CONTENT_STATUS_CHOICES, CONTENT_STATUS_DRAFT
-
-from widget.widget_pool import get_widget_options, WidgetHasNoOptions
+from widget.widget_pool import get_widget_options, WidgetHasNoOptions, get_all_page_widgets
 from widget.models import WidgetOptionEntry, Widget
 
 from mezzanine.pages.models import Page
-from mezzanine.forms import fields
 from mezzanine.conf import settings
-from mezzanine.forms.forms import fs
 
 from uuid import uuid4
 
+import option_fields
 
-#def get_widget_form()
+
 class WidgetForm(forms.ModelForm):
 
     def __init__(self, *args, **kwargs):
+        restrict_list = kwargs.pop("restrict_list", settings.RESTRICTED_WIDGETS)
         super(WidgetForm, self).__init__(*args, **kwargs)
+        try:
+            user = self.initial["user"]
+            if user.is_superuser:
+                restrict_list = None
+        except KeyError:
+            pass
+
         self.uuid = str(uuid4())
+        self.fields["page"].queryset = Page.objects.get_query_set()
+        self.fields["widget_class"].choices = get_all_page_widgets(restrict_list)
 
     class Meta:
         model = Widget
     Dynamically created form for displaying widget options
     defined in a widget class. Based on mezzanine forms
     """
+    extra_js = []
+    hasOptions = False
 
-    hasOptions = False
-    status = forms.ChoiceField(choices=CONTENT_STATUS_CHOICES, initial=CONTENT_STATUS_DRAFT)
+#    widget_class = forms.HiddenInput(choices=get_all_page_widgets(settings.RESTRICTED_WIDGETS))
 
     def __init__(self, widget_class, *args, **kwargs):
         """
         instance and its related field model instances.
         """
         #get widget options from widget_class
+        self.extra_js = []
         super(WidgetOptionsForm, self).__init__(*args, **kwargs)
         self.widget_class = widget_class
         try:
             self.hasOptions = True
             for field in self.form_fields:
                 field_key = "option_%s" % field.name
-                field_class = fields.CLASSES[field.field_type]
-                field_widget = fields.WIDGETS.get(field.field_type)
+                field_class = option_fields.CLASSES[field.field_type]
+                field_widget = option_fields.WIDGETS.get(field.field_type)
                 field_args = {"label": field.name, "required": field.required,
                               "help_text": field.help_text}
                 arg_names = field_class.__init__.im_func.func_code.co_varnames
                     field_args["widget"] = field_widget
                 self.fields[field_key] = field_class(**field_args)
                 css_class = field_class.__name__.lower()
+
+                field_key_widget =  self.fields[field_key].widget
                 if field.required:
                     css_class += " required"
                     if (settings.FORMS_USE_HTML5 and
-                        field.field_type != fields.CHECKBOX_MULTIPLE):
-                        self.fields[field_key].widget.attrs["required"] = ""
-                self.fields[field_key].widget.attrs["class"] = css_class
+                        field.field_type != option_fields.CHECKBOX_MULTIPLE):
+                        field_key_widget.attrs["required"] = ""
+                try:
+                    field_key_widget.attrs["class"] = css_class + " " + field_key_widget.attrs["class"]
+                except KeyError:
+                    field_key_widget.attrs["class"] = css_class
+
+                try:
+                    self.extra_js.append("this.%s('%s');" % (field_key_widget.META.init_js, "id_%s" % field_key))
+                except Exception:
+                    pass
+
                 try:
                     if field.placeholder_text and not field.default:
                         text = field.placeholder_text
         """
         Save all option ``WidgetOptionEntry`` with reference to the passed widget.
         """
-        widget.status = self.cleaned_data['status']
-        widget.save()
 
         if self.hasOptions:
             for field in self.form_fields:
                     option.value = value
                     option.save()
         return True
+
+
+def ModelFormForWidget(widget_model, fields=None, widget=None):
+    meta_data = { "model": widget_model, }
+
+    try:
+        widget_overrides = settings.WIDGET_OVERRIDES
+    except AttributeError:
+        widget_overrides = {}
+
+    if fields:
+        meta_data.update({"fields": fields})
+
+    if widget:
+        widgets = {
+            'widget': HiddenInput(),
+            }
+        meta_data.update({"widgets": widgets})
+
+    meta = type('Meta', (), meta_data)
+
+    class WidgetModelForm(forms.ModelForm):
+        extra_js = []
+
+        def __init__(self, *args, **kwargs):
+            super(WidgetModelForm, self).__init__(*args, **kwargs)
+            self.uuid = str(uuid4())
+            for f in self.fields.keys():
+                field_class = self.fields[f].__class__
+                try:
+                    field_type = widget_overrides[field_class]
+                except KeyError:
+                    pass
+                else:
+                    self.fields[f].widget = option_fields.WIDGETS[field_type]()
+                css_class = self.fields[f].widget.attrs.get("class", "")
+                css_class += " " + field_class.__name__.lower()
+                self.fields[f].widget.attrs["class"] = css_class
+                self.fields[f].widget.attrs["id"] = "%s" % (f)
+
+                try:
+                    self.extra_js.append("this.%s('%s');" % (self.fields[f].widget.META.init_js, "%s" % f))
+                except Exception:
+                    pass
+
+    modelform_class = type('modelform', (WidgetModelForm,), {"Meta": meta})
+    return modelform_class
 from datetime import datetime
 
-from django.contrib.sites.managers import CurrentSiteManager
 from django.contrib.sites.models import Site
 from django.utils.translation import ugettext as _, ugettext
 from django.db import models
 
 from mezzanine.conf import settings
-from mezzanine.core.managers import PublishedManager, SearchableManager
-from mezzanine.core.models import Orderable, Displayable, \
+from mezzanine.core.managers import PublishedManager, SearchableManager, CurrentSiteManager
+from mezzanine.core.models import Orderable, \
     CONTENT_STATUS_CHOICES, CONTENT_STATUS_DRAFT, Ownable, SiteRelated
-from mezzanine.forms.fields import TEXT
+
+from .option_fields import TEXT
 from mezzanine.pages.models import Page
 
 from widget.fields import PageWidgetClass
 
+from django.db.models import Q
+from mezzanine.utils.timezone import now
 
 class WidgetOption(object):
     """
     """
     Base class for all widget plugin classes
     """
+    editableFields = ""
     template = None
     raw = False 
 
     def render(self, **kwargs):
         raise NotImplementedError("Render function needs to be implemented")
 
+    def cleanup(self, **kwargs):
+        return True
 
 class WidgetModel(SiteRelated):
     widget = models.ForeignKey('widget.Widget')
 
     def __unicode__(self):
-        return u'Model for widget <%s>' % widget.widget_class
+        return u'Model for widget <%s>' % self.widget.widget_class
 
 
 class WidgetManager(CurrentSiteManager, PublishedManager, SearchableManager):
     """
-    Manually combines ``CurrentSiteManager``, ``PublishedManager``
-    and ``SearchableManager`` for the ``Widget`` model.
+    Manually combines ``CurrentSiteManager``, ``SearchableManager`` and provides a modified
+    published filter which takes into cconsideration the users change permission
+    for the ``Widget`` model.
 
     """
-    pass
+    def published(self, for_user=None):
+        """
+        For non-staff/permissionless users, return items with a published status and
+        whose publish and expiry dates fall before and after the
+        current date when specified.
+        """
+        from mezzanine.core.models import CONTENT_STATUS_PUBLISHED
+
+        if for_user is not None and bool(for_user.is_staff
+                or for_user.has_perm("widget.change_widget")):
+            return self.all()
+        return self.filter(
+            Q(publish_date__lte=now()) | Q(publish_date__isnull=True),
+            Q(expiry_date__gte=now()) | Q(expiry_date__isnull=True),
+            Q(status=CONTENT_STATUS_PUBLISHED))
+    def widget_models(self):
+        return WidgetModel.objects.filter(widget=self)
 
 
 class Widget(Orderable, Ownable, SiteRelated):
     expiry_date = models.DateTimeField(_("Expires on"),
         help_text=_("With published checked, won't be shown after this time"),
         blank=True, null=True)
-#    site = models.ForeignKey(Site, editable=False)
+
 
     objects = WidgetManager()
     search_fields = {"keywords": 10, "display_title": 5}
     value = models.CharField(max_length=settings.FORMS_FIELD_MAX_LENGTH)
 
     def __unicode__(self):
-        return '' or self.name
+        return '' or '%s [%s]' % (self.name, self.value)
 
     class Meta:
         verbose_name = _("Widget Option entry")

widget/option_fields.py

+
+from django import forms
+from django.forms.extras import SelectDateWidget
+
+from django.utils.translation import ugettext_lazy as _
+
+from mezzanine.conf import settings
+from mezzanine.core.forms import SplitSelectDateTimeWidget
+
+
+# Constants for all available field types.
+from mezzanine.utils.importing import import_dotted_path
+
+TEXT = 1
+TEXTAREA = 2
+EMAIL = 3
+CHECKBOX = 4
+CHECKBOX_MULTIPLE = 5
+SELECT = 6
+SELECT_MULTIPLE = 7
+RADIO_MULTIPLE = 8
+FILE = 9
+DATE = 10
+DATE_TIME = 11
+HIDDEN = 12
+NUMBER = 13
+URL = 14
+RICHTEXTAREA = 15
+IMAGE = 16
+
+# Names for all available field types.
+NAMES = (
+    (TEXT, _("Single line text")),
+    (TEXTAREA, _("Multi line text")),
+    (EMAIL, _("Email")),
+    (NUMBER, _("Number")),
+    (URL, _("URL")),
+    (CHECKBOX, _("Check box")),
+    (CHECKBOX_MULTIPLE, _("Check boxes")),
+    (SELECT, _("Drop down")),
+    (SELECT_MULTIPLE, _("Multi select")),
+    (RADIO_MULTIPLE, _("Radio buttons")),
+    (FILE, _("File upload")),
+    (DATE, _("Date")),
+    (DATE_TIME, _("Date/time")),
+    (HIDDEN, _("Hidden")),
+    (RICHTEXTAREA, _("Multi line text")),
+    (IMAGE, _("Image")),
+    )
+
+# Field classes for all available field types.
+CLASSES = {
+    TEXT: forms.CharField,
+    TEXTAREA: forms.CharField,
+    RICHTEXTAREA: forms.CharField,
+    EMAIL: forms.EmailField,
+    CHECKBOX: forms.BooleanField,
+    CHECKBOX_MULTIPLE: forms.MultipleChoiceField,
+    SELECT: forms.ChoiceField,
+    SELECT_MULTIPLE: forms.MultipleChoiceField,
+    RADIO_MULTIPLE: forms.ChoiceField,
+    FILE: forms.FileField,
+    DATE: forms.DateField,
+    DATE_TIME: forms.DateTimeField,
+    HIDDEN: forms.CharField,
+    NUMBER: forms.FloatField,
+    URL: forms.URLField,
+    IMAGE: forms.ImageField,
+    }
+
+# Widgets for field types where a specialised widget is required.
+WIDGETS = {
+    TEXTAREA: forms.Textarea,
+    RICHTEXTAREA: import_dotted_path(settings.RICHTEXT_WIDGET_CLASS),
+    CHECKBOX_MULTIPLE: forms.CheckboxSelectMultiple,
+    RADIO_MULTIPLE: forms.RadioSelect,
+    DATE: SelectDateWidget,
+    DATE_TIME: SplitSelectDateTimeWidget,
+    HIDDEN: forms.HiddenInput,
+    IMAGE: forms.FileInput
+    }
+
+#tiny hack to use IMAGE WIDGET CLASS if it exists
+try:
+    WIDGETS.update({IMAGE: import_dotted_path(settings.IMAGE_FIELD_WIDGET_CLASS)})
+except AttributeError:
+    pass
+
+# Some helper groupings of field types.
+CHOICES = (CHECKBOX, CHECKBOX_MULTIPLE, SELECT,
+           SELECT_MULTIPLE, RADIO_MULTIPLE)
+DATES = (DATE, DATE_TIME)
+MULTIPLE = (CHECKBOX_MULTIPLE, SELECT_MULTIPLE)
+
+# HTML5 Widgets
+if settings.FORMS_USE_HTML5:
+    html5_field = lambda name, base: type("", (base,), {"input_type": name})
+    WIDGETS.update({
+        DATE: html5_field("date", forms.DateInput),
+        DATE_TIME: html5_field("datetime", forms.DateTimeInput),
+        EMAIL: html5_field("email", forms.TextInput),
+        NUMBER: html5_field("number", forms.TextInput),
+        URL: html5_field("url", forms.TextInput),
+        })

widget/page_widgets.py

-from widget import widget_pool
 from widget.models import WidgetOption as opt, WidgetClassBase
 
 from django.utils.translation import ugettext_lazy as _
     raw = True
     default_placeholder = "test"
     options = [
-        opt(name="Option 1"),
-        opt(name="Option 2"),
-        opt(name="Option 3")
+        opt(name="First"),
+        opt(name="Second"),
+        opt(name="Third")
     ]
 
-    def render(self, context, slot, queryset, **kwargs):
+    def render(self, context, slot, queryset=None, options=None, **kwargs):
         return context
 
     class Meta:
         name = _("Test")
         author = 'Osiloke Emoekpere'
 
-#widget_pool.register_widget(TestWidget)

widget/static/widget/css/widget.css

 .frontend-admin-form .btn {width:auto; cursor:pointer; float:right;
     margin:15px 0 0 15px; padding:5px 15px;}
 .frontend-admin-form .controls{margin-bottom: 10px;}
-.frontend-admin-form .controls label{margin-bottom: 10px;}
+.frontend-admin-form .controls label{margin-bottom: 10px;}
+
+.ordering .tools{position: relative; top:0; right:0; loat:right; cursor:move;}
+.wysihtml5-sandbox body{line-height: 1px !important;}
+#sortablelist {
+    padding: 16px 21px !important;
+}
+
+.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
+.widget-sortable { float:left; margin-right:20px;}
+
+/*body { color:white; font-family:Helvetica, sans-serif; text-shadow:1px 1px 1px rgba(0,0,0,0.2); }*/
+.widget-sortable { overflow:hidden; border-radius:6px; }
+.widget_holder { display:block; position:relative; z-index:1; }
+.widget_holder:after {display:block; position:absolute; height:100%; width:100%; top:0px; left:0px; content:' '; border-radius:6px; z-index:-1; }
+
+.widget_holder { -moz-transition:border-top-width 0.1s ease-in; -webkit-transition:border-top-width 0.1s ease-in; border-top:0px solid rgba(0,0,0,0); }
+.marker {
+    width:100%;
+    float:left;
+    opacity:0.0;
+    background: #f0f0f0;
+    border:1px dashed #000;
+    visibility: visible !important;
+}
+.placeholder {
+    width: 100%;
+    /*margin: -2px;*/
+    background: #717ca1;
+    height: 1em;
+}

widget/static/widget/js/bootstrap-tooltip.js

+/* ===========================================================
+ * bootstrap-tooltip.js v2.2.1
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
+ * Inspired by the original jQuery.tipsy by Jason Frame
+ * ===========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+    "use strict"; // jshint ;_;
+
+
+    /* TOOLTIP PUBLIC CLASS DEFINITION
+     * =============================== */
+
+    var Tooltip = function (element, options) {
+        this.init('tooltip', element, options)
+    }
+
+    Tooltip.prototype = {
+
+        constructor: Tooltip
+
+        , init: function (type, element, options) {
+            var eventIn
+                , eventOut
+
+            this.type = type
+            this.$element = $(element)
+            this.options = this.getOptions(options)
+            this.enabled = true
+
+            if (this.options.trigger == 'click') {
+                this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+            } else if (this.options.trigger != 'manual') {
+                eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
+                eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
+                this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+                this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+            }
+
+            this.options.selector ?
+                (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
+                this.fixTitle()
+        }
+
+        , getOptions: function (options) {
+            options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
+
+            if (options.delay && typeof options.delay == 'number') {
+                options.delay = {
+                    show: options.delay
+                    , hide: options.delay
+                }
+            }
+
+            return options
+        }
+
+        , enter: function (e) {
+            var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+
+            if (!self.options.delay || !self.options.delay.show) return self.show()
+
+            clearTimeout(this.timeout)
+            self.hoverState = 'in'
+            this.timeout = setTimeout(function() {
+                if (self.hoverState == 'in') self.show()
+            }, self.options.delay.show)
+        }
+
+        , leave: function (e) {
+            var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+
+            if (this.timeout) clearTimeout(this.timeout)
+            if (!self.options.delay || !self.options.delay.hide) return self.hide()
+
+            self.hoverState = 'out'
+            this.timeout = setTimeout(function() {
+                if (self.hoverState == 'out') self.hide()
+            }, self.options.delay.hide)
+        }
+
+        , show: function () {
+            var $tip
+                , inside
+                , pos
+                , actualWidth
+                , actualHeight
+                , placement
+                , tp
+
+            if (this.hasContent() && this.enabled) {
+                $tip = this.tip()
+                this.setContent()
+
+                if (this.options.animation) {
+                    $tip.addClass('fade')
+                }
+
+                placement = typeof this.options.placement == 'function' ?
+                    this.options.placement.call(this, $tip[0], this.$element[0]) :
+                    this.options.placement
+
+                inside = /in/.test(placement)
+
+                $tip
+                    .detach()
+                    .css({ top: 0, left: 0, display: 'block' })
+                    .insertAfter(this.$element)
+
+                pos = this.getPosition(inside)
+
+                actualWidth = $tip[0].offsetWidth
+                actualHeight = $tip[0].offsetHeight
+
+                switch (inside ? placement.split(' ')[1] : placement) {
+                    case 'bottom':
+                        tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
+                        break
+                    case 'top':
+                        tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
+                        break
+                    case 'left':
+                        tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
+                        break
+                    case 'right':
+                        tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
+                        break
+                }
+
+                $tip
+                    .offset(tp)
+                    .addClass(placement)
+                    .addClass('in')
+            }
+        }
+
+        , setContent: function () {
+            var $tip = this.tip()
+                , title = this.getTitle()
+
+            $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
+            $tip.removeClass('fade in top bottom left right')
+        }
+
+        , hide: function () {
+            var that = this
+                , $tip = this.tip()
+
+            $tip.removeClass('in')
+
+            function removeWithAnimation() {
+                var timeout = setTimeout(function () {
+                    $tip.off($.support.transition.end).detach()
+                }, 500)
+
+                $tip.one($.support.transition.end, function () {
+                    clearTimeout(timeout)
+                    $tip.detach()
+                })
+            }
+
+            $.support.transition && this.$tip.hasClass('fade') ?
+                removeWithAnimation() :
+                $tip.detach()
+
+            return this
+        }
+
+        , fixTitle: function () {
+            var $e = this.$element
+            if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
+                $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
+            }
+        }
+
+        , hasContent: function () {
+            return this.getTitle()
+        }
+
+        , getPosition: function (inside) {
+            return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
+                width: this.$element[0].offsetWidth
+                , height: this.$element[0].offsetHeight
+            })
+        }
+
+        , getTitle: function () {
+            var title
+                , $e = this.$element
+                , o = this.options
+
+            title = $e.attr('data-original-title')
+                || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
+
+            return title
+        }
+
+        , tip: function () {
+            return this.$tip = this.$tip || $(this.options.template)
+        }
+
+        , validate: function () {
+            if (!this.$element[0].parentNode) {
+                this.hide()
+                this.$element = null
+                this.options = null
+            }
+        }
+
+        , enable: function () {
+            this.enabled = true
+        }
+
+        , disable: function () {
+            this.enabled = false
+        }
+
+        , toggleEnabled: function () {
+            this.enabled = !this.enabled
+        }
+
+        , toggle: function (e) {
+            var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+            self[self.tip().hasClass('in') ? 'hide' : 'show']()
+        }
+
+        , destroy: function () {
+            this.hide().$element.off('.' + this.type).removeData(this.type)
+        }
+
+    }
+
+
+    /* TOOLTIP PLUGIN DEFINITION
+     * ========================= */
+
+    $.fn.tooltip = function ( option ) {
+        return this.each(function () {
+            var $this = $(this)
+                , data = $this.data('tooltip')
+                , options = typeof option == 'object' && option
+            if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
+            if (typeof option == 'string') data[option]()
+        })
+    }
+
+    $.fn.tooltip.Constructor = Tooltip
+
+    $.fn.tooltip.defaults = {
+        animation: true
+        , placement: 'top'
+        , selector: false
+        , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
+        , trigger: 'hover'
+        , title: ''
+        , delay: 0
+        , html: false
+    }
+
+}(window.jQuery);

widget/static/widget/js/widget.coffee

 class @WidgetAdmin
   @options_forms: {}
+  @options: {}
+  widget_status_icon_toggle: {
+    2: {"ico":"icon-chevron-up", "message": "Published", "prefix": "Unpublish"},
+    1: {"ico":"icon-chevron-down", "messsage": "Unpublished", "prefix":"Publish"}
+  }
 
-
-  constructor: ->
+  constructor: (options) ->
+    @options = options
 #    console.log "Widget Admin Controller"
     #Catch all actions which are not implemented yet
     not_impl = $('a.not-implemented')
         not_impl.each((i) ->
 
         )
+    #some neccessary jq config
+    $(".widget-edit-link, .widget-delete-link").tooltip {placement:"right"}
+    @setupAdmin()
+    @setupWidgetForms()
+    @setupSortableWidgets()
+    @setupWidgetStatusHandler()
     @
 
   setupAdmin: () =>
             )
         else
           $("#options-form-holder").html(@options_forms[type])
-    @setupSortableWidgets()
+
+
     @
 
   setupWidgetForms: () =>
         overlay = {onBeforeLoad: onBeforeLoad, closeOnEsc: true, expose: expose, closeOnClick: true, close: ':button'}
         link.overlay(overlay)
     )
+
+    #Setup Edit Form for ajax post submission
     $("#edit-widget-form").adminForm({resultParsed: @onEditData})
-    $('.widget-edit-link').click((e) =>
-        widget_id = e.currentTarget.id.split("-")[1]
-        widget_title = e.currentTarget.value
-        @onEditForm(e.currentTarget, widget_id, widget_title)
+
+    that = this
+    #Setup Edit Form Triggers
+    $.each($('.widget-edit-link'), (i) ->
+        $link = $(this)
+        target = $(this)[0]
+        onBeforeLoad = () ->
+          widget_id = target.id.split("-")[1]
+          widget_title = target.parentElement.parentElement.parentElement.id
+          that.onEditForm(target, widget_id, widget_title)
+        overlay = {onBeforeLoad: onBeforeLoad, closeOnEsc: true, expose: expose, closeOnClick: true, close: ':button'}
+        $link.overlay(overlay) 
     )
     @
 
+  setupWidgetStatusHandler: =>
+    status_icons = @widget_status_icon_toggle
+    $(".widget-publish-link").tooltip {
+      placement:"right",
+      title: () ->
+        widget_status = @id.split("-")[-1..][0]
+        return status_icons[widget_status]["prefix"]
+    }
+    $(".widget-publish-link").on("click", ((e) =>
+      id_split = e.currentTarget.id.split("-")
+      widget_id = id_split[1]
+      widget_title = $(e.currentTarget).attr('data-original-title')
+      callback = (data) =>
+        if data.status == true
+#          icon = $("#" + e.currentTarget.id + " i")
+          icon = e.currentTarget.getElementsByTagName("i")[0]
+          toggle = @widget_status_icon_toggle[data.published]
+          new_class = toggle["ico"]
+          icon.className = new_class
+          old_id = e.currentTarget.id
+          new_id = old_id[...-1] + data.published
+          e.currentTarget.id = new_id
+
+      @remoteCall(e.currentTarget, @options.status_url, {"id":widget_id}, callback)
+      e.preventDefault()
+    ))
+
+  setupSortableWidgets: ->
+    # AJAX callback that's triggered when dragging a widget to re-order
+    # Based on mezzanine
+    updateOrdering = (event, ui) ->
+#      $uiItem = $(ui.item)
+#      if $uiItem.parent().is('.widget-sortable') then $uiItem.remove()
+
+      next = ui.item.next()
+      next.css({'-moz-transition':'none', '-webkit-transition':'none', 'transition':'none'})
+      setTimeout(next.css.bind(next, {'-moz-transition':'border-top-width 0.1s ease-in', '-webkit-transition':'border-top-width 0.1s ease-in', 'transition':'border-top-width 0.1s ease-in'}))
+
+      args =
+        'ordering_from': $(this).sortable('toArray').toString(),
+        'ordering_to': $(ui.item).parent().sortable('toArray').toString(),
+#      console.log $(this), $(ui.item)
+      if args['ordering_from'] != args['ordering_to']
+        # Branch changed - set the new parent ID.
+        args['moved_widget'] = $(ui.item).attr('id')
+        args['moved_parent'] = $(ui.item).parent().parent().attr('id')
+        if args['moved_parent'] == 'widget-sortable'
+          delete args['moved_parent']
+      else
+        delete args['ordering_to']
+        delete args['widget_class_to']
+
+      $.post(window.__widget_ordering_url, args, (data) ->
+        if not data
+          alert("Error occured: " + data + "\nWidget ordering wasn't updated.");
+
+      ) 
+    stylesheet = $('style[name=impostor_size]')[0].sheet
+    `rule = stylesheet.rules ? stylesheet.rules[0].style : stylesheet.cssRules[0].style`
+    setPadding = (atHeight) ->
+        rule.cssText = 'border-top-width: '+atHeight+'px'
+
+    $('.widget-sortable').sortable({
+      handle: '.ordering',
+      opacity: '.7',
+      stop: updateOrdering,
+      forcePlaceholderSize: true,
+      dropOnEmpty: true,
+      placeholder: 'placeholder',
+      helper: 'clone',
+      revert: 150,
+
+#      start: (ev, ui) ->
+#        setPadding(ui.item.height())
+    })
+      .sortable('option', 'connectWith', '.widget-sortable')
+      .bind('sortstart', (event, ui) ->
+          setPadding(ui.item.height())
+#          $uiItem = $(ui.item)
+#          $uiItem.clone().show().insertBefore($uiItem)
+      )
+      .disableSelection()
+
+  #edit form handler
   onEditForm: (link, widget_id, widget_title) ->
     widget = this
-    editUrl = "/widget/edit/" + widget_id + "/"
+    url = "/widget/edit/" + widget_id + "/"
     options = {
-      url: editUrl
+      url: url
       success: (data) ->
-        expose = {color: "#333", loadSpeed: 200, opacity: 0.9}
-        overlay = {load: true, closeOnEsc: true, expose: expose, closeOnClick: true, close: ':button'}
         widget.onEditData(null, data, widget_title)
         $("#edit-widget-form")
-          # .adminForm({data: {id: widget_id}})
           .get(0)
-          .setAttribute("action", editUrl)
-
-        $(link).overlay(overlay)