Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/navi2ch-list.el b/navi2ch-list.el
- index 4188735..509df1d 100644
- --- a/navi2ch-list.el
- +++ b/navi2ch-list.el
- @@ -94,7 +94,7 @@
- (nil " " navi2ch-list-board-name-face))))
- (defconst navi2ch-list-bbstable-default-url
- - "http://menu.2ch.net/bbsmenu.html")
- + "https://menu.5ch.net/bbsmenu.json")
- ;; add hook
- (add-hook 'navi2ch-save-status-hook 'navi2ch-list-save-info)
- @@ -567,10 +567,56 @@ changed-list は '((board-id old-board new-board) ...) な alist。
- (let ((board-id (cdr (assoc url navi2ch-list-board-id-alist))))
- (or board-id
- (save-match-data
- - (if (string-match "\\`http://.+/\\([^/]+\\)/\\'" url)
- + (if (string-match "\\`https?://.+/\\([^/]+\\)/\\'" url)
- (match-string 1 url))))))
- +
- (defun navi2ch-list-make-board-txt ()
- + (if (and navi2ch-list-media-type
- + (string-equal (cdr navi2ch-list-media-type) "application/json"))
- + (navi2ch-list-make-board-txt-from-json)
- + (navi2ch-list-make-board-txt-from-html)))
- +
- +(defun navi2ch-list-make-board-txt-from-json ()
- + "bbstable.json から (navi2ch 用の) board.txt を作る。
- +`navi2ch-net-update-file' のハンドラ。"
- + (let ((coding-system-for-read 'binary)
- + (coding-system-for-write 'binary)
- + (case-fold-search t)
- + (beg (point))
- + (id-to-url-table (make-hash-table :test 'eq))
- + (bbstable (json-parse-string (decode-coding-string (buffer-string) 'utf-8))))
- + (erase-buffer)
- + (seq-doseq (category (gethash "menu_list" bbstable))
- + (let ((category-name (gethash "category_name" category)))
- + (unless
- + ;; ignore category?
- + (member category-name navi2ch-list-ignore-category-list)
- + (insert (encode-coding-string category-name navi2ch-coding-system) "\n\n\n")
- + (seq-doseq (board (gethash "category_content" category))
- + (let ((url (gethash "url" board))
- + (board-name (gethash "board_name" board))
- + board-id id u)
- + (setq url (or (cdr (assoc url navi2ch-list-moved-board-alist))
- + url))
- + (when (and (navi2ch-list-valid-board url)
- + (setq board-id (navi2ch-list-board-id-from-url url)))
- + (setq id (intern board-id))
- + (when (and (setq u (gethash id id-to-url-table))
- + (not (string= u url)))
- + ;; 同じ ID で URL が違う板がある場合
- + (let ((i 2)
- + newid)
- + (while (and (setq newid (intern (format "%s:%d" id i)))
- + (setq u (gethash newid id-to-url-table))
- + (not (string= u url)))
- + (setq i (1+ i)))
- + (setq id newid)))
- + (insert (encode-coding-string board-name navi2ch-coding-system) "\n"
- + url "\n" (symbol-name id) "\n")))))))))
- +
- +
- +(defun navi2ch-list-make-board-txt-from-html ()
- "bbstable.html から (navi2ch 用の) board.txt を作る。
- `navi2ch-net-update-file' のハンドラ。"
- (let ((coding-system-for-read 'binary)
- @@ -590,7 +636,7 @@ changed-list は '((board-id old-board new-board) ...) な alist。
- (if (string-match "a" tag)
- (let (url board-id id u)
- (when (and (not ignore)
- - (string-match "href=\\(.+/\\([^/]+\\)/\\)" attr))
- + (string-match "href=\"?\\(.+/\\([^/]+\\)/\\)" attr))
- (setq url (match-string 1 attr))
- (setq url (or (cdr (assoc
- url
- @@ -624,7 +670,7 @@ changed-list は '((board-id old-board new-board) ...) な alist。
- (defun navi2ch-list-valid-board (uri)
- (save-match-data
- - (when (string-match "http://\\([^/]+\\)/\\([^/]+\\)/" uri)
- + (when (string-match "https?://\\([^/]+\\)/\\([^/]+\\)/" uri)
- (let ((host (match-string 1 uri)))
- (and (not (string-match navi2ch-list-invalid-host-regexp host))
- (string-match navi2ch-list-valid-host-regexp host))))))
- diff --git a/navi2ch-multibbs.el b/navi2ch-multibbs.el
- index 8e49f28..d1ef831 100644
- --- a/navi2ch-multibbs.el
- +++ b/navi2ch-multibbs.el
- @@ -345,7 +345,7 @@ START, END, NOFIRST で範囲を指定する"
- ;;;-----------------------------------------------
- -(defsubst navi2ch-2ch-subject-callback ()
- +(defsubst navi2ch-2ch-subject-callback (&optional args)
- (when navi2ch-board-use-subback-html
- (navi2ch-board-make-subject-txt)))
- @@ -525,7 +525,7 @@ START, END, NOFIRST で範囲を指定する"
- 'equal)))
- (navi2ch-cache-get
- (cons uri file-name)
- - (cond ((string-match "http://\\(?:[^@/]+@\\)?\\(.+\\)" uri)
- + (cond ((string-match "https?://\\(?:[^@/]+@\\)?\\(.+\\)" uri)
- (navi2ch-expand-file-name
- (concat (match-string 1 uri)
- file-name)))
- diff --git a/navi2ch-net.el b/navi2ch-net.el
- index dc11ec5..687c810 100644
- --- a/navi2ch-net.el
- +++ b/navi2ch-net.el
- @@ -220,7 +220,7 @@ nil なら常に再接続する。")
- (process-connection-type nil)
- (inherit-process-coding-system
- navi2ch-net-inherit-process-coding-system)
- - user pass host file port host2ch credentials auth)
- + user pass host file port host2ch credentials auth rest)
- (let ((list (navi2ch-net-split-url url navi2ch-net-http-proxy)))
- (setq list (navi2ch-net-connect-check list))
- (setq user (cdr (assq 'user list))
- @@ -228,7 +228,8 @@ nil なら常に再接続する。")
- host (cdr (assq 'host list))
- file (cdr (assq 'file list))
- port (cdr (assq 'port list))
- - host2ch (cdr (assq 'host2ch list))))
- + host2ch (cdr (assq 'host2ch list))
- + rest (cdr (assq 'rest list))))
- (when navi2ch-net-http-proxy
- (setq credentials (navi2ch-net-http-basic-credentials
- navi2ch-net-http-proxy-userid
- @@ -257,11 +258,8 @@ nil なら常に再接続する。")
- (setq proc nil)
- (unless (navi2ch-net-down-p host)
- (condition-case nil
- - (if (string-match "^https://" url)
- - (setq proc (funcall 'open-tls-stream
- - navi2ch-net-connection-name buf host "443"))
- - (setq proc (funcall navi2ch-open-network-stream-function
- - navi2ch-net-connection-name buf host port)))
- + (setq proc (apply navi2ch-open-network-stream-function
- + navi2ch-net-connection-name buf host port rest))
- (error (navi2ch-net-add-down-host host)))))
- (when proc
- (with-current-buffer buf
- @@ -304,6 +302,10 @@ nil なら常に再接続する。")
- (navi2ch-net-cleanup-vars)
- (setq navi2ch-net-process proc))))
- +(defun navi2ch-net-split-url-scheme-to-rest (scheme)
- + (if (string-prefix-p "https:" scheme)
- + '(:type tls)))
- +
- (defun navi2ch-net-split-url (url &optional proxy)
- (let (host2ch authinfo user pass)
- (string-match "https?://\\([^@/]+@\\)?\\([^/]+\\)" url)
- @@ -324,16 +326,21 @@ nil なら常に再接続する。")
- (cons 'host (match-string 2 proxy))
- (cons 'file url)
- (cons 'port (string-to-number (match-string 3 proxy)))
- - (cons 'host2ch host2ch)))
- - (string-match "https?://\\(?:[^@/]+@\\)?\\([^/:]+\\)\\(?::\\([0-9]+\\)\\)?\\(.*\\)" url)
- + (cons 'host2ch host2ch)
- + (cons 'rest (navi2ch-net-split-url-scheme-to-rest (match-string 1 proxy)))))
- + (string-match "\\(https?://\\)\\(?:[^@/]+@\\)?\\([^/:]+\\)\\(?::\\([0-9]+\\)\\)?\\(.*\\)" url)
- (list
- (cons 'user user)
- (cons 'pass pass)
- - (cons 'host (match-string 1 url))
- - (cons 'port (string-to-number (or (match-string 2 url)
- - "80")))
- - (cons 'file (match-string 3 url))
- - (cons 'host2ch host2ch)))))
- + (cons 'host (match-string 2 url))
- + (cons 'port
- + (if (match-string 3 url)
- + (string-to-number (match-string 3 url))
- + (if (string-prefix-p "https:" (match-string 1 url))
- + 443 80)))
- + (cons 'file (match-string 4 url))
- + (cons 'host2ch host2ch)
- + (cons 'rest (navi2ch-net-split-url-scheme-to-rest (match-string 1 url)))))))
- (defun navi2ch-net-http-basic-credentials (user pass)
- "USER と PASS から Basic 認証の証明書 (?) 部分を返す。"
- @@ -642,6 +649,9 @@ OTHER-HEADER は `navi2ch-net-download-file' に渡される。
- (navi2ch-set-buffer-multibyte nil)
- (insert cont)
- (goto-char (point-min))
- + (set (make-local-variable 'navi2ch-list-media-type)
- + (if (assq 'content-type header)
- + (assq 'content-type header)))
- (funcall func)
- (buffer-string))))
- (when (navi2ch-net-is-tanpan-thread-p cont)
- @@ -999,7 +1009,7 @@ This is taken from RFC 2396.")
- "BBS_\\(TITLE_PICTURE\\|FIGUREHEAD\\)=\\(.+\\)" content))
- (setq src (match-string 2 content))
- (let (url file)
- - (setq url (if (string-match "http://" src)
- + (setq url (if (string-match "https?://" src)
- src
- (navi2ch-board-get-url board src)))
- (string-match "/\\([^/]+\\)$" url)
- diff --git a/navi2ch-vars.el b/navi2ch-vars.el
- index 7bb307c..dbc5dda 100644
- --- a/navi2ch-vars.el
- +++ b/navi2ch-vars.el
- @@ -255,7 +255,7 @@ nil ならば手動で更新しないかぎり取りにいかない。"
- (defcustom navi2ch-list-valid-host-regexp
- (concat "\\("
- - (regexp-opt '(".2ch.net" ".bbspink.com" ".machibbs.com" ".machi.to"))
- + (regexp-opt '(".5ch.net" ".2ch.net" ".bbspink.com" ".machibbs.com" ".machi.to"))
- "\\)\\'")
- "*2ちゃんねるの板とみなすホストの正規表現。"
- :type 'regexp
- @@ -263,7 +263,7 @@ nil ならば手動で更新しないかぎり取りにいかない。"
- (defcustom navi2ch-list-invalid-host-regexp
- (concat "\\`\\("
- - (regexp-opt '("find.2ch.net" "info.2ch.net"))
- + (regexp-opt '("find.5ch.net" "find.2ch.net" "info.5ch.net" "info.2ch.net" ))
- "\\)\\'")
- "*2ちゃんねるの板とみなさないホストの正規表現。
- `navi2ch-list-valid-host-regexp' より優先される。"
- @@ -2424,5 +2424,8 @@ to force the image format."
- (define-key map "\C-x\C-s" 'navi2ch-save-status)
- (setq navi2ch-global-view-map map)))
- +;;;
- +(defvar navi2ch-list-media-type nil)
- +
- (run-hooks 'navi2ch-vars-load-hook)
- ;;; navi2ch-vars.el ends here
Advertisement
Add Comment
Please, Sign In to add comment