Browse Source

Updated web interface

Pierre-Olivier Latour 11 years ago
parent
commit
df95ecb1c2

+ 0 - 4
GCDWebUploader/GCDWebUploader.bundle/css/index.css

@@ -25,10 +25,6 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-.header {
-  color: #222;
-}
-
 .row-file {
   height: 40px;
 }

+ 3 - 3
GCDWebUploader/GCDWebUploader.bundle/en.lproj/Localizable.strings

@@ -1,3 +1,3 @@
-"TITLE" = "%@";
-"HEADER" = "Drag & drop files on this window or use the \"Upload Files…\" button to upload new files.";
-"FOOTER" = "%@ %@";
+"PROLOGUE" = "<p>Drag &amp; drop files on this window or use the \"Upload Files&hellip;\" button to upload new files.</p>";
+"EPILOGUE" = "";
+"FOOTER_FORMAT" = "%@ %@";

+ 4 - 2
GCDWebUploader/GCDWebUploader.bundle/index.html

@@ -57,10 +57,10 @@
     <div class="container">
       
       <div class="page-header">
-        <h1>%title%</h1>
+        <h1>%header%</h1>
       </div>
       
-      <p class="header">%header%</p>
+      %prologue%
       
       <div id="alerts"></div>
       
@@ -89,6 +89,8 @@
         <table class="table table-striped"><tbody id="listing"></tbody></table>
       </div>
       
+      %epilogue%
+      
       <p class="footer">%footer%</p>
       
     </div>

+ 5 - 3
GCDWebUploader/GCDWebUploader.h

@@ -43,9 +43,11 @@
 @property(nonatomic, assign) id<GCDWebUploaderDelegate> delegate;
 @property(nonatomic, copy) NSArray* allowedFileExtensions;  // Default is nil i.e. all file extensions are allowed
 @property(nonatomic) BOOL showHiddenFiles;  // Default is NO
-@property(nonatomic, copy) NSString* title;  // Default is application name (text must be HTML escaped)
-@property(nonatomic, copy) NSString* header;  // Default is help blurb (text must be HTML escaped)
-@property(nonatomic, copy) NSString* footer;  // Default is application name and version (text must be HTML escaped)
+@property(nonatomic, copy) NSString* title;  // Default is application name (must be HTML escaped)
+@property(nonatomic, copy) NSString* header;  // Default is same as title (must be HTML escaped)
+@property(nonatomic, copy) NSString* prologue;  // Default is mini help (must be raw HTML)
+@property(nonatomic, copy) NSString* epilogue;  // Default is mini help (must be raw HTML)
+@property(nonatomic, copy) NSString* footer;  // Default is application name and version (must be HTML escaped)
 - (id)initWithUploadDirectory:(NSString*)path;
 @end
 

+ 26 - 12
GCDWebUploader/GCDWebUploader.m

@@ -42,13 +42,16 @@
   BOOL _showHidden;
   NSString* _title;
   NSString* _header;
+  NSString* _prologue;
+  NSString* _epilogue;
   NSString* _footer;
 }
 @end
 
 @implementation GCDWebUploader
 
-@synthesize uploadDirectory=_uploadDirectory, delegate=_delegate, allowedFileExtensions=_allowedExtensions, showHiddenFiles=_showHidden, title=_title, header=_header, footer=_footer;
+@synthesize uploadDirectory=_uploadDirectory, delegate=_delegate, allowedFileExtensions=_allowedExtensions, showHiddenFiles=_showHidden,
+            title=_title, header=_header, prologue=_prologue, epilogue=_epilogue, footer=_footer;
 
 - (BOOL)_checkFileExtension:(NSString*)fileName {
   if (_allowedExtensions && ![_allowedExtensions containsObject:[[fileName pathExtension] lowercaseString]]) {
@@ -93,15 +96,6 @@
     // Web page
     [self addHandlerForMethod:@"GET" path:@"/" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
       
-      NSString* title = uploader.title;
-      if (title == nil) {
-        title = [NSString stringWithFormat:[siteBundle localizedStringForKey:@"TITLE" value:@"" table:nil],
-                 [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
-      }
-      NSString* header = uploader.header;
-      if (header == nil) {
-        header = [siteBundle localizedStringForKey:@"HEADER" value:@"" table:nil];
-      }
 #if TARGET_OS_IPHONE
       NSString* device = [[UIDevice currentDevice] name];
 #else
@@ -111,17 +105,35 @@
       NSString* device = [(id)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease];
 #endif
 #endif
+      NSString* title = uploader.title;
+      if (title == nil) {
+        title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
+      }
+      NSString* header = uploader.header;
+      if (header == nil) {
+        header = title;
+      }
+      NSString* prologue = uploader.prologue;
+      if (prologue == nil) {
+        prologue = [siteBundle localizedStringForKey:@"PROLOGUE" value:@"" table:nil];
+      }
+      NSString* epilogue = uploader.epilogue;
+      if (epilogue == nil) {
+        epilogue = [siteBundle localizedStringForKey:@"EPILOGUE" value:@"" table:nil];
+      }
       NSString* footer = uploader.footer;
       if (footer == nil) {
-        footer = [NSString stringWithFormat:[siteBundle localizedStringForKey:@"FOOTER" value:@"" table:nil],
+        footer = [NSString stringWithFormat:[siteBundle localizedStringForKey:@"FOOTER_FORMAT" value:@"" table:nil],
                   [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
                   [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
       }
       return [GCDWebServerDataResponse responseWithHTMLTemplate:[siteBundle pathForResource:@"index" ofType:@"html"]
                                                       variables:@{
+                                                                  @"device": device,
                                                                   @"title": title,
                                                                   @"header": header,
-                                                                  @"device": device,
+                                                                  @"prologue": prologue,
+                                                                  @"epilogue": epilogue,
                                                                   @"footer": footer
                                                                   }];
       
@@ -322,6 +334,8 @@
   [_allowedExtensions release];
   [_title release];
   [_header release];
+  [_prologue release];
+  [_epilogue release];
   [_footer release];
   
   [super dealloc];