Skip to content

Commit

Permalink
Merge pull request #17 from kabukky/development
Browse files Browse the repository at this point in the history
Fixed: Image path creation in Windows and no image selector in Chrome.
Closes #16
  • Loading branch information
kabukky committed Apr 26, 2015
2 parents 68f8b2f + 6f89e83 commit 83eb990
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion built-in/admin/post-options-modal.tpl
Expand Up @@ -13,7 +13,7 @@
<div class="form-group">
<label for="post-cover" class="col-sm-2 control-label">Cover</label>
<div class="col-sm-10">
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'post-cover')"><img class="img-settings img-thumbnail img-settings" id="post-cover" src="{{shared.post.Image}}" alt="{{shared.post.Image}}" /></a> <a class="text-danger" id="post-cover-delete" ng-controller="EmptyModalCtrl" ng-click="deleteCover()"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a>
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'post-cover')"><img class="img-settings img-thumbnail img-settings" id="post-cover" src="{{shared.post.Image}}" alt="{{shared.post.Image}}" ng-if="shared.post.Image!=''" /><img class="img-settings img-thumbnail img-settings" id="post-cover" src="/public/images/no-image.png" alt="No image" ng-if="shared.post.Image==''" /></a> <a class="text-danger" id="post-cover-delete" ng-controller="EmptyModalCtrl" ng-click="deleteCover()"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a>
</div>
</div>
<div class="form-group">
Expand Down
8 changes: 4 additions & 4 deletions built-in/admin/settings.html
Expand Up @@ -33,13 +33,13 @@ <h1>Blog</h1>
<div class="form-group">
<label for="blog-logo" class="col-sm-2 control-label">Logo</label>
<div class="col-sm-10">
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'blog-logo')"><img class="img-settings img-thumbnail img-settings" id="blog-logo" src="{{shared.blog.Logo}}" alt="{{shared.blog.Logo}}" /></a>
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'blog-logo')"><img class="img-settings img-thumbnail img-settings" id="blog-logo" src="{{shared.blog.Logo}}" alt="{{shared.blog.Logo}}" ng-if="shared.blog.Logo!=''" /><img class="img-settings img-thumbnail img-settings" id="blog-logo" src="/public/images/no-image.png" alt="No image" ng-if="shared.blog.Logo==''" /></a>
</div>
</div>
<div class="form-group">
<label for="blog-cover" class="col-sm-2 control-label">Cover</label>
<div class="col-sm-10">
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'blog-cover')"><img class="img-settings img-thumbnail img-settings" id="blog-cover" src="{{shared.blog.Cover}}" alt="{{shared.blog.Cover}}" /></a>
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'blog-cover')"><img class="img-settings img-thumbnail img-settings" id="blog-cover" src="{{shared.blog.Cover}}" alt="{{shared.blog.Cover}}" ng-if="shared.blog.Cover!=''" /><img class="img-settings img-thumbnail img-settings" id="blog-cover" src="/public/images/no-image.png" alt="No image" ng-if="shared.blog.Cover==''" /></a>
</div>
</div>
<div class="form-group">
Expand All @@ -62,13 +62,13 @@ <h1>User {{shared.user.Name}}</h1>
<div class="form-group">
<label for="user-image" class="col-sm-2 control-label">Avatar</label>
<div class="col-sm-10">
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'user-image')"><img class="img-settings img-thumbnail img-settings" id="user-image" src="{{shared.user.Image}}" alt="{{shared.user.Image}}" /></a>
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'user-image')"><img class="img-settings img-thumbnail img-settings" id="user-image" src="{{shared.user.Image}}" alt="{{shared.user.Image}}" ng-if="shared.user.Image!=''" /><img class="img-settings img-thumbnail img-settings" id="user-image" src="/public/images/no-image.png" alt="No image" ng-if="shared.user.Image==''" /></a>
</div>
</div>
<div class="form-group">
<label for="user-cover" class="col-sm-2 control-label">Cover</label>
<div class="col-sm-10">
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'user-cover')"><img class="img-settings img-thumbnail img-settings" id="user-cover" src="{{shared.user.Cover}}" alt="{{shared.user.Cover}}" /></a>
<a ng-controller="ImageModalCtrl" ng-click="open('lg', 'user-cover')"><img class="img-settings img-thumbnail img-settings" id="user-cover" src="{{shared.user.Cover}}" alt="{{shared.user.Cover}}" ng-if="shared.user.Cover!=''" /><img class="img-settings img-thumbnail img-settings" id="user-cover" src="/public/images/no-image.png" alt="No image" ng-if="shared.user.Cover==''" /></a>
</div>
</div>
<div class="form-group">
Expand Down
Binary file added built-in/public/images/no-image.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion server/admin.go
Expand Up @@ -365,7 +365,11 @@ func apiUploadHandler(w http.ResponseWriter, r *http.Request, _ map[string]strin
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
allFilePaths = append(allFilePaths, strings.Replace(dst.Name(), filenames.ContentFilepath, "", 1))
// Rewrite to file path on server
filePath = strings.Replace(dst.Name(), filenames.ImagesFilepath, "/images", 1)
// Make sure to always use "/" as path separator (to make a valid url that we can use on the blog)
filePath = filepath.ToSlash(filePath)
allFilePaths = append(allFilePaths, filePath)
}
json, err := json.Marshal(allFilePaths)
if err != nil {
Expand Down Expand Up @@ -397,6 +401,8 @@ func apiImagesHandler(w http.ResponseWriter, r *http.Request, params map[string]
if !info.IsDir() && (strings.EqualFold(filepath.Ext(filePath), ".jpg") || strings.EqualFold(filepath.Ext(filePath), ".jpeg") || strings.EqualFold(filepath.Ext(filePath), ".gif") || strings.EqualFold(filepath.Ext(filePath), ".png") || strings.EqualFold(filepath.Ext(filePath), ".svg")) {
// Rewrite to file path on server
filePath = strings.Replace(filePath, filenames.ImagesFilepath, "/images", 1)
// Make sure to always use "/" as path separator (to make a valid url that we can use on the blog)
filePath = filepath.ToSlash(filePath)
// Prepend file to slice (thus reversing the order)
images = append([]string{filePath}, images...)
}
Expand Down
2 changes: 1 addition & 1 deletion watcher/watcher.go
Expand Up @@ -68,7 +68,7 @@ func createWatcher(extensionsFunctions map[string]func() error) (*fsnotify.Watch
}
}
case err := <-watcher.Errors:
log.Println("Error while watching theme directory.", err)
log.Println("Error while watching directory:", err)
}
}
}()
Expand Down

0 comments on commit 83eb990

Please sign in to comment.