Commits

Michael Granger committed 494fc9a

More DND upload fixes/display tweaks

Comments (0)

Files changed (7)

+ChangeLog
 History.md
 LICENSE
 README.md
 Rakefile
 bin/gemserver
 data/gemserver/gemserver.conf.example
+data/gemserver/public/css/jquery.fileupload-ui.css
 data/gemserver/public/css/master.css
+data/gemserver/public/css/overcast/images/ui-bg_flat_0_aaaaaa_40x100.png
+data/gemserver/public/css/overcast/images/ui-bg_flat_0_eeeeee_40x100.png
+data/gemserver/public/css/overcast/images/ui-bg_flat_55_c0402a_40x100.png
+data/gemserver/public/css/overcast/images/ui-bg_flat_55_eeeeee_40x100.png
+data/gemserver/public/css/overcast/images/ui-bg_glass_100_f8f8f8_1x400.png
+data/gemserver/public/css/overcast/images/ui-bg_glass_35_dddddd_1x400.png
+data/gemserver/public/css/overcast/images/ui-bg_glass_60_eeeeee_1x400.png
+data/gemserver/public/css/overcast/images/ui-bg_inset-hard_75_999999_1x100.png
+data/gemserver/public/css/overcast/images/ui-bg_inset-soft_50_c9c9c9_1x100.png
+data/gemserver/public/css/overcast/images/ui-icons_3383bb_256x240.png
+data/gemserver/public/css/overcast/images/ui-icons_454545_256x240.png
+data/gemserver/public/css/overcast/images/ui-icons_70b2e1_256x240.png
+data/gemserver/public/css/overcast/images/ui-icons_999999_256x240.png
+data/gemserver/public/css/overcast/images/ui-icons_fbc856_256x240.png
+data/gemserver/public/css/overcast/jquery-ui-1.8.9.custom.css
 data/gemserver/public/images/favicon.ico
+data/gemserver/public/images/pbar-ani.gif
 data/gemserver/public/images/upload-arrow.png
 data/gemserver/public/js/gemserver.js
-data/gemserver/public/js/jquery-1.4.2.min.js
-data/gemserver/public/js/jquery.filedrop.js
-data/gemserver/public/js/jquery.tools-1.2.3.min.js
+data/gemserver/public/js/jquery-1.4.4.min.js
+data/gemserver/public/js/jquery-ui-1.8.9.custom.min.js
+data/gemserver/public/js/jquery.fileupload-ui.js
+data/gemserver/public/js/jquery.fileupload.js
 data/gemserver/views/details.erb
 data/gemserver/views/index.erb
 data/gemserver/views/layout.erb
 lib/gemserver/app.rb
 lib/gemserver/authentication.rb
 lib/gemserver/keystore.rb
+lib/gemserver/mixins.rb
+spec/gemserver/app_spec.rb
+spec/gemserver/keystore_spec.rb
+spec/gemserver/mixins_spec.rb
 spec/gemserver_spec.rb
 spec/lib/helpers.rb

data/gemserver/public/css/master.css

  *
  */
 
-@import url(overcast/jquery-ui-1.8.9.custom.css);
+/*@import url(overcast/jquery-ui-1.8.9.custom.css);*/
 
 /* @group Entity styles */
 
 }
 
 body > footer {
+	color: #888;
+	clear: both;
 	font-size: 0.8em;
 	margin: 0;
-	position: absolute;
-	bottom: 1em;
-	width: 95%;
+	position: relative;
+	margin-top: 3em;
 }
 
 body > footer p {
 	border-radius: 1em
 }
 
+section#upload p {
+	text-align: center;
+	font-size: 0.9em;
+	color: #666;
+	margin-bottom: 0;
+}
 section#upload label {
 	color: #666;
 	font-size: 1.2em;
 	padding: 0 0.5em;
 }
+
 section#upload input[type=file] {
 	background: #eee;
 	border-radius: 1em;
 	width: 60%;
 }
 
+button,
 section#upload input[type=submit] {
 	-moz-border-radius: 5px;
 	-webkit-border-radius: 5px;
 
 }
 
+button:hover,
 section#upload input[type=submit]:hover {
 	background:rgba(240,240,240,1);
 	background: -webkit-gradient( linear,
 	);
 }
 
-button:active, button:focus {
+button:active,
+button:focus,
+section#upload input[type=submit]:active,
+section#upload input[type=submit]:focus {
 	background: -webkit-gradient( linear,
 		0% 100%, 
 		0% 0%,
 	);
 }
 
-button:disabled {
+button:disabled,
+section#upload input[type=submit]:disabled {
 	color:rgba(0,0,0,0.4);
 	text-shadow:1px 1px 0px rgba(255,255,255,0.5);
 	background:rgba(220,220,220,1);
 }
 
-section#upload.targeted {
+section#upload table.uploads {
+	display: none;
+	background: #eee;
+	width: 80%;
+	font-size: 0.8em;
+}
+section#upload.uploading table.uploads {
 	display: block;
 }
-
-section#upload.uploading {
-	display: block;
+section#upload table.uploads tbody {
+	padding: 0;
+}
+section#upload table.uploads td {
+	padding: 0 4px;
+}
+section#upload table.uploads td.cancel {
+	width: 10%;
 }
 
 #dropzone {
 	display: none;
 	position: absolute;
 	top: 35%;
-	left: 35%%;
+	left: 35%;
 	opacity: 0.5;
 	border: 3px dashed rgba( 85,85,85, 0.4 );
 	border-radius: 35px;
 		rgba(25,25,25, 0.25));
 }
 
+#dropzone.dragging {
+	display: block;
+}
+
 #dropzone.targeted {
 	opacity: 1.0;
 }
 	display: none;
 }
 
-section#upload .progress-bar {
-	color: white;
-	text-shadow: 0px 0px 2px #333;
-	position: relative;
-	font-size: 10px;
-	vertical-align: top;
-	width: 300px;
-	height: 14px;
-	background-color: rgba(240, 240, 240, 0.9);
-	margin: 2px auto;
-	border: 1px solid #999;
-	-webkit-box-shadow: 1px 1px 3px rgba( 25,25,25, 0.5 );
-}
-
-.progress-bar-progress {
-	background-color: #6c8c22;
-	background-image: -webkit-gradient( linear, 0 0, 0 100%,
-		color-stop( 0.0, rgba(255,255,255, 0.25) ),
-		color-stop( 0.4, rgba(  0,  0,  0, 0.35) ),
-		color-stop( 1.0, rgba(255,255,255, 0.15) )
-	 );
-	background-image: -moz-linear-gradient( -90deg,
-		rgba(255,255,255, 0.15),
-		rgba(  0,  0,  0, 0.35) 40%,
-		rgba(255,255,255, 0.15)
-	 );
-	width: 0%;
-	height: 12px;
-	margin: 1px 0px;
-}
-
-.progress-bar-filename {
-	position: absolute;
-	top: -3px;
-	left: 1em;
-}
-
-.progress-bar-percent {
-	position: absolute;
-	top: -3px;
-	left: 140px;
-}
-
-.progress-bar-speed {
-	position: absolute;
-	top: -3px;
-	right: 1em;
-}
 
 aside#error-notice {
 	position: absolute;

data/gemserver/public/js/gemserver.js

         window.console[names[i]] = function() {};
 }
 
+function on_upload_docenter( event ) {
+	EnterCounter.doc += 1;
+	console.debug( "DocEnter event (%d): %o", EnterCounter.doc, event );
+	$('#dropzone').addClass('dragging');
+}
+
+function on_upload_docleave( event ) {
+	EnterCounter.doc -= 1;
+	console.debug( "DocLeave event (%d): %o", EnterCounter.doc, event );
+	if ( EnterCounter.doc == 0 )
+		$('#upload').removeClass('dragging');
+}
+
 function on_upload_dragenter( event ) {
 	EnterCounter.drag += 1;
 	console.debug( "DragEnter event (%d): %o", EnterCounter.drag, event );
 		$('#dropzone').removeClass('targeted');
 }
 
-function on_upload_docenter( event ) {
-	EnterCounter.doc += 1;
-	console.debug( "DocEnter event (%d): %o", EnterCounter.doc, event );
-	$('#dropzone').addClass('dragging');
-}
-
-function on_upload_docleave( event ) {
-	EnterCounter.doc -= 1;
-	console.debug( "DocLeave event (%d): %o", EnterCounter.doc, event );
-	if ( EnterCounter.doc == 0 )
-		$('#upload').removeClass('dragging');
-}
-
 function on_upload_drop( event ) {
 	console.debug( "Drop event: %o", event );
 	$('#upload').addClass('uploading');
 function build_upload_row( files, index ) {
 	var file = files[ index ];
 	var tmpl = Templates.upload_row.clone();
-	console.debug( "Building an upload row for file %d of %d: %d", files.length, index, file.name );
+	console.debug( "Building an upload row for file %d of %d: %s",
+		index + 1, files.length, file.name );
 
 	tmpl.find( '.filename' ).html( file.name );
+	console.debug( "Returning row: %o", tmpl );
 
 	return tmpl;
 }
 	return typeof FileReader != 'undefined';
 }
 
+
+/**
+ * Callback for 'beforeSend' event.
+ */
+function on_before_send( event, files, index, xhr, handler, callBack ) {
+	var file = files[ index ];
+
+	if ( UploadCounter === 0 )
+		console.group( "Upload (%d files)", files.length );
+
+	console.debug( "Upload started for %s (%d of %d dropped)", file.name, index+1, files.length );
+	UploadCounter++;
+
+	$('#upload').addClass( 'uploading' );
+
+    return callBack();
+}
+
+
+/**
+ * Callback for the 'onComplete' event.
+ */
+function on_complete( event, files, index, xhr, handler ) {
+	var file = files[ index ];
+
+	console.debug( "Finished uploading %s", file.name );
+	UploadCounter--;
+
+	handler.progressbar.fadeOut( function() {$(this).remove();} );
+	if ( UploadCounter === 0 ) {
+		console.groupEnd();
+		$( '#main' ).load( '/gems' );
+		$('#upload').removeClass( 'uploading' );
+	}
+}
+
+
 function hook_fileupload() {
 	console.debug( "hooking fileupload" );
 
 		onDocumentDragLeave: on_upload_docleave,
 		onDragEnter: on_upload_dragenter,
 		onDragLeave: on_upload_dragleave,
-		onDrop: on_upload_drop
+		beforeSend: on_before_send,
+		onComplete: on_complete
     });
 
+}
+
+function set_upload_instructions() {
 	if ( hasDragAndDrop() && hasFileAPI() ) {
 		console.debug( "  has drag-and-drop and the File API" );
 		$('#upload p').
 	}
 }
 
-
 function handle_ajax_error( event, xhr, opts, err ) {
 	console.error( "AJAX error: %o", err );
 	$('#error-notice').
 
 function extract_templates() {
 	Templates.upload_row = $('#upload table.uploads tr.upload-row').remove();
+	// Templates.upload_row = $('#upload table.uploads tr.upload-row').clone();
 }
 
 $(document).ready( function() {
 	extract_templates();
 	hook_fileupload();
+	set_upload_instructions();
 	$('#error-notice').ajaxError( handle_ajax_error );
 });
 

data/gemserver/views/index.erb

 		<input type="submit" value="Upload &rarr;" id="gem-upload-button" />
 	</form>
 
-	<div id="upload-progress">
-	</div>
+	<p>Select one or more gems to upload.</p>
+
+	<table class="uploads">
+	<tbody>
+		<tr class="upload-row">
+			<td class="filename">filename-1.0.8.gem</td>
+			<td class="progress"></td>
+			<td class="cancel">Cancel</td>
+		</tr>
+	</tbody>
+	</table>
 </section>
 

data/gemserver/views/layout.erb

 
 	<footer>
 		<p>
-			<span class="name">Gemserver</span>
+			<span class="name"><%= Gemserver.version_string %></span>
 			<span class="vcsrev">$Revision$</span>
 		</p>
 	</footer>
 
 
 	# Software version
-	VERSION = '0.2.0'
+	VERSION = '0.3.0'
+
+	# Software revision
+	REVISION = %q$Revision$
 
 	# The path to the gemserver's data directory
 	SYSTEM_DATADIR = Pathname( Gem.datadir('gemserver') || 'data/gemserver' )
 	LOG_LEVEL_NAMES = LOG_LEVELS.invert.freeze
 
 
+	### 
+	class UploadFailed < RuntimeError
+		
+	end
+
+
 	# Rack configuration values
 	@host = DEFAULT_HOST
 	@port = DEFAULT_PORT
 	require 'gemserver/keystore'
 
 
+	### Get the Gemserver version.
+	### @return [String] the library's version
+	def self::version_string( include_buildnum=false )
+		vstring = "%s %s" % [ self.name, VERSION ]
+		vstring << " (build %s)" % [ REVISION[/: ([[:xdigit:]]+)/, 1] || '0' ] if include_buildnum
+		return vstring
+	end
+
+
 	### Load the configuration and install it
 	def self::load_config( *args )
 		configfile = args.flatten.shift || self.find_standard_config
 
 	### Find the config file in a standard path and return it.
 	### @return [Pathname] the path to the config, or nil if it wasn't in any of the 
-	### standard places.
+	###     standard places.
 	def self::find_standard_config
 		self.log.debug "Looking for a standard config."
 		bindir  = Pathname( $0 ).dirname

lib/gemserver/app.rb

 require 'gemserver/keystore'
 
 
-include ERB::Util
-
+### The Gemserver application object
 class Gemserver::App < Sinatra::Base
 	extend Configurability
-	include Gemserver::Authentication,
+	include ERB::Util,
+	        Gemserver::Authentication,
 	        Gemserver::Loggable
 
 	# Configurability API -- register for the 'gemserver' section of the config
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.