mirror of
https://github.com/swisspol/GCDWebServer.git
synced 2026-04-24 00:00:04 +08:00
Updated web interface
This commit is contained in:
@@ -25,10 +25,6 @@
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.header {
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.row-file {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
@@ -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 & drop files on this window or use the \"Upload Files…\" button to upload new files.</p>";
|
||||
"EPILOGUE" = "";
|
||||
"FOOTER_FORMAT" = "%@ %@";
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user