Gnus development mailing list
 help / color / mirror / Atom feed
* Reddit Backend Message Ids
@ 2018-02-13 23:08 Stefan Huchler
  2018-02-14  4:58 ` Jeffrey DeLeo
  2018-02-14 19:27 ` Haider Rizvi
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Huchler @ 2018-02-13 23:08 UTC (permalink / raw)
  To: ding

Hello,

I try to make the mmreddit backend of gnus better, I want to make it
possible that gnus can track the viewed messaged so that I can see what
is new and where new posts and comments are:

https://github.com/paul-issartel/nnreddit/issues/6

But I am struggling with implementing it or find the parts I have to
edit. Because its abstracted away you need a good knowledge what is
expected.

As example does the backend need continious ids, or is it ok if its just
numbers and the numbers are unique?

I tried to edit the "nnreddit-make-header" function:
https://github.com/paul-issartel/nnreddit/blob/9843f99d01fd8f1eea2fc685965a7c7f4eeb187a/nnreddit.el#L331

by replacing:

#+begin_src emacs-lisp
    (make-full-mail-header
     id
     clean-title
     clean-author...)
#+end_src

with:

#+begin_src emacs-lisp
    (make-full-mail-header
     (nnreddit-id-to-numberreddit-id)
     clean-title
     clean-author
#+end_src

I think it then detected when a new message/post did happen in a
subreddit, but when I tried to open the group it says "no messages".

It's hard for me to get that figured out alone, I don't think that
should be that hard to fix, but again I hope somebody can assist me and
help me to understand the api of gnus a bit.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-13 23:08 Reddit Backend Message Ids Stefan Huchler
@ 2018-02-14  4:58 ` Jeffrey DeLeo
  2018-02-14 11:07   ` Stefan Huchler
  2018-02-14 19:27 ` Haider Rizvi
  1 sibling, 1 reply; 8+ messages in thread
From: Jeffrey DeLeo @ 2018-02-14  4:58 UTC (permalink / raw)
  To: ding

Wow, didn't know about this. I read reddit groups as newsgroups through
gwene.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-14  4:58 ` Jeffrey DeLeo
@ 2018-02-14 11:07   ` Stefan Huchler
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Huchler @ 2018-02-14 11:07 UTC (permalink / raw)
  To: ding

Jeffrey DeLeo <JeffreyDeLeo@gmail.com> writes:

> Wow, didn't know about this. I read reddit groups as newsgroups through
> gwene.

Yeah I thought about doing that, the advantage of this backend is at
this point that you also see comments, what you don't get with the gwene
groups I think? Right?

In theory you also could implement answering in gnus. Well there is even
a library for that:

http://nullprogram.com/blog/2013/12/16/

So it would not even be that hard. But for now I want to concentrate on
getting read-only support done.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-13 23:08 Reddit Backend Message Ids Stefan Huchler
  2018-02-14  4:58 ` Jeffrey DeLeo
@ 2018-02-14 19:27 ` Haider Rizvi
  2018-02-15 15:42   ` Stefan Huchler
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Haider Rizvi @ 2018-02-14 19:27 UTC (permalink / raw)
  To: ding

Stefan Huchler <stefan.huchler@mail.de> writes:


> I try to make the mmreddit backend of gnus better, I want to make it
> possible that gnus can track the viewed messaged so that I can see what
> is new and where new posts and comments are:
>
> https://github.com/paul-issartel/nnreddit/issues/6

Stefan, thanks for posting about nnreddit. It was on my todo list to
try out, your msg nudged me to do it. Looks promising on first view.

Unfortunately can't help you with the Gnus code. But, a question for you. 

Have you already got some code to jump to the Reddit thread in a
browser. Since the Message-id has the Reddit id, it can be built
reasonably easily. If you have something please share.

Regards, 
-- 
Haider




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-14 19:27 ` Haider Rizvi
@ 2018-02-15 15:42   ` Stefan Huchler
  2018-02-15 16:25   ` Stefan Huchler
  2018-02-24  3:50   ` Stefan Huchler
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Huchler @ 2018-02-15 15:42 UTC (permalink / raw)
  To: ding

Hi Haider,

I played a bit around and I got something working very hackish but it
works:

if you go to the function: nnreddit-request-article

(let ((header (car value))
              (data (cadr value))
              (type (caddr value))
	      (subreddit
	       (string-remove-suffix "*"
				     (string-remove-prefix
				      "*Article nnreddit:"
				      (buffer-name)))))

add this "subreddit" binding here and a few lines further change the
Subject to that:

     (concat "Subject: "
		     (format "[https://reddit.com/r/%s/comments/%s] - "
			     subreddit
			     (plist-get data :id))
		     (or (mail-header-subject header) "(none)") "\n")
             "")
           "Date: " (or (mail-header-date header) "") "\n"


You get a clickable url in your Subject line to the subreddit. Only
works with the messages, not with the comments there you get a 404.

Not sure how to get the message id from the subreddit inside a comment.

Hope that's not to confusing :D

I hesitate to create a github till its more solid than that :D So sorry
for the copy/pasting.


Haider Rizvi <harizvi@gmail.com> writes:

> Stefan Huchler <stefan.huchler@mail.de> writes:
>
>
>> I try to make the mmreddit backend of gnus better, I want to make it
>> possible that gnus can track the viewed messaged so that I can see what
>> is new and where new posts and comments are:
>>
>> https://github.com/paul-issartel/nnreddit/issues/6
>
> Stefan, thanks for posting about nnreddit. It was on my todo list to
> try out, your msg nudged me to do it. Looks promising on first view.
>
> Unfortunately can't help you with the Gnus code. But, a question for you. 
>
> Have you already got some code to jump to the Reddit thread in a
> browser. Since the Message-id has the Reddit id, it can be built
> reasonably easily. If you have something please share.
>
> Regards, 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-14 19:27 ` Haider Rizvi
  2018-02-15 15:42   ` Stefan Huchler
@ 2018-02-15 16:25   ` Stefan Huchler
  2018-02-24  3:50   ` Stefan Huchler
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Huchler @ 2018-02-15 16:25 UTC (permalink / raw)
  To: ding

Here is a bit refined version:

(subreddit
	       (string-remove-prefix
		"nnreddit:"
		gnus-newsgroup-name))

and:


(format "Score: %d\n" score)
               ""))
	   (format "\n<a href=https://reddit.com/r/%s/comments/%s>open in browser</a><br/> "
				    subreddit
				    (plist-get data :id))
           "\n"

But its hard, to get further:
1. not a reddit expert (of its api and anyting)
2. no gnus expert (its api)
3. don't understand the code of the backend very well

Therefor I hoped to find somebody here that can help me. Where are the
gnus developers hiding? Irc?



Haider Rizvi <harizvi@gmail.com> writes:

> Stefan Huchler <stefan.huchler@mail.de> writes:
>
>
>> I try to make the mmreddit backend of gnus better, I want to make it
>> possible that gnus can track the viewed messaged so that I can see what
>> is new and where new posts and comments are:
>>
>> https://github.com/paul-issartel/nnreddit/issues/6
>
> Stefan, thanks for posting about nnreddit. It was on my todo list to
> try out, your msg nudged me to do it. Looks promising on first view.
>
> Unfortunately can't help you with the Gnus code. But, a question for you. 
>
> Have you already got some code to jump to the Reddit thread in a
> browser. Since the Message-id has the Reddit id, it can be built
> reasonably easily. If you have something please share.
>
> Regards, 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-14 19:27 ` Haider Rizvi
  2018-02-15 15:42   ` Stefan Huchler
  2018-02-15 16:25   ` Stefan Huchler
@ 2018-02-24  3:50   ` Stefan Huchler
  2018-04-12 19:44     ` Haider Rizvi
  2 siblings, 1 reply; 8+ messages in thread
From: Stefan Huchler @ 2018-02-24  3:50 UTC (permalink / raw)
  To: ding

Hi Haider,

I think I made what you wanted and posted the patch here:

https://github.com/spiderbit/nnreddit

Regards


Haider Rizvi <harizvi@gmail.com> writes:

> Stefan, thanks for posting about nnreddit. It was on my todo list to
> try out, your msg nudged me to do it. Looks promising on first view.
>
> Unfortunately can't help you with the Gnus code. But, a question for you. 
>
> Have you already got some code to jump to the Reddit thread in a
> browser. Since the Message-id has the Reddit id, it can be built
> reasonably easily. If you have something please share.
>
> Regards, 




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Reddit Backend Message Ids
  2018-02-24  3:50   ` Stefan Huchler
@ 2018-04-12 19:44     ` Haider Rizvi
  0 siblings, 0 replies; 8+ messages in thread
From: Haider Rizvi @ 2018-04-12 19:44 UTC (permalink / raw)
  To: ding

Stefan Huchler <stefan.huchler@mail.de> writes:

> Hi Haider,
>
> I think I made what you wanted and posted the patch here:
>
> https://github.com/spiderbit/nnreddit

Stefan,

Apologize for being absent after our initial conversation, been busy
at work. Thanks for making this change. I had hacked together
something that works for me. I'll put it in git later, see the patch
below.

I add a header called Archived-at, which has the url to point to the
reddit entry. This is the same header that gwene adds to rss feeds. I
have prior code to jump to the url in Archived-at. I can share that
separately if there is interest.

Here is a patch if anyone is interested:


--- nnreddit.el.original	2018-02-15 15:04:07.000000000 -0700
+++ nnreddit.el	2018-02-15 15:36:14.000000000 -0700
@@ -316,6 +316,13 @@
 (defun nnreddit-make-message-id (reddit-id)
   (format "<%s@reddit.com>" reddit-id))
 
+;; Add an "Archived-At:" header somewhat like gwene does with a url pointing to the main
+;; Reddit comment thread - HR
+;; For example, add the following, full subject is not required to get to the comment
+;; Archived-At: <https://www.reddit.com/comments/7xrsr4/>
+(defun nnreddit-make-archived-at-header (reddit-id)
+  (format "Archived-At: <https://www.reddit.com/r/comments/%s/>" reddit-id))
+
 ;; (defun nnreddit-id-to-number (reddit-id)
 ;;   "Convert a Reddit ID (6 alphanumeric characters) to an integer."
 ;;   (car (read-from-string (concat "#36r" reddit-id))))
@@ -350,6 +357,7 @@
      nil ; no cross references
      ;; Extra headers
      (append `((X-Reddit-ID . ,reddit-id))
+             `((Archived-At . ,(nnreddit-make-archived-at-header reddit-id)))
              (if (integerp score)
                  `((X-Reddit-Score . ,(number-to-string score))))
              (if (integerp num_comments)
@@ -489,6 +497,7 @@
            "Date: " (or (mail-header-date header) "") "\n"
            "Message-ID: " (or (mail-header-id header) (nnmail-message-id)) "\n"
            "References: " (or (mail-header-references header) "") "\n"
+           (or (cdr (assq 'Archived-At (mail-header-extra header))) "") "\n"
            "Content-Type: text/html; charset=utf-8" "\n"
            (let ((score (plist-get data :score)))
              (if (and nnreddit-insert-score-header




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-12 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 23:08 Reddit Backend Message Ids Stefan Huchler
2018-02-14  4:58 ` Jeffrey DeLeo
2018-02-14 11:07   ` Stefan Huchler
2018-02-14 19:27 ` Haider Rizvi
2018-02-15 15:42   ` Stefan Huchler
2018-02-15 16:25   ` Stefan Huchler
2018-02-24  3:50   ` Stefan Huchler
2018-04-12 19:44     ` Haider Rizvi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).