Spaces:
Sleeping
Sleeping
Vinay Jose
commited on
Commit
·
9eb2ef0
1
Parent(s):
246882a
initial commit
Browse files- .github/workflows/main.yml +24 -0
- Dockerfile +15 -0
- README.md +13 -1
- app.py +166 -0
- books/show_your_work.md +39 -0
- books/steal_like_an_artist.md +49 -0
- requirements.txt +3 -0
.github/workflows/main.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Deploy to HF Spaces
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- 'hf-deploy'
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
deploy:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
steps:
|
12 |
+
- uses: actions/checkout@v4
|
13 |
+
with:
|
14 |
+
fetch-depth: 0
|
15 |
+
lfs: false
|
16 |
+
|
17 |
+
- name: Push to HF Spaces
|
18 |
+
env:
|
19 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
20 |
+
run: |
|
21 |
+
git config --global user.email "[email protected]"
|
22 |
+
git config --global user.name "GitHub Actions"
|
23 |
+
git push https://HuggingFaceBot:[email protected]/spaces/vinay-jose/notesMD hf-deploy:main
|
24 |
+
|
Dockerfile
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
6 |
+
|
7 |
+
RUN pip install --upgrade pip
|
8 |
+
|
9 |
+
WORKDIR /app
|
10 |
+
|
11 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
12 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
13 |
+
|
14 |
+
COPY --chown=user . /app
|
15 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
@@ -1,2 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# notesMD
|
2 |
-
|
|
|
1 |
+
---
|
2 |
+
title: Books
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: green
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
license: apache-2.0
|
9 |
+
short_description: app to render markdown notes
|
10 |
+
app_port: 5001
|
11 |
+
---
|
12 |
+
|
13 |
# notesMD
|
14 |
+
|
app.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fasthtml.common import *
|
2 |
+
from monsterui.all import *
|
3 |
+
import frontmatter
|
4 |
+
import pathlib
|
5 |
+
from fasthtml.components import Uk_theme_switcher
|
6 |
+
from monsterui.foundations import *
|
7 |
+
|
8 |
+
app, rt = fast_app(hdrs=Theme.gray.headers(daisy=True))
|
9 |
+
|
10 |
+
def load_book(file_path):
|
11 |
+
"""Load and parse a book's markdown file"""
|
12 |
+
with open(file_path) as f:
|
13 |
+
post = frontmatter.load(f)
|
14 |
+
return post
|
15 |
+
|
16 |
+
def create_mode_picker():
|
17 |
+
def _opt(val, txt, **kwargs): return Option(txt, value=val, **kwargs)
|
18 |
+
def _optgrp(key, lbl, opts): return Optgroup(data_key=key, label=lbl)(*opts)
|
19 |
+
group = _optgrp('mode', 'Mode',
|
20 |
+
[
|
21 |
+
_opt('light','Light',data_icon='sun'),
|
22 |
+
_opt('dark','Dark',data_icon='moon')
|
23 |
+
])
|
24 |
+
return Div(Uk_theme_switcher(
|
25 |
+
Select(group, hidden=True, selected=True),
|
26 |
+
id="mode-picker"
|
27 |
+
),
|
28 |
+
cls=stringify('p-4'))
|
29 |
+
|
30 |
+
def create_book_page(post):
|
31 |
+
"""Create the detailed book page using our template"""
|
32 |
+
metadata = post.metadata
|
33 |
+
return Container(
|
34 |
+
random_theme_script(),
|
35 |
+
DivCentered(
|
36 |
+
Card(
|
37 |
+
DivCentered(
|
38 |
+
H1(metadata["title"],
|
39 |
+
cls="text-transparent bg-clip-text bg-gradient-to-r from-primary via-muted to-primary transition-all duration-1000 hover:scale-105",
|
40 |
+
style="font-size: 2.5rem; font-weight: 700; -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.7);"),
|
41 |
+
H2(metadata["author"], cls=(TextT.muted)),
|
42 |
+
A(
|
43 |
+
Img(
|
44 |
+
src=metadata['cover_img_url'],
|
45 |
+
cls="rounded-lg hover:scale-105 shadow-lg transition-all duration-1000",
|
46 |
+
style="width:300px"
|
47 |
+
),
|
48 |
+
cls="rounded-lg overflow-hidden",
|
49 |
+
href=metadata['book_url']
|
50 |
+
),
|
51 |
+
cls="text-center space-y-6"
|
52 |
+
),
|
53 |
+
DivCentered(
|
54 |
+
Section(
|
55 |
+
DivHStacked(
|
56 |
+
Label(f"📅 {metadata['date'].strftime('%B %d, %Y')}", cls=LabelT.secondary),
|
57 |
+
Label(f"📚 {metadata['genre']}", cls=LabelT.secondary),
|
58 |
+
cls="space-x-2"
|
59 |
+
),
|
60 |
+
cls=SectionT.xs
|
61 |
+
),
|
62 |
+
cls="mb-6"
|
63 |
+
),
|
64 |
+
Div(
|
65 |
+
render_md(
|
66 |
+
post.content,
|
67 |
+
class_map={
|
68 |
+
'h3': f'text-transparent bg-clip-text bg-gradient-to-r from-primary to-secondary {TextT.xl} {TextT.bold} mb-6 mt-8',
|
69 |
+
'ul': f'{ListT.disc} space-y-4 mb-8',
|
70 |
+
'li': f'{TextT.lg} {TextT.normal} leading-relaxed',
|
71 |
+
'ul ul': f'{ListT.circle} ml-8 mt-4',
|
72 |
+
'ul ul li': f'{TextT.normal} leading-relaxed',
|
73 |
+
'p': f'{TextT.lg} {TextT.normal} mb-4',
|
74 |
+
'img': 'rounded-lg shadow-md hover:shadow-xl transition-shadow duration-200',
|
75 |
+
'*[@class="gallery"]': 'flex flex-row items-center justify-center gap-8'
|
76 |
+
}
|
77 |
+
),
|
78 |
+
cls = 'space-y-6'
|
79 |
+
),
|
80 |
+
cls=CardT.default
|
81 |
+
)
|
82 |
+
),
|
83 |
+
cls=(ContainerT.lg, 'p-8'),
|
84 |
+
style="position: relative; overflow: hidden;"
|
85 |
+
)
|
86 |
+
|
87 |
+
def create_book_card(metadata, filename):
|
88 |
+
"""Create a card for the book listing"""
|
89 |
+
return A(
|
90 |
+
Card(
|
91 |
+
DivCentered(
|
92 |
+
Img(
|
93 |
+
src=metadata['cover_img_url'],
|
94 |
+
cls="rounded-lg shadow-md hover:scale-105 transition-all duration-300",
|
95 |
+
style="width:200px"
|
96 |
+
),
|
97 |
+
H3(metadata['title'],
|
98 |
+
cls="text-transparent bg-clip-text bg-gradient-to-r from-primary to-secondary"),
|
99 |
+
P(metadata['author'], cls=TextT.muted),
|
100 |
+
DivHStacked(
|
101 |
+
Label(metadata['genre'], cls=LabelT.secondary),
|
102 |
+
Label(metadata['date'].strftime('%B %d, %Y'), cls=LabelT.secondary),
|
103 |
+
cls="mt-4 space-x-2"
|
104 |
+
),
|
105 |
+
cls="space-y-4 p-4"
|
106 |
+
),
|
107 |
+
cls=(CardT.hover, "transition-all duration-300 hover:shadow-xl")
|
108 |
+
),
|
109 |
+
href=f"/book/{filename}",
|
110 |
+
)
|
111 |
+
|
112 |
+
def random_theme_script():
|
113 |
+
return Script("""
|
114 |
+
document.addEventListener('DOMContentLoaded', function() {
|
115 |
+
const themes = ['uk-theme-zinc', 'uk-theme-slate', 'uk-theme-red',
|
116 |
+
'uk-theme-rose', 'uk-theme-orange', 'uk-theme-green',
|
117 |
+
'uk-theme-blue', 'uk-theme-yellow', 'uk-theme-violet'];
|
118 |
+
const randomTheme = themes[Math.floor(Math.random() * themes.length)];
|
119 |
+
document.documentElement.className = randomTheme;
|
120 |
+
});
|
121 |
+
""")
|
122 |
+
|
123 |
+
@rt
|
124 |
+
def index():
|
125 |
+
"""Homepage with grid of book cards"""
|
126 |
+
books_path = pathlib.Path('books')
|
127 |
+
book_files = list(books_path.glob('*.md'))
|
128 |
+
|
129 |
+
# Create cards for each book
|
130 |
+
book_cards = []
|
131 |
+
for file in book_files:
|
132 |
+
post = load_book(file)
|
133 |
+
book_cards.append(create_book_card(post.metadata, file.stem))
|
134 |
+
|
135 |
+
return Container(
|
136 |
+
create_mode_picker(),
|
137 |
+
random_theme_script(),
|
138 |
+
Grid(*book_cards,
|
139 |
+
cols_sm=1, cols_md=2, cols_lg=3, cols_xl=4,
|
140 |
+
gap=6),
|
141 |
+
cls=(ContainerT.xl, 'p-8')
|
142 |
+
)
|
143 |
+
|
144 |
+
@rt("/book/{filename}")
|
145 |
+
def get(filename: str):
|
146 |
+
"""Individual book page"""
|
147 |
+
try:
|
148 |
+
books_path = pathlib.Path('books')
|
149 |
+
book_file = books_path / f"{filename}.md"
|
150 |
+
|
151 |
+
if not book_file.exists():
|
152 |
+
raise FileNotFoundError
|
153 |
+
|
154 |
+
post = load_book(book_file)
|
155 |
+
return create_book_page(post)
|
156 |
+
except (FileNotFoundError, ValueError) as e:
|
157 |
+
return Container(
|
158 |
+
DivCentered(
|
159 |
+
H1("Book Not Found", cls=TextT.error),
|
160 |
+
P("Sorry, we couldn't find the book you're looking for."),
|
161 |
+
A("Return to Library", href="/", cls=ButtonT.primary),
|
162 |
+
cls="space-y-6 py-12"
|
163 |
+
)
|
164 |
+
)
|
165 |
+
|
166 |
+
serve()
|
books/show_your_work.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
date: 2024-01-24
|
3 |
+
genre: Self-Help
|
4 |
+
title: Show Your Work
|
5 |
+
author: Austin Kleon
|
6 |
+
cover_img_url: https://i.pinimg.com/736x/81/e1/a8/81e1a857c7c6ced9378fa8320aad0807.jpg
|
7 |
+
book_url: https://www.audible.in/pd/The-Steal-Like-an-Artist-Audio-Trilogy-Audiobook/B0B6QCC6TM
|
8 |
+
tags: []
|
9 |
+
---
|
10 |
+
|
11 |
+
### The Good Stuff
|
12 |
+
|
13 |
+
+ All you need is to show your work; influence others by letting others steal from you 😉
|
14 |
+
+ "Be so good they can't ignore you" - Steve Martin
|
15 |
+
+ Working in public
|
16 |
+
+ Alternative to self promotion???
|
17 |
+
+ Find a scenius - be part of a creative community
|
18 |
+
+ Be an amateur - do things out of love
|
19 |
+
+ Share things that you are passionate about with your community
|
20 |
+
+ "Find your voice, shout it from the rooftops, and keep doing it until the people that are looking for you find you." - Dan Harmon
|
21 |
+
+ Think process, not product.
|
22 |
+
+ People like to see how the sausage is made; what happens behind the scenes.
|
23 |
+
+ Document your work, intermediate steps in the process - helps you introspect and show others.
|
24 |
+
+ Share something small everday
|
25 |
+
+ "Put yourself and your work out there everyday and you'll start meeting some amazing people." - Bobby Solomon
|
26 |
+
+ Think of your boss and mother reading the stuff you share
|
27 |
+
+ Flow - small steps v/s Stock - big milestones
|
28 |
+
+ Design your process so that your little flows culminate into stock
|
29 |
+
|
30 |
+
<!-- ### A few good illustrations from the book
|
31 |
+
|
32 |
+
<div class="gallery">
|
33 |
+
<img src="https://live.staticflickr.com/6215/6289302147_38e8035680.jpg" alt="Good Theft vs Bad Theft " width="auto" height="300">
|
34 |
+
<img src="https://live.staticflickr.com/6109/6998009409_bd8679529b.jpg" alt="Garbage In, Garbage Out" width="auto" height="300">
|
35 |
+
</div> -->
|
36 |
+
|
37 |
+
### My Thoughts
|
38 |
+
|
39 |
+
|
books/steal_like_an_artist.md
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
date: 2024-01-15
|
3 |
+
genre: Self-Help
|
4 |
+
title: Steal Like an Artist
|
5 |
+
author: Austin Kleon
|
6 |
+
cover_img_url: https://live.staticflickr.com/8209/8167875453_6e2cd6b9e2_m.jpg
|
7 |
+
book_url: https://www.audible.in/pd/The-Steal-Like-an-Artist-Audio-Trilogy-Audiobook/B0B6QCC6TM
|
8 |
+
tags: []
|
9 |
+
---
|
10 |
+
|
11 |
+
### The Good Stuff
|
12 |
+
|
13 |
+
+ "All advice is autobiographical"
|
14 |
+
+ Copy great work, fall short, adapt and create your own version
|
15 |
+
+ "Garbage in, garbage out."
|
16 |
+
+ Do the work you want to see get done,
|
17 |
+
build the product you want to use,
|
18 |
+
create the music you want to listen to
|
19 |
+
+ Just doing things you know how to ends up boring
|
20 |
+
+ Use your hands, move your body
|
21 |
+
+ Side projects / hobbies are important, protect and nurture them
|
22 |
+
+ "Don't throw any parts of yourself away"
|
23 |
+
+ "Don't worry about unity [of your work] from piece to piece - what unifies all of your work is the fact that you made it"
|
24 |
+
+ "You can't connect the dots looking forward,
|
25 |
+
you can only connect them looking backwards" - Steve Jobs
|
26 |
+
+ Do good work (the hard part),
|
27 |
+
share it with people (relatively easy - post about it online)
|
28 |
+
+ Forget about validation, write public fan letters
|
29 |
+
+ Do boring stuff, find time to get bored.
|
30 |
+
+ "Inertia is the death of creativity"
|
31 |
+
+ Build systems; track habits
|
32 |
+
+ Creativity is Subtraction - do less, say less
|
33 |
+
+ Constraints bring out the best work in you
|
34 |
+
- eg: Green Eggs and Ham by Dr. Seuss - written using only 50 words
|
35 |
+
+ Creativity isn't just what you put in, it's also what you leave out.
|
36 |
+
|
37 |
+
### A few good illustrations from the book
|
38 |
+
|
39 |
+
<div class="gallery">
|
40 |
+
<img src="https://live.staticflickr.com/6215/6289302147_38e8035680.jpg" alt="Good Theft vs Bad Theft " width="auto" height="300">
|
41 |
+
<img src="https://live.staticflickr.com/6109/6998009409_bd8679529b.jpg" alt="Garbage In, Garbage Out" width="auto" height="300">
|
42 |
+
</div>
|
43 |
+
|
44 |
+
### My Thoughts
|
45 |
+
|
46 |
+
One thing that stayed with me most is the advice to find time for your passion and protective of the piece.
|
47 |
+
Lot of these ideas are also discussed in books of Cal Newport.
|
48 |
+
The Steve Job quote reminds of something Eric Ries said about pieces of work culminating in a magnum opus.
|
49 |
+
Austin Kleon keeps the books short and to the point. It was a good listen, and I am looking forward to the next one in the trilogy!
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
MonsterUI
|
2 |
+
python-fasthtml
|
3 |
+
python-frontmatter
|