Commit Graph

31 Commits

Author SHA1 Message Date
Edward Loveall 7e927469dc
Replace Redirector extension with LibRedirect
Since Scribe launched, the Redirector extension config has needed
occasional attention. Using regular expressions to cover all edge cases
is difficult. After finding out that Scribe's current config can hang
websites, I decided that [LibRedirect] is likely a more robust
solution. It can rely on more than regular expressions, and is less
work to set up.

[LibRedirect]: https://libredirect.github.io/
2022-09-24 15:50:38 -04:00
Edward Loveall 449ece843a
Provide a configuration file for the Redirector extension
Instead of providing long detailed instructions for how to configure
the Redirector extension, this provides a single json file that users
can import. I started by making a single file stored in the
`public/assets` directory, but then realized this was a regression since
the instructions were customized to each domain. Instead I can use
Lucky's [data] response to dynamically build the JSON config.

[data]:
https://luckyframework.org/guides/http-and-routing/request-and-response#
handling-responses
2022-07-17 15:00:03 -04:00
Edward Loveall 80b6b51804
Fix redirection pattern
Commit 6ea0586423 improved redirection
instructions, but regressed in one way. The "Redirect to" pattern
specified a slash which was accounted for in the main pattern, which
resulted in a double slash:

https://medium.com/@user/post-123456abcdef

would redirect to

https://scribe.rip//@user/post-123456abcdef

This removes the extra slash
2022-03-12 12:03:23 -05:00
Edward Loveall 1f517f9031
Link to full Medium URL on error page
Previously the link on the error page was only linking to the path
component of the url, e.g. `/search` but ignoring any query params e.g.
`/search?q=hello`. This uses the HTTP::Request `resource` method which
appears to capture both.
2022-02-13 10:13:24 -05:00
Edward Loveall f056a0b68a
Better error pages
Instead of showing the default Lucky error page, the styles now match
Scribe. In addition, if a URL can't be parsed, Scribe gives some
information as to why this might be (that Scribe can only deal with an
article pages)
2022-02-12 17:56:36 -05:00
Edward Loveall 46d87930b8
Use FAQ entry to explain custom domains 2022-01-08 20:15:46 -05:00
Edward Loveall f7e82ffd03
Home page instructions for custom domains 2022-01-04 21:16:56 -05:00
Edward Loveall 6ea0586423
Improve Redirector extension instructions
This specifies advanced options for configuring the Redirector
extension. If everything is let on (like images) things will break
(like images). It also improves the regular expression a bit to account
for the image CDN

Co-authored-by: Austin Huang <im@austinhuang.me>
2022-01-04 20:58:30 -05:00
Edward Loveall 1449acc500
Upgrade Crystal to 1.2.1 and Lucky to 0.29.0 2021-12-12 12:01:55 -05:00
Edward Loveall e365ee8be5
Add FAQ on how to use Scribe with custom domains
This is generic so as to not call out any specific website.
2021-12-04 14:05:39 -05:00
Edward Loveall 25464acabe
Add instance docs 2021-11-11 11:33:22 -05:00
Edward Loveall 4b354c659f
Add FAQ 2021-10-23 15:34:13 -04:00
Edward Loveall 513d590ce3
Point source link at sr.ht project page
Instead of the git page. That way it's easier to find the mailing lists
and whatnot.
2021-10-16 16:23:15 -04:00
Martin Puppe 56b6d546db
Further improve proposed pattern for Redirector
This patch further improves the proposed pattern for the Redirector
extension. In contrast to the old pattern, …

* … it will redirect the URL https://medium.com.
* … it will *not* redirect URLs with top-level domains like mediumXcom.
  (This point is purely theoretical, but it makes the regular expression
  more correct and consistent.)
* … it will *not* redirect URLs like https://link.medium.com/AXEtCilplkb
  which Scribe currently cannot handle. These are shortened URLs that
  users get when they use the Twitter button on Medium to share a post.

In order to implement the last point (not matching link.medium.com), the
pattern uses negative lookbehind. This feature of regular expressions is
supported by all recent browsers for which Redirector is available
(Firefox, Chrome, Edge, Opera)[^1], including the current version of
Firefox ESR (Extended Stability Release).

[^1]: https://caniuse.com/js-regexp-lookbehind
2021-10-15 08:55:26 -04:00
Amolith 9fcf37f416
Use app_domain in Redirector example
In the current redirector example, "scribe.rip" is hardcoded as the
destination. This patch simply changes that to use the app_domain
environment variable, so people wanting to use a community instance
aren't mistakenly redirected to the main scribe.rip instance.
2021-10-14 18:10:46 -04:00
Martin Puppe 0d9170b8d6
Improve proposed pattern for Redirector extension
The old pattern matches all host names that end with medium.com. The new
pattern matches only medium.com and its sub-domains. For example, the
old pattern would have matched
https://foomedium.com/@user/post-123456abcdef.
2021-10-13 21:51:55 -04:00
Edward Loveall 91f4aae0bc
Add an example and tagline to homepage 2021-10-11 20:03:31 -04:00
Edward Loveall 91687bb689
Add automatic redirect instructions to homepage 2021-10-10 15:05:56 -04:00
Edward Loveall fba87c1076
Improve title parsing
The subtitle has been removed because it's difficult to find and error
prone to guess at. It is somewhat accessible from the post's
previewContent field in GraphQL but that can be truncated.
2021-10-03 18:14:46 -04:00
Edward Loveall 2808505b4e
Add instructions on how to view a post 2021-10-03 17:21:17 -04:00
Edward Loveall 561483cf9f
Link to the author's page
Right now this links to the user's medium page. It may link to an
internal page in the future.

Instead of the Page taking the author as a string, it now takes a
PostResponse::Creator object. The Articles::ShowPage then converts the
Creator (a name and user_id) to an author link.

Finally, I did some refactoring of UserAnchor (which I thought I was
going to use for this) to change it's userId attribute to user_id as is
Crystal convention.
2021-09-15 16:03:36 -04:00
Edward Loveall 0cab1a11ed
Add home page 2021-09-06 13:38:18 -04:00
Edward Loveall 04b8d90b8f
Improve author/timestamp 2021-09-04 22:05:58 -04:00
Edward Loveall 8939772b12
Add post creation date/time 2021-09-04 17:32:27 -04:00
Edward Loveall c681d2e2ee
Add author to post
Instead of passing Paragraphs to the PageConverter, it now receives all
the data from the response. This has the author so it can be parsed out.
2021-09-04 17:15:30 -04:00
Edward Loveall 083abc5ef1
Add page title to <header> <title> 2021-09-04 14:44:05 -04:00
Edward Loveall 6baba80309
Display title and subtitle
Also wrap the content in an article for semantic formatting

tufte.css requires that content is wrapped in an <article> and at least
one <section>. There's no way of determining new semantic sections so
there is only one.
2021-08-29 15:19:39 -04:00
Edward Loveall 5a5f68bcf8
First step rendering a page
The API responds with a bunch of paragraphs which the client converts
into Paragraph objects.

This turns the paragraphs in a PostResponse's Paragraph objects into the
form needed to render them on a page. This includes converting flat list
elements into list elements nested by a UL. And adding a limited markups
along the way.

The array of paragraphs is passed to a recursive function. The function
takes the first paragraph and either wraps the (marked up) contents in a
container tag (like Paragraph or Heading3), and then moves onto the next
tag. If it finds a list, it starts parsing the next paragraphs as a list
instead.

Originally, this was implemented like so:

```crystal
paragraph = paragraphs.shift
if list?
  convert_list([paragraph] + paragraphs)
end
```

However, passing the `paragraphs` after adding it to the already shifted
`paragraph` creates a new object. This means `paragraphs` won't be
mutated and once the list is parsed, it starts with the next element of
the list. Instead, the element is `shift`ed inside each converter.

```crystal
if paragraphs.first == list?
  convert_list(paragraphs)
end

def convert_list(paragraphs)
  paragraph = paragraphs.shift
  # ...
end
```

When rendering, there is an Empty and Container object. These represent
a kind of "null object" for both leafs and parent objects respectively.
They should never actually render. Emptys are filtered out, and
Containers are never created explicitly but this will make the types
pass.

IFrames are a bit of a special case. Each IFrame has custom data on it
that this system would need to be aware of. For now, instead of trying
to parse the seemingly large number of iframe variations and dealing
with embedded iframe problems, this will just keep track of the source
page URL and send the user there with a link.
2021-07-04 16:28:03 -04:00
Edward Loveall 57f26996b2
Break up views into components 2021-05-15 17:06:42 -04:00
Edward Loveall 9e96f29852
Add basic response (except images)
The basic idea here is to fetch the post with the medium API, parse the
JSON into types, and then re-display the content. We also have to fetch
each media object as a REST call to get things like embeded iframes.
2021-05-01 17:39:05 -04:00
Edward Loveall fcf3eb14d0
Initial app 2021-05-01 17:03:38 -04:00