Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 31e4a67856c541c1b922ff905e852f50d6117131 Fiedzia committed Oct 13, 2009
Showing with 2,134 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. 0 INSTALL
  3. 0 README
  4. 0 code_hacking.txt
  5. 0 fangofmongo/__init__.py
  6. 0 fangofmongo/fom/__init__.py
  7. +3 −0 fangofmongo/fom/models.py
  8. +17 −0 fangofmongo/fom/templates/base.html
  9. +30 −0 fangofmongo/fom/templates/base2.html
  10. +5 −0 fangofmongo/fom/templates/mongo_colllist.html
  11. +5 −0 fangofmongo/fom/templates/mongo_console.html
  12. +5 −0 fangofmongo/fom/templates/mongo_dblist.html
  13. +45 −0 fangofmongo/fom/templates/mongo_ui_page.html
  14. +31 −0 fangofmongo/fom/templates/start_form.html
  15. +17 −0 fangofmongo/fom/templates/start_page.html
  16. +23 −0 fangofmongo/fom/tests.py
  17. +9 −0 fangofmongo/fom/urls.py
  18. +77 −0 fangofmongo/fom/views.py
  19. +11 −0 fangofmongo/manage.py
  20. +81 −0 fangofmongo/settings.py
  21. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_flat_0_aaaaaa_40x100.png
  22. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_flat_75_ffffff_40x100.png
  23. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_glass_55_fbf9ee_1x400.png
  24. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_glass_65_ffffff_1x400.png
  25. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_glass_75_dadada_1x400.png
  26. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_glass_75_e6e6e6_1x400.png
  27. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_glass_95_fef1ec_1x400.png
  28. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  29. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-icons_222222_256x240.png
  30. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-icons_2e83ff_256x240.png
  31. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-icons_454545_256x240.png
  32. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-icons_888888_256x240.png
  33. BIN fangofmongo/static/contrib/jquery-ui/css/base/images/ui-icons_cd0a0a_256x240.png
  34. +9 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.accordion.css
  35. +2 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.all.css
  36. +8 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.base.css
  37. +37 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.core.css
  38. +62 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.datepicker.css
  39. +13 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.dialog.css
  40. +4 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.progressbar.css
  41. +13 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.resizable.css
  42. +17 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.slider.css
  43. +11 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.tabs.css
  44. +245 −0 fangofmongo/static/contrib/jquery-ui/css/base/ui.theme.css
  45. BIN ...fmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
  46. BIN ...fmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
  47. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
  48. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
  49. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
  50. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
  51. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
  52. BIN ...fmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
  53. BIN ...ofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
  54. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-icons_222222_256x240.png
  55. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-icons_228ef1_256x240.png
  56. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-icons_ef8c08_256x240.png
  57. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
  58. BIN fangofmongo/static/contrib/jquery-ui/css/ui-lightness/images/ui-icons_ffffff_256x240.png
  59. +406 −0 fangofmongo/static/contrib/jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css
  60. +367 −0 fangofmongo/static/contrib/jquery-ui/index.html
  61. +19 −0 fangofmongo/static/contrib/jquery-ui/js/jquery-1.3.2.min.js
  62. +298 −0 fangofmongo/static/contrib/jquery-ui/js/jquery-ui-1.7.2.custom.min.js
  63. +19 −0 fangofmongo/static/contrib/jquery/jquery-1.3.2.min.js
  64. +8 −0 fangofmongo/static/fom/css/fangofmongo_login.css
  65. +17 −0 fangofmongo/static/fom/css/fangofmongo_ui.css
  66. +60 −0 fangofmongo/static/fom/js/fangofmongo_login.js
  67. +133 −0 fangofmongo/static/fom/js/fangofmongo_ui.js
  68. +25 −0 fangofmongo/urls.py
@@ -0,0 +1,2 @@
+#ignore python compiled files
+*.pyc
No changes.
0 README
No changes.
No changes.
No changes.
No changes.
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+{% block meta %}{% endblock meta %}
+{% block js %}{% endblock js %}
+{% block css %}{% endblock css %}
+
+
+</head>
+<body>
+{% block header %}{% endblock header %}
+{% block content %}{% endblock content%}
+{% block footer %}{% endblock footer %}
+
+</body>
+</html>
+
@@ -0,0 +1,30 @@
+{% extends 'base.html' %}
+
+{% block meta %}
+{{ block.super }}
+<title>Fang of Mongo: MongoDB web interface</title>
+<meta name="keywords" content="fang of mongo, fangofmongo, mongo, mongodb, django"/>
+<meta name="author" content="maciej dziardziel (maciejdziardziel@wp.pl"/>
+
+{% endblock meta %}
+{% block js %}
+{{ block.super }}
+<script src="/static/contrib/jquery/jquery-1.3.2.min.js"></script>
+<script src="/static/contrib/jquery-ui/js/jquery-ui-1.7.2.custom.min.js"></script>
+{% endblock %}
+
+{% block css %}
+{{ block.super }}
+<link rel=stylesheet href="/static/contrib/jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css" type="text/css"/>
+{% endblock %}
+
+{% block content %}
+
+<div id='errormsg'>
+<p>
+If you see this mesage, then either you have javascript disabled, or something else went wrong.<br/>
+Please turn js on and refresh this page.
+</p>
+</div>
+
+{% endblock content %}
@@ -0,0 +1,5 @@
+<div id="fom_dialog_coll" title="Collections">
+<input type="text" name="fom_input_coll" id="fom_input_coll"/>
+ <div id="fom_dialog_coll_list">
+ </div>
+</div>
@@ -0,0 +1,5 @@
+<div id="fom_console_dialog" title="Console">
+<input type="text" name="fom_console_input" id="fom_console_input"/>
+ <div id="fom_console_output">
+ </div>
+</div>
@@ -0,0 +1,5 @@
+<div id="fom_dialog_db" title="Databases">
+<input type="text" name="fom_input_db" id="fom_input_db"/>
+ <div id="fom_dialog_db_list">
+ </div>
+</div>
@@ -0,0 +1,45 @@
+{% extends 'base2.html' %}
+
+{% block js %}
+{{ block.super }}
+<script> var connection_params = { 'host':'{{ connection_params.host }}', 'port': '{{ connection_params.port }}', 'db' : null, 'coll': null }; </script>
+<script src="/static/fom/js/fangofmongo_ui.js"></script>
+<script> try { fom_init_mongo_ui(); } catch(e) { alert(e); }; </script>
+{% endblock %}
+
+{% block css %}
+{{ block.super }}
+<link rel=stylesheet href="/static/fom/css/fangofmongo_ui.css" type="text/css"/>
+{% endblock %}
+
+{% block header %}
+{{ block.super }}
+<div id="mongo_ui_header" class="ui-dialog-titlebar ui-widget-headeri">
+Fang of mongo
+</div>
+<div id="mongo_ui_header_tools">
+ <div id="mongo_ui_header_tools_db">
+ Database list
+ </div>
+ <div id="mongo_ui_header_tools_coll">
+ Collection list
+ </div>
+ <div id="mongo_ui_header_tools_console">
+ Console window
+ </div>
+
+</div>
+<div id="errors"></div>
+{% endblock header %}
+
+
+{% block content %}
+{{ block.super }}
+<div id="mongo_ui_container">
+</div> <!-- mongo_ui_container -->
+{% include 'fom/templates/mongo_dblist.html' %}
+{% include 'fom/templates/mongo_colllist.html' %}
+{% include 'fom/templates/mongo_console.html' %}
+
+
+{% endblock content %}
@@ -0,0 +1,31 @@
+<div id="start_dialog" title="Welcome to Fang of Mongo">
+ <p id="validateTips">
+ <b>Fang of Mongo</b> is a dead simple web interface to <a href="http://www.mongodb.org">Mongo</a> database,<br/>
+ written in <a href="http://www.djangoproject.com/">Django</a> by Maciej Dziardziel (<a href="mailto:maciejdziardziel@wp.pl">maciejdziardziel@wp.pl</a>).<br/>
+ You will need modern webbrowser to use it. I hope you will find it usefull.
+ </p>
+
+ <form>
+ <fieldset>
+ <!--<label for="db_engine">Engine</label>
+ <select name="db_engine" id="db_engine">
+ <option value="mongo">Mongo</option>
+ </select>-->
+ <label for="db_host">Host</label>
+ <input type="text" name="db_host" id="db_host" value="localhost" class="text ui-widget-content ui-corner-all" />
+ <label for="db_port">Port</label>
+ <input type="text" name="db_port" id="db_port" value="27017" class="text ui-widget-content ui-corner-all" />
+
+
+ <label for="db_login">Login</label>
+ <input type="test" name="db_login" id="db_login" value="" class="text ui-widget-content ui-corner-all" />
+
+
+ <label for="db_password">Password</label>
+ <input type="password" name="db_password" id="db_password" value="" class="text ui-widget-content ui-corner-all" />
+ </fieldset>
+ </form>
+ <p>
+ For connecting with default Mongo installation, just click the button.
+ </p>
+</div>
@@ -0,0 +1,17 @@
+{% extends 'base2.html' %}
+
+{% block js %}
+{{ block.super }}
+<script src="/static/fom/js/fangofmongo_login.js"></script>
+<script> try { fom_init_login_form(); }catch(e){ alert(e);}; </script>
+{% endblock %}
+
+{% block css %}
+{{ block.super }}
+<link rel=stylesheet href="/static/fom/css/fangofmongo_login.css" type="text/css"/>
+{% endblock %}
+
+{% block content %}
+{{ block.super }}
+{% include 'fom/templates/start_form.html' %}
+{% endblock content %}
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
@@ -0,0 +1,9 @@
+from django.conf.urls.defaults import patterns, include
+
+urlpatterns = patterns('',
+ # Example:
+ (r'^$', 'fom.views.start_page'),
+ (r'ui/mongo/(?P<host>.+)/(?P<port>\d+)/$', 'fom.views.ui_page'),
+ (r'rest/mongo/(?P<host>.+)/(?P<port>\d+)/databases/$', 'fom.views.list_databases'),
+ (r'rest/mongo/(?P<host>.+)/(?P<port>\d+)/collections/(?P<dbname>.+)/$', 'fom.views.list_collections'),
+)
@@ -0,0 +1,77 @@
+from django.http import HttpResponse
+from django.shortcuts import render_to_response
+from django.utils import simplejson as json
+
+import re
+import pymongo
+
+#login view
+def start_page(request):
+ """
+ place to enter database credentials
+ """
+ return render_to_response('fom/templates/start_page.html', {})
+
+#login view
+def ui_page(request, host, port):
+ """
+ mongo user interface
+ """
+ return render_to_response('fom/templates/mongo_ui_page.html',
+ { 'connection_params' : {'host':host, 'port': port,'db': None,'coll':None}}
+ )
+
+######### mongo interface. Ok, just stub of it.
+
+def list_databases(request, host, port):
+ """
+ From GET take: login, password : database credentials(optional, currently ignored)
+ search : text to search (optional)
+ method : re (means regular expression) or empty (means search for occurence of text) (optional)
+ if there is no search, return all databases (FIXME: handle large amount of databases)
+ Return list of databases matching given criteria
+ """
+
+ try:
+ conn = pymongo.Connection(host = host, port = int(port))
+ dbnames = conn.database_names()
+ if request.GET:
+ if 'search' in request.GET:
+ if request.GET.get('method','') =='re':
+ dbnames = [dbname for dbname in dbnames if re.match(request.GET['search'], dbname)]
+ else:
+ dbnames = [dbname for dbname in dbnames if request.GET['search'] in dbname]
+ dbnames.sort()
+ json_response = json.dumps({'data':dbnames})
+ except (Exception), e:
+ json_response = (json.dumps({'error': repr(e)}))
+
+ return HttpResponse(json_response, mimetype='application/json')
+
+
+def list_collections(request, host, port, dbname):
+ """
+ From GET take: login, password : database credentials(optional, currently ignored)
+ search : text to search (optional)
+ method : re (means regular expression) or empty (means search for occurence of text) (optional)
+ if there is no search, return all collections (FIXME: handle large amount of collections)
+ Return list of databases matching given criteria
+ """
+ try:
+ conn = pymongo.Connection(host = host, port = int(port))
+ db = conn[dbname]
+ collnames = db.collection_names()
+ if request.GET:
+ if 'search' in request.GET:
+ if request.GET.get('method','') =='re':
+ collnames = [collname for collname in collnames if re.match(request.GET['search'], collname)]
+ else:
+ collnames = [collname for collname in collnames if request.GET['search'] in collname]
+ collnames.sort()
+ json_response = json.dumps({'data':collnames})
+ except (Exception), e:
+ json_response = json.dumps({'error': repr(e)})
+
+ return HttpResponse(json_response, mimetype='application/json')
+
+
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
@@ -0,0 +1,81 @@
+# Django settings for fangofmongo project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = '' # Or path to database file if using sqlite3.
+DATABASE_USER = '' # Not used with sqlite3.
+DATABASE_PASSWORD = '' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'Warsaw/Poland'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = False
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = '/home/fiedzia/moje/fangofmongo/fangofmongo/static/'
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'o&z6rnjmqh@gmxp#7d)p3f(4g6u^rl^6q3&iuc^cu9k6znq^8f'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ #'django.middleware.common.CommonMiddleware',
+ #'django.contrib.sessions.middleware.SessionMiddleware',
+ #'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'fangofmongo.urls'
+
+TEMPLATE_DIRS = (
+ '',
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+INSTALLED_APPS = (
+ #'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ #'django.contrib.sessions',
+ #'django.contrib.sites',
+ 'fangofmongo.fom',
+)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+/* Accordion
+----------------------------------*/
+.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
+.ui-accordion .ui-accordion-li-fix { display: inline; }
+.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
+.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em 2.2em; }
+.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
+.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; }
+.ui-accordion .ui-accordion-content-active { display: block; }
@@ -0,0 +1,2 @@
+@import "ui.base.css";
+@import "ui.theme.css";
@@ -0,0 +1,8 @@
+@import url("ui.core.css");
+@import url("ui.resizable.css");
+@import url("ui.accordion.css");
+@import url("ui.dialog.css");
+@import url("ui.slider.css");
+@import url("ui.tabs.css");
+@import url("ui.datepicker.css");
+@import url("ui.progressbar.css");
Oops, something went wrong.

0 comments on commit 31e4a67

Please sign in to comment.