Skip to content

Reverse timeline entries so newest entries come first#879

Merged
ChrisLovering merged 1 commit into
mainfrom
flip-timeline
Feb 20, 2023
Merged

Reverse timeline entries so newest entries come first#879
ChrisLovering merged 1 commit into
mainfrom
flip-timeline

Conversation

@ichard26
Copy link
Copy Markdown
Contributor

@ichard26 ichard26 commented Feb 20, 2023

We agreed internally that this would look better, and especially as I add more entries.

This was automated using this script:

import dataclasses, sys, textwrap
from pathlib import Path

import bs4


@dataclasses.dataclass
class TimelineEntry:
    title: str
    date: str


html_doc = Path(sys.argv[1]).read_text("utf-8")
soup = bs4.BeautifulSoup(html_doc, "html.parser")

entries = []
for item in soup.find_all(class_="cd-timeline__block"):
    entries.append(TimelineEntry(
        title=str(item.find("h2").string),
        date=str(item.find(class_="cd-timeline__date").string),
    ))

entry_html_pieces = []
doc_lines = html_doc.splitlines()
line_index = 0
for entry in entries:
    entry_lines = []
    for line_index, line in enumerate(doc_lines[line_index:], start=line_index):
        if "cd-timeline__block" in line:
            break
    for line_index, line in enumerate(doc_lines[line_index:], start=line_index + 1):
        entry_lines.append(line)
        if line == "      </div>":
            break
    entry_html_pieces.append("\n".join(entry_lines))
    if entry.title not in entry_html_pieces[-1]:
        assert False, f"entry title ({entry.title}) not found!"

print("\n\n".join(entry_html_pieces))

I gave it the pre-existing HTML and then copy n' pasted the output in-between the non-timeline-entry elements.

We agreed internally that this would look better, and especially as I
add more entries.
@ichard26 ichard26 added area: frontend Related to site content and user interaction priority: 2 - normal Normal Priority type: enhancement Changes or improvements to existing features s: needs review Author is waiting for someone to review and approve labels Feb 20, 2023
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 20, 2023

Deploy Preview for pydis-static ready!

Name Link
🔨 Latest commit a41a997
🔍 Latest deploy log https://app.netlify.com/sites/pydis-static/deploys/63f2e3cba542fe00085bdb86
😎 Deploy Preview https://deploy-preview-879--pydis-static.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage: 100.0%. Remained the same when pulling a41a997 on flip-timeline into 286bd80 on main.

@ichard26
Copy link
Copy Markdown
Contributor Author

ichard26 commented Feb 20, 2023

Note

This may be easier to review locally with git show as the diff will contain no red or green lines, indicating that the contents weren't changed, only moved.

Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

Had a look at it in netlify and it all looks good.

@ChrisLovering ChrisLovering merged commit 0639c65 into main Feb 20, 2023
@ChrisLovering ChrisLovering deleted the flip-timeline branch February 20, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: frontend Related to site content and user interaction priority: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve type: enhancement Changes or improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants