Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add extra items support #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

yshrsmz
Copy link

@yshrsmz yshrsmz commented Jul 13, 2020

related #82

Hi, based on #82 I added the ability to add extra items.

I still need to add some documentation, but could you review this to make sure that the direction is right?

@coveralls
Copy link

coveralls commented Jul 13, 2020

Coverage Status

Coverage increased (+0.03%) to 99.605% when pulling 86dffd1 on yshrsmz:custom-elements into fd77835 on jpmonette:master.

* @param key
* @param value
*/
public addExtra = (key: string, value: ExtraItem) => this.extra[key] = value;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtraItem is just a xml-js object. Each user needs to make sure that the object conforms to xml-js specification.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm not sure how I should handle these extra items in the json format.

Copy link
Author

@yshrsmz yshrsmz Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can simply ignore extra items when generating JSON? Just like extensions in atom1/rss2 format.

@FelixButzbach
Copy link

Hei there,
thanks for your time and this plugin.

Any ideas when (or if) this will be merged?
It would be super handy for us.

@JosephSaw
Copy link

hey @yshrsmz thanks for your time in creating this, I have forked your code and tried to understand it as much as I could.

I am trying to add it to my feed as you can see in the image below, i have the attribute "extra" in the addItem function, but it doesn't seem to be working for me.

I have also tried including the xml-js library and using the 'json2xml' function doesn't seem to work too.

I have also simply tried with a plain string but to no avail.

Any help would be greatly appreciated.
image

@yshrsmz
Copy link
Author

yshrsmz commented Aug 12, 2020

@JosephSaw could you add your example in a code snippet, not a screenshot?

The following item seems to render its content correctly(I've tested with test cases in this repo).

sampleFeed.addItem({
      title: "Hello World",
      id: "https://example.com/hello-world?id=this&that=true",
      link: "https://example.com/hello-world?link=sanitized&value=2",
      description: "This is an article about Hello World.",
      content: "Content of my item",
      date: new Date(),
      extra: {
        testExtra: '{"a": {"_text": " Hi "}}'
      }
    })

atom1

<entry>
    <title type="html"><![CDATA[Hello World]]></title>
    <id>https://example.com/hello-world?id=this&amp;that=true</id>
    <link href="https://example.com/hello-world?link=sanitized&amp;value=2"/>
    <updated>2020-08-12T11:21:50.778Z</updated>
    <summary type="html"><![CDATA[This is an article about Hello World.]]></summary>
    <content type="html"><![CDATA[Content of my item]]></content>
    <testExtra>{"a": {"_text": " Hi "}}</testExtra>
</entry>

rss2

<item>
    <title><![CDATA[Hello World]]></title>
    <link>https://example.com/hello-world?link=sanitized&amp;value=2</link>
    <guid>https://example.com/hello-world?id=this&amp;that=true</guid>
    <pubDate>Wed, 12 Aug 2020 11:24:36 GMT</pubDate>
    <description><![CDATA[This is an article about Hello World.]]></description>
    <content:encoded><![CDATA[Content of my item]]></content:encoded>
    <testExtra>{"a": {"_text": " Hi "}}</testExtra>
</item>

@JosephSaw
Copy link

@yshrsmz Yup sorry, it works!

Was actually using https://github.com/nuxt-community/feed-module I had to fork this and update the dependency to use the newly forked feed you created

@yshrsmz
Copy link
Author

yshrsmz commented Feb 26, 2021

@jpmonette I've rebased the PR to the current master.
Could you take a look?

@remorses
Copy link

remorses commented Sep 2, 2022

Has anyone already published a fork with these changes?

@yshrsmz
Copy link
Author

yshrsmz commented Sep 2, 2022

@remorses if you really need it, you can use my fork directly

"dependencies": {
  "feed": "https://github.com/yshrsmz/feed.git#commit=5d545dc6ce46ac9b05b357e26be23e74472f966e"
}

edit 2022/09/08: merge master branch, updated commit hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants