Skip to content

Commit

Permalink
original working version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Richardson committed Oct 6, 2011
0 parents commit 1745014
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 0 deletions.
Empty file added __init__.py
Empty file.
Binary file added __init__.pyc
Binary file not shown.
14 changes: 14 additions & 0 deletions manage.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('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" % __file__)
sys.exit(1)

import settings

if __name__ == "__main__":
execute_manager(settings)
148 changes: 148 additions & 0 deletions settings.py
@@ -0,0 +1,148 @@
# Django settings for discorrelate project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/home/tim/workspace/discorrelate/src/sqlite.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'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.
# On Unix systems, a value of None will cause Django to use the same
# 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 = 'America/Chicago'

# 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 = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = '/home/tim/workspace/discorrelate/src/discorrelate/staticroot/'

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/tim/workspace/discorrelate/src/discorrelate/static/',
)

# 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',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'a6%_ko*@*9n$r6w7460-jue1llog8fo0l5(96&uxhjch!tk1ry'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware'
)

ROOT_URLCONF = 'discorrelate.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.
"/home/tim/workspace/discorrelate/src/discorrelate/templates"
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
Binary file added settings.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions static/d3
Submodule d3 added at 9a8b38
2 changes: 2 additions & 0 deletions static/test
@@ -0,0 +1,2 @@
hello

128 changes: 128 additions & 0 deletions templates/root.html
@@ -0,0 +1,128 @@
<!doctype html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<style type="text/css">
svg{
position:absolute;
top:0;
left:0;
z-index:-1;
}
form{
position:absolute;
left:1em;
top:1em;
}
circle {
stroke-width: 1.5px;
}

line {
stroke: #999;
}
.nodetext { pointer-events: none; font: 10px sans-serif; }

</style>
<script type="text/javascript">
$(document).ready(function(data) {
$('form').submit(function(e){
e.preventDefault();
var url = $('input[name="url"]').val();
var query = $('select[name="query"]').val();
var csrfmiddlewaretoken = $('input[name="csrfmiddlewaretoken"]').val();
$.ajax({
type : 'POST',
url : '/',
data: {
url : url,
query : query,
csrfmiddlewaretoken : csrfmiddlewaretoken
},
success : function(json){
var w = $(window).width(),
h = $(window).height(),
r = 10,
fill = d3.scale.category20();

var force = d3.layout.force()
.gravity(.01)
.charge(-50)
.linkDistance(60)
.size([w, h]);

var svg = d3.select("body").append("svg:svg")
.attr("width", w)
.attr("height", h);

var link = svg.selectAll("line")
.data(json.links)
.enter().append("svg:line");

var node = svg.selectAll("g.node")
.data(json.nodes)
.enter().append("svg:g")
.attr("class", "node")
.call(force.drag);

node
.append("svg:circle")
.attr("r", r - .75)
.style("fill", function(d) { return fill(d.group); })
.style("stroke", function(d) { return d3.rgb(fill(d.group)).darker(); });

node
.append("svg:title")
.text(function(d) { return d.artist; });

node
.append("svg:text")
.attr("class", "nodetext")
.attr("dx", 12)
.attr("dy", ".3em")
.text(function(d) { return d.name; });

force
.nodes(json.nodes)
.links(json.links)
.on("tick", tick)
.start();

function tick() {

force.start();

node
.attr("transform", function(d) {
//return "translate(" + ((d.x - d.px)+w/2) + "," + ((d.y - d.py)+h/2) + ")";
return "translate(" + d.x + "," + d.y + ")";
});

link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });

}
}
});
});
});
</script>
</head>
<body>
<form method="">
{% csrf_token %}
<input name="url" type="text" value="Use Discogs URL here"/>
<select name="query">
<option value="labels">Linked by label</option>
<option value="colabs">Colaborations</option>
<option value="comps">On compilations together</option>
</select>
<input type="submit" value="find" id="submit-button"/>
</form>
<div id="result"></div>
<script type="text/javascript" src="{{ STATIC_URL }}d3/d3.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}d3/d3.geom.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}d3/d3.layout.js"></script>
</body>
</html>

0 comments on commit 1745014

Please sign in to comment.