srid / zulip-archive

Zulip Archive viewer (statically generated HTML)
https://funprog.srid.ca
13 stars 1 forks source link

[#11] Add OpenGraph Protocol Meta Tags #15

Closed prikhi closed 4 years ago

prikhi commented 4 years ago

Add OpenGraph Protocol meta tags to the generated HTML. These describe the site, streams, and topics to website's that provide rich media for linked pages(e.g., Facebook, LinkedIn).

Streams simply display the Stream Name & Description.

Topics show the Topic Name, the Stream name, the created & modified times, a description using the first 300 characters of the first message, and the originals poster's avatar as an image.

A new baseUrl configuration value has been added, which should contain the protocol & domain of the archive(e.g., https://funprog.srid.ca). This is used to generate the url OGP tags, which require a full URI instead of just a path.

Refs #11

prikhi commented 4 years ago

Also my nix is broken atm so I wasn't able to test builds... I'll see how CI does :(

prikhi commented 4 years ago

Alright, builds are fixed now. To finish this, I need an instance-agnostic way of getting the URL the archive will be hosted at since the url and image properties should be the full URL w/ protocol, domain, and path.

I might also clean up the generation of properties dependent on Maybe a types.

srid commented 4 years ago

@prikhi You can get the base URL from the cfg value, which is passed as an argument to generateSite function. Just pass it down to renderPage and from there use Config.baseUrl cfg.

The Config type itself is generated by Dhall.TH, and you can check the available fields in ./config/Type.dhall.

Also my nix is broken atm so I wasn't able to test builds

Let me know (here or in Zulip) if there is any problem with getting the app running locally!

prikhi commented 4 years ago

You can get the base URL from the cfg value, which is passed as an argument to generateSite function. Just pass it down to renderPage and from there use Config.baseUrl cfg.

The Config type itself is generated by Dhall.TH, and you can check the available fields in ./config/Type.dhall.

That's the Zulip domain right, I was thinking that the url property should point to the archive's domain instead(e.g., funprog.srid.ca). Is that available somewhere or should I add another config field for that?

prikhi commented 4 years ago

Also, I'm not sure if it matters that there's HTML in the description tag.

srid commented 4 years ago

That's the Zulip domain right, I was thinking that the url property should point to the archive's domain instead(e.g., funprog.srid.ca). Is that available somewhere or should I add another config field for that?

Oops, my bad. Yea, you can just add another config field for that.

srid commented 4 years ago

Also, I'm not sure if it matters that there's HTML in the description tag.

Does it? I see that you are using _streamDescription s, which should just be a text.

prikhi commented 4 years ago

The stream descriptions should be fine, but some of the topic descriptions have HTML like <code> elements.

Do you have a preference for naming of the archive domain field?

srid commented 4 years ago

About the <code> elements, you can leave them as is for now. The zulip API actually does return the plain text version (Markdown) as well, I just haven't added that field to Zulip/Client.hs; I can do that after merging this PR (or you can poke around).

Do you have a preference for naming of the archive domain field?

baseUrl.

prikhi commented 4 years ago

Let me know if there's anything else I should address.

prikhi commented 4 years ago

Little more cleanup:

srid commented 4 years ago

@prikhi Thanks, and deployed! I changed the OGP title to match that of the page.