2024-12-19-Thursday
created: 2024-12-19 06:00 tags: - daily-notes
Thursday, December 19, 2024
<< Timestamps/2024/12-December/2024-12-18-Wednesday|Yesterday | Timestamps/2024/12-December/2024-12-20-Friday|Tomorrow >>
🎯 Goal
- [x] Pretty up the display of the different notes so that they have their own separate containers (similar to the Blog App)
- [ ] Develop Django Management Commands that can be run on these different
Vault
s to help parse information from the Markdown files and load them directly into the Django Model's data (mainly summaries and tags).
🌟 Results
- Made the BigBrain App's vault display look much nicer, including the public vault page, vault details page, and note details page.
- Identified and fixed the fact that
Linked Note
s were not being added into the database
🌱 Next Time
- Develop Django Management Commands that can be run on these different
Vault
s to help parse information from the Markdown files and load them directly into the Django Model's data (mainly summaries and tags).
📝 Notes
I decided to start today with beautifying the display of the notes first because I just can't stand the way they look. The fix could be pretty simple too since the CSS is already established for the blog posts themselves. I'll just have to alter the Django Templates to place the note data in the right div containers.
I found out that I wasn't actually creating any Linked Note
s because I placed the Class Method to associate linked notes with one another after the return statement. Whoops. No worries, I should be able to easily delete and re-load the vaults at any point since they'll always be a working reflection of the Local Version of my notes. In this case I let ChatGPT update my import script so that links were established and resolved between notes. I also updated the Regex so that imports of images (--redacted--
) weren't included as valid links.
I adjusted some of the CSS styling as well as some of the HTML to get a nice card layout for the notes list:
--redacted--
As well as a nice card layout for the vaults list:
--redacted--
Not sure if I like the way the blue looks here, but this looks way nicer than the original layout I was using that was trying to make the Blog App CSS work:
--redacted--
Overall I'm happy with these changes and will update them if needed. I created a github issue for the mobile issue. The main point is that the pagination at the bottom should also be centered but that's a lower priority right now.
--redacted--
I ended up coming back to this after work because I wanted to make sure I'd be able to associate links [[]]
with URLs instead of just the raw text they represent in traditional Markdown files. To do this I didn't necessarily need to edit the raw markdown content of the .md
files (the Note
's content
Attribute), but could instead update the function that renders the markdown as HTML. I ended up using the following approach:
# Create a property that returns the markdown
@property
def formatted_markdown(self, note_pattern=r'!\[\[(.*?)\]\]', link_pattern=r'\[\[(.*?)\]\]'):
"""
Parse the markdown content and transform:
- [Note Name](/blog/vault/dimmin-notes/note-name/) into markdown links to note pages.
- --redacted-- into a redacted string (--redacted--).
"""
# Replace --redacted-- with --redacted--
def redact(match):
return "--redacted--"
# Replace [[]] with proper markdown links
def create_link(match):
note_name = match.group(1)
slugified_name = slugify(note_name)
# Use Django's reverse to generate the URL for the note
url = reverse('vault_note_detail', kwargs={
'vault_slug': self.vault.slug,
'note_slug': slugified_name
})
return f"[{note_name}]({url})"
# Apply transformations
content = re.sub(note_pattern, redact, self.content)
content = re.sub(link_pattern, create_link, content)
return markdownify(content)
Which uses two internal functions as well as Regex to reconstruct the URL in the same way it's performed in the Django Management Command. This allows links to be embedded and my image content (mainly screenshots of work) to remain redacted in case of any copyright claims / issues.
Notes created today
List FROM "" WHERE file.cday = date("2024-12-19") SORT file.ctime asc
Notes last touched today
List FROM "" WHERE file.mday = date("2024-12-19") SORT file.mtime asc