Commit graph

13 commits

Author SHA1 Message Date
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