Updated web interface
This commit is contained in:
@ -25,10 +25,6 @@
|
|||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.header {
|
|
||||||
color: #222;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row-file {
|
.row-file {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
"TITLE" = "%@";
|
"PROLOGUE" = "<p>Drag & drop files on this window or use the \"Upload Files…\" button to upload new files.</p>";
|
||||||
"HEADER" = "Drag & drop files on this window or use the \"Upload Files…\" button to upload new files.";
|
"EPILOGUE" = "";
|
||||||
"FOOTER" = "%@ %@";
|
"FOOTER_FORMAT" = "%@ %@";
|
||||||
|
|||||||
@ -57,10 +57,10 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>%title%</h1>
|
<h1>%header%</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="header">%header%</p>
|
%prologue%
|
||||||
|
|
||||||
<div id="alerts"></div>
|
<div id="alerts"></div>
|
||||||
|
|
||||||
@ -89,6 +89,8 @@
|
|||||||
<table class="table table-striped"><tbody id="listing"></tbody></table>
|
<table class="table table-striped"><tbody id="listing"></tbody></table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
%epilogue%
|
||||||
|
|
||||||
<p class="footer">%footer%</p>
|
<p class="footer">%footer%</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -43,9 +43,11 @@
|
|||||||
@property(nonatomic, assign) id<GCDWebUploaderDelegate> delegate;
|
@property(nonatomic, assign) id<GCDWebUploaderDelegate> delegate;
|
||||||
@property(nonatomic, copy) NSArray* allowedFileExtensions; // Default is nil i.e. all file extensions are allowed
|
@property(nonatomic, copy) NSArray* allowedFileExtensions; // Default is nil i.e. all file extensions are allowed
|
||||||
@property(nonatomic) BOOL showHiddenFiles; // Default is NO
|
@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* title; // Default is application name (must be HTML escaped)
|
||||||
@property(nonatomic, copy) NSString* header; // Default is help blurb (text must be HTML escaped)
|
@property(nonatomic, copy) NSString* header; // Default is same as title (must be HTML escaped)
|
||||||
@property(nonatomic, copy) NSString* footer; // Default is application name and version (text 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;
|
- (id)initWithUploadDirectory:(NSString*)path;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -42,13 +42,16 @@
|
|||||||
BOOL _showHidden;
|
BOOL _showHidden;
|
||||||
NSString* _title;
|
NSString* _title;
|
||||||
NSString* _header;
|
NSString* _header;
|
||||||
|
NSString* _prologue;
|
||||||
|
NSString* _epilogue;
|
||||||
NSString* _footer;
|
NSString* _footer;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GCDWebUploader
|
@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 {
|
- (BOOL)_checkFileExtension:(NSString*)fileName {
|
||||||
if (_allowedExtensions && ![_allowedExtensions containsObject:[[fileName pathExtension] lowercaseString]]) {
|
if (_allowedExtensions && ![_allowedExtensions containsObject:[[fileName pathExtension] lowercaseString]]) {
|
||||||
@ -93,15 +96,6 @@
|
|||||||
// Web page
|
// Web page
|
||||||
[self addHandlerForMethod:@"GET" path:@"/" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
|
[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
|
#if TARGET_OS_IPHONE
|
||||||
NSString* device = [[UIDevice currentDevice] name];
|
NSString* device = [[UIDevice currentDevice] name];
|
||||||
#else
|
#else
|
||||||
@ -111,17 +105,35 @@
|
|||||||
NSString* device = [(id)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease];
|
NSString* device = [(id)SCDynamicStoreCopyComputerName(NULL, NULL) autorelease];
|
||||||
#endif
|
#endif
|
||||||
#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;
|
NSString* footer = uploader.footer;
|
||||||
if (footer == nil) {
|
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:@"CFBundleDisplayName"],
|
||||||
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
|
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
|
||||||
}
|
}
|
||||||
return [GCDWebServerDataResponse responseWithHTMLTemplate:[siteBundle pathForResource:@"index" ofType:@"html"]
|
return [GCDWebServerDataResponse responseWithHTMLTemplate:[siteBundle pathForResource:@"index" ofType:@"html"]
|
||||||
variables:@{
|
variables:@{
|
||||||
|
@"device": device,
|
||||||
@"title": title,
|
@"title": title,
|
||||||
@"header": header,
|
@"header": header,
|
||||||
@"device": device,
|
@"prologue": prologue,
|
||||||
|
@"epilogue": epilogue,
|
||||||
@"footer": footer
|
@"footer": footer
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@ -322,6 +334,8 @@
|
|||||||
[_allowedExtensions release];
|
[_allowedExtensions release];
|
||||||
[_title release];
|
[_title release];
|
||||||
[_header release];
|
[_header release];
|
||||||
|
[_prologue release];
|
||||||
|
[_epilogue release];
|
||||||
[_footer release];
|
[_footer release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
|||||||
Reference in New Issue
Block a user