diff --git a/DEPLOYING b/DEPLOYING new file mode 100644 index 0000000..24fffd5 --- /dev/null +++ b/DEPLOYING @@ -0,0 +1,18 @@ +Here is a quick guide on how to deploy your very own LightWrite server! + +First off, you have to get all the needed things. You will need Python 2.7 and django, just google search em +You will also need sqlite3, so do a quick apt-get || yum install || whatever the hell your package manager is sqlite3 + +Now, you will need to configure a few things. +In the directory lightwrite, which you should've gotten from the git pull, there is a file named local_settings.py. Open that. + +All you have to do here is change the paths to work with your machine. Here are some templates. + +MEDIA_ROOT = '/path/to/top/dir/of/this/project/static' +SITE_ROOT = '/path/to/top/dir/of/this/project' +STATICFILES_DIR = ('/path/to/top/dir/of/this/project/static') + +And that should be that! Now all you have to do is from the terminal, change directory to /path/to/top/dir/of/this/project/lightwrite/ and then type ./run.sh! +If you have any problems with this, just try and figure it out. It shouldn't be that hard. + +If you see something I missed, please do add on to this file. diff --git a/lightwrite/.local_settings.py.swp b/lightwrite/.local_settings.py.swp deleted file mode 100644 index ab1a835..0000000 Binary files a/lightwrite/.local_settings.py.swp and /dev/null differ diff --git a/lightwrite/.urls.py.swp b/lightwrite/.urls.py.swp deleted file mode 100644 index f5843e3..0000000 Binary files a/lightwrite/.urls.py.swp and /dev/null differ diff --git a/lightwrite/__init__.pyc b/lightwrite/__init__.pyc new file mode 100644 index 0000000..baeea94 Binary files /dev/null and b/lightwrite/__init__.pyc differ diff --git a/lightwrite/local_settings.py b/lightwrite/local_settings.py index 06e2d0f..0b78518 100644 --- a/lightwrite/local_settings.py +++ b/lightwrite/local_settings.py @@ -1,6 +1,12 @@ -MEDIA_ROOT = '/home/tuttle/Projects/LightWrite/static' -SITE_ROOT = '/home/tuttle/Projects/LightWrite/' +#Change these to where you installed light write. Methinks these are sensible defaults + +import os + +home_path = os.getenv("HOME") + +MEDIA_ROOT = '%s/LightWrite/static' % home_path +SITE_ROOT = '%s/LightWrite/' % home_path STATICFILES_DIRS = ( - '/home/tuttle/Projects/LightWrite/static/', + '%s/LightWrite/static/' % home_path, ) diff --git a/lightwrite/local_settings.pyc b/lightwrite/local_settings.pyc new file mode 100644 index 0000000..4c061aa Binary files /dev/null and b/lightwrite/local_settings.pyc differ diff --git a/lightwrite/settings.py b/lightwrite/settings.py index 059c161..9143ead 100644 --- a/lightwrite/settings.py +++ b/lightwrite/settings.py @@ -6,7 +6,7 @@ TEMPLATE_DEBUG = DEBUG ADMINS = ( - # ('Your Name', 'your_email@example.com'), + # ('', ''), ) MANAGERS = ADMINS @@ -163,3 +163,4 @@ except: pass +REDIR = 'w' diff --git a/lightwrite/settings.pyc b/lightwrite/settings.pyc new file mode 100644 index 0000000..8036032 Binary files /dev/null and b/lightwrite/settings.pyc differ diff --git a/lightwrite/templates/.light.html.swp b/lightwrite/templates/.light.html.swp index a8c824f..3f2592b 100644 Binary files a/lightwrite/templates/.light.html.swp and b/lightwrite/templates/.light.html.swp differ diff --git a/lightwrite/templates/light.html b/lightwrite/templates/light.html index 69a39f0..286c712 100644 --- a/lightwrite/templates/light.html +++ b/lightwrite/templates/light.html @@ -4,25 +4,56 @@ + + + + + + + @@ -121,5 +155,6 @@ + diff --git a/lightwrite/text_db b/lightwrite/text_db new file mode 100644 index 0000000..a9574dc Binary files /dev/null and b/lightwrite/text_db differ diff --git a/lightwrite/texts/__init__.pyc b/lightwrite/texts/__init__.pyc new file mode 100644 index 0000000..bc68fa2 Binary files /dev/null and b/lightwrite/texts/__init__.pyc differ diff --git a/lightwrite/texts/models.pyc b/lightwrite/texts/models.pyc new file mode 100644 index 0000000..342cc93 Binary files /dev/null and b/lightwrite/texts/models.pyc differ diff --git a/lightwrite/texts/views.pyc b/lightwrite/texts/views.pyc new file mode 100644 index 0000000..f25819b Binary files /dev/null and b/lightwrite/texts/views.pyc differ diff --git a/lightwrite/urls.py b/lightwrite/urls.py index 1e93464..4266bd3 100644 --- a/lightwrite/urls.py +++ b/lightwrite/urls.py @@ -8,9 +8,9 @@ urlpatterns = patterns('', # Examples: # url(r'^$', 'lightwrite.views.home', name='home'), - url(r'^(?P[a-zA-Z0-9_.-]+)$', 'lightwrite.texts.views.write'), - url(r'^t/(?P[a-zA-Z0-9_.-]+)/$', 'lightwrite.texts.views.json_get_text'), - url(r'^a/about/$', 'lightwrite.texts.views.about'), + url(r'^%s/(?P[a-zA-Z0-9_.-]+)$' % (settings.REDIR), 'lightwrite.texts.views.write'), + url(r'^%s/t/(?P[a-zA-Z0-9_.-]+)/$' % (settings.REDIR), 'lightwrite.texts.views.json_get_text'), + url(r'^%s/a/about/$' % (settings.REDIR), 'lightwrite.texts.views.about'), url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}), url(r'^$', 'lightwrite.texts.views.root'), # Uncomment the admin/doc line below to enable admin documentation: diff --git a/lightwrite/urls.pyc b/lightwrite/urls.pyc new file mode 100644 index 0000000..e4726e5 Binary files /dev/null and b/lightwrite/urls.pyc differ diff --git a/static/ZeroClipboard.js b/static/ZeroClipboard.js new file mode 100755 index 0000000..5adde95 --- /dev/null +++ b/static/ZeroClipboard.js @@ -0,0 +1,311 @@ +// Simple Set Clipboard System +// Author: Joseph Huckaby + +var ZeroClipboard = { + + version: "1.0.7", + clients: {}, // registered upload clients on page, indexed by id + moviePath: 'ZeroClipboard.swf', // URL to movie + nextId: 1, // ID of next movie + + $: function(thingy) { + // simple DOM lookup utility function + if (typeof(thingy) == 'string') thingy = document.getElementById(thingy); + if (!thingy.addClass) { + // extend element with a few useful methods + thingy.hide = function() { this.style.display = 'none'; }; + thingy.show = function() { this.style.display = ''; }; + thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; }; + thingy.removeClass = function(name) { + var classes = this.className.split(/\s+/); + var idx = -1; + for (var k = 0; k < classes.length; k++) { + if (classes[k] == name) { idx = k; k = classes.length; } + } + if (idx > -1) { + classes.splice( idx, 1 ); + this.className = classes.join(' '); + } + return this; + }; + thingy.hasClass = function(name) { + return !!this.className.match( new RegExp("\\s*" + name + "\\s*") ); + }; + } + return thingy; + }, + + setMoviePath: function(path) { + // set path to ZeroClipboard.swf + this.moviePath = path; + }, + + dispatch: function(id, eventName, args) { + // receive event from flash movie, send to client + var client = this.clients[id]; + if (client) { + client.receiveEvent(eventName, args); + } + }, + + register: function(id, client) { + // register new client to receive events + this.clients[id] = client; + }, + + getDOMObjectPosition: function(obj, stopObj) { + // get absolute coordinates for dom element + var info = { + left: 0, + top: 0, + width: obj.width ? obj.width : obj.offsetWidth, + height: obj.height ? obj.height : obj.offsetHeight + }; + + while (obj && (obj != stopObj)) { + info.left += obj.offsetLeft; + info.top += obj.offsetTop; + obj = obj.offsetParent; + } + + return info; + }, + + Client: function(elem) { + // constructor for new simple upload client + this.handlers = {}; + + // unique ID + this.id = ZeroClipboard.nextId++; + this.movieId = 'ZeroClipboardMovie_' + this.id; + + // register client with singleton to receive flash events + ZeroClipboard.register(this.id, this); + + // create movie + if (elem) this.glue(elem); + } +}; + +ZeroClipboard.Client.prototype = { + + id: 0, // unique ID for us + ready: false, // whether movie is ready to receive events or not + movie: null, // reference to movie object + clipText: '', // text to copy to clipboard + handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor + cssEffects: true, // enable CSS mouse effects on dom container + handlers: null, // user event handlers + + glue: function(elem, appendElem, stylesToAdd) { + // glue to DOM element + // elem can be ID or actual DOM element object + this.domElement = ZeroClipboard.$(elem); + + // float just above object, or zIndex 99 if dom element isn't set + var zIndex = 99; + if (this.domElement.style.zIndex) { + zIndex = parseInt(this.domElement.style.zIndex, 10) + 1; + } + + if (typeof(appendElem) == 'string') { + appendElem = ZeroClipboard.$(appendElem); + } + else if (typeof(appendElem) == 'undefined') { + appendElem = document.getElementsByTagName('body')[0]; + } + + // find X/Y position of domElement + var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem); + + // create floating DIV above element + this.div = document.createElement('div'); + var style = this.div.style; + style.position = 'absolute'; + style.left = '' + box.left + 'px'; + style.top = '' + box.top + 'px'; + style.width = '' + box.width + 'px'; + style.height = '' + box.height + 'px'; + style.zIndex = zIndex; + + if (typeof(stylesToAdd) == 'object') { + for (addedStyle in stylesToAdd) { + style[addedStyle] = stylesToAdd[addedStyle]; + } + } + + // style.backgroundColor = '#f00'; // debug + + appendElem.appendChild(this.div); + + this.div.innerHTML = this.getHTML( box.width, box.height ); + }, + + getHTML: function(width, height) { + // return HTML for movie + var html = ''; + var flashvars = 'id=' + this.id + + '&width=' + width + + '&height=' + height; + + if (navigator.userAgent.match(/MSIE/)) { + // IE gets an OBJECT tag + var protocol = location.href.match(/^https/i) ? 'https://' : 'http://'; + html += ''; + } + else { + // all other browsers get an EMBED tag + html += ''; + } + return html; + }, + + hide: function() { + // temporarily hide floater offscreen + if (this.div) { + this.div.style.left = '-2000px'; + } + }, + + show: function() { + // show ourselves after a call to hide() + this.reposition(); + }, + + destroy: function() { + // destroy control and floater + if (this.domElement && this.div) { + this.hide(); + this.div.innerHTML = ''; + + var body = document.getElementsByTagName('body')[0]; + try { body.removeChild( this.div ); } catch(e) {;} + + this.domElement = null; + this.div = null; + } + }, + + reposition: function(elem) { + // reposition our floating div, optionally to new container + // warning: container CANNOT change size, only position + if (elem) { + this.domElement = ZeroClipboard.$(elem); + if (!this.domElement) this.hide(); + } + + if (this.domElement && this.div) { + var box = ZeroClipboard.getDOMObjectPosition(this.domElement); + var style = this.div.style; + style.left = '' + box.left + 'px'; + style.top = '' + box.top + 'px'; + } + }, + + setText: function(newText) { + // set text to be copied to clipboard + this.clipText = newText; + if (this.ready) this.movie.setText(newText); + }, + + addEventListener: function(eventName, func) { + // add user event listener for event + // event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel + eventName = eventName.toString().toLowerCase().replace(/^on/, ''); + if (!this.handlers[eventName]) this.handlers[eventName] = []; + this.handlers[eventName].push(func); + }, + + setHandCursor: function(enabled) { + // enable hand cursor (true), or default arrow cursor (false) + this.handCursorEnabled = enabled; + if (this.ready) this.movie.setHandCursor(enabled); + }, + + setCSSEffects: function(enabled) { + // enable or disable CSS effects on DOM container + this.cssEffects = !!enabled; + }, + + receiveEvent: function(eventName, args) { + // receive event from flash + eventName = eventName.toString().toLowerCase().replace(/^on/, ''); + + // special behavior for certain events + switch (eventName) { + case 'load': + // movie claims it is ready, but in IE this isn't always the case... + // bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function + this.movie = document.getElementById(this.movieId); + if (!this.movie) { + var self = this; + setTimeout( function() { self.receiveEvent('load', null); }, 1 ); + return; + } + + // firefox on pc needs a "kick" in order to set these in certain cases + if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { + var self = this; + setTimeout( function() { self.receiveEvent('load', null); }, 100 ); + this.ready = true; + return; + } + + this.ready = true; + this.movie.setText( this.clipText ); + this.movie.setHandCursor( this.handCursorEnabled ); + break; + + case 'mouseover': + if (this.domElement && this.cssEffects) { + this.domElement.addClass('hover'); + if (this.recoverActive) this.domElement.addClass('active'); + } + break; + + case 'mouseout': + if (this.domElement && this.cssEffects) { + this.recoverActive = false; + if (this.domElement.hasClass('active')) { + this.domElement.removeClass('active'); + this.recoverActive = true; + } + this.domElement.removeClass('hover'); + } + break; + + case 'mousedown': + if (this.domElement && this.cssEffects) { + this.domElement.addClass('active'); + } + break; + + case 'mouseup': + if (this.domElement && this.cssEffects) { + this.domElement.removeClass('active'); + this.recoverActive = false; + } + break; + } // switch eventName + + if (this.handlers[eventName]) { + for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) { + var func = this.handlers[eventName][idx]; + + if (typeof(func) == 'function') { + // actual function reference + func(this, args); + } + else if ((typeof(func) == 'object') && (func.length == 2)) { + // PHP style object + method, i.e. [myObject, 'myMethod'] + func[0][ func[1] ](this, args); + } + else if (typeof(func) == 'string') { + // name of function + window[func](this, args); + } + } // foreach event handler defined + } // user defined handler for event + } + +}; diff --git a/static/ZeroClipboard.swf b/static/ZeroClipboard.swf new file mode 100755 index 0000000..13bf8e3 Binary files /dev/null and b/static/ZeroClipboard.swf differ diff --git a/static/clippy.swf b/static/clippy.swf deleted file mode 100644 index e46886c..0000000 Binary files a/static/clippy.swf and /dev/null differ diff --git a/static/copyButtons/button_down.png b/static/copyButtons/button_down.png new file mode 100644 index 0000000..f50823f Binary files /dev/null and b/static/copyButtons/button_down.png differ diff --git a/static/copyButtons/button_over.png b/static/copyButtons/button_over.png new file mode 100644 index 0000000..4183363 Binary files /dev/null and b/static/copyButtons/button_over.png differ diff --git a/static/copyButtons/button_up.png b/static/copyButtons/button_up.png new file mode 100644 index 0000000..fd238e3 Binary files /dev/null and b/static/copyButtons/button_up.png differ