-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: image uploading from gravatar (#52)
- Loading branch information
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
;; Author: Artur Yaroshenko <[email protected]> | ||
;; URL: https://github.com/artawower/blamer.el | ||
;; Package-Requires: ((emacs "27.1") (posframe "1.1.7")) | ||
;; Version: 0.7.2 | ||
;; Version: 0.7.3 | ||
|
||
;; This program is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
|
@@ -222,7 +222,7 @@ Each element is a cons cell (REGEXP . FUNCTION)." | |
:type 'list) | ||
|
||
(defcustom blamer-fallback-avatar-config | ||
'("http://www.gravatar.com/avatar" blamer--fallback-avatar-uploader) | ||
'("https://www.gravatar.com/avatar" blamer--fallback-avatar-uploader) | ||
"Fallback avatar config." | ||
:group 'blamer | ||
:type 'list) | ||
|
@@ -598,15 +598,24 @@ REMOTE-URL - url of resource to download avatar." | |
(avatar-url (gethash "avatar_url" json-data))) | ||
(blamer--upload-avatar avatar-url file-path))) | ||
|
||
(defun blamer--normalize-file-path (file-path) | ||
"Normalize FILE-PATH for Windows." | ||
(setq file-path (replace-regexp-in-string ">" "" file-path)) | ||
(setq file-path (replace-regexp-in-string " " "-" file-path)) | ||
(setq file-path (replace-regexp-in-string "<" "" file-path)) | ||
file-path) | ||
|
||
(defun blamer--upload-avatar (url file-path) | ||
"Download the avatar from URL and save it to the path as FILE-PATH. | ||
HOST-NAME is the name of the host for caching. | ||
host folder. | ||
If the file already exists, return the path to the existing file." | ||
(unless (file-exists-p (file-name-directory file-path)) | ||
(make-directory (file-name-directory file-path) t)) | ||
(url-copy-file url file-path t) | ||
file-path) | ||
(setq file-path (blamer--normalize-file-path file-path)) | ||
(ignore-errors | ||
(url-copy-file url file-path t) | ||
file-path)) | ||
|
||
|
||
(defun blamer--find-avatar-uploader (remote-ref) | ||
|