Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/data/blooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class Bloom:


def add_bloom(*, sender: User, content: str) -> Bloom:
hashtags = [word[1:] for word in content.split(" ") if word.startswith("#")]

if len(content) > 280:
raise ValueError("Bloom content cannot exceed 280 characters")

hashtags = re.findall(r'#(\w+)', content)

now = datetime.datetime.now(tz=datetime.UTC)
bloom_id = int(now.timestamp() * 1000000)
Expand Down
6 changes: 3 additions & 3 deletions front-end/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Purple Forest</title>
<link href="/index.css" rel="stylesheet" />
<link href="index.css" rel="stylesheet" />
</head>
<body id="app">
<header>
<a href="/"
><h1>
<img
src="/logo.svg"
src="logo.svg"
alt="Purple Forest "
width="50"
height="60"
Expand Down Expand Up @@ -256,6 +256,6 @@ <h2 id="bloom-form-title" class="bloom-form__title">Share a Bloom</h2>
<p>Please enable JavaScript in your browser.</p>
</noscript>

<script type="module" src="/index.mjs"></script>
<script type="module" src="index.mjs"></script>
</body>
</html>
33 changes: 8 additions & 25 deletions front-end/views/hashtag.mjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
import {renderOne, renderEach, destroy} from "../lib/render.mjs";
import {renderOne, renderEach,} from "../lib/render.mjs";
import {
state,
apiService,
getLogoutContainer,
getLoginContainer,
getTimelineContainer,
getHeadingContainer,
} from "../index.mjs";
import {createLogin, handleLogin} from "../components/login.mjs";
import {createLogout, handleLogout} from "../components/logout.mjs";
import {createBloom} from "../components/bloom.mjs";
import {createHeading} from "../components/heading.mjs";

// Hashtag view: show all tweets containing this tag

function hashtagView(hashtag) {
destroy();

apiService.getBloomsByHashtag(hashtag);
// changed to only fetch hashtags when hashtag changes
if (state.currentHashtag !== hashtag) {
state.currentHashtag = hashtag;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

apiService is responsible for updating the state when it fetches - you shouldn't need to set this here yourself.

state.isLoadingHashtag = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does this state do? I can't see it being used anywhere?

apiService.getBloomsByHashtag(hashtag);
}

renderOne(
state.isLoggedIn,
getLogoutContainer(),
"logout-template",
createLogout
);
document
.querySelector("[data-action='logout']")
?.addEventListener("click", handleLogout);
renderOne(
state.isLoggedIn,
getLoginContainer(),
"login-template",
createLogin
);
document
.querySelector("[data-action='login']")
?.addEventListener("click", handleLogin);


renderOne(
state.currentHashtag,
Expand Down