ππ» myapp44μμλ myapp43νλ‘μ,νλ‘μ 리μ€νΈμ²λΌ μλ¦Όμ pinafore ν
λ§μ ν¬ν¨μν΅λλ€.
In myapp44, notificationsβsimilar to the following and follower lists in myapp43βare included in the Pinafore theme.
ππ» μλ¦Ό APIλ κΈ°μ‘΄μ κ²μ μ¬νμ©ν©λλ€.(app/api/v1/notifications/route.ts)
The notification API reuses the existing one (app/api/v1/notifications/route.ts)
ππ» μ 체 μ½λλ κΉνλΈμμ νμΈ ν μ μμ΅λλ€.
You can find the full code on GitHub.
https://github.com/gideonslife01/flm-nextjs
π μ 체 νλ‘μ νΈ κ΅¬μ‘° / Overall Project Structure
myapp project/
βββ app/ (Next.js App Router)
β βββ .well-known/webfinger/route.ts -> webfinger
β βββ api/follow/route.ts -> Follow API(temporary)
β βββ api/announce/route.ts -> Boost(Announcement)
β βββ api/like/route.ts. -> Like API
β βββ api/posts/route.ts -> Writing API
β βββ api/timeline/route.ts -> Timeline API
β βββ api/followinglist/route.ts -> followinglist API
β βββ api/followerslist/route.ts -> followerslist API
β βββ api/v1/instance/route.ts -> auth
β βββ api/v1/apps/route.ts. -> auth
β βββ api/v1/accounts/verify_credentials/route.ts -> auth
β βββ api/v1/statuses/route.ts -> Write Post
β βββ api/v1/timelines/home/route.ts -> timeline
β βββ oauth/authorize/route.ts -> auth
β βββ oauth/token/route.ts -> auth
β βββ api/v1/search/home/route.ts -> search
β βββ api/v2/search/home/route.ts -> search
β βββ api/v1/accounts/[id]/followers/route.ts -> followers
β βββ api/v1/accounts/[id]/following/route.ts -> following
β βββ api/auth/signup/route.ts -> Signup
β βββ api/auth/login/route.ts -> Login
β βββ api/auth/logout/route.ts -> Logout
β βββ api/auth/refresh/route.ts -> Refresh Token
β βββ api/auth/me/route.tsx -> Login Check
β βββ auth/signup/page.tsx -> Signup UI
β βββ auth/signup/page.tsx -> Login UI
β βββ users/[username]/
β β βββ statuses/[id]/route.ts -> Indivisual Post
β β βββ route.ts -> Acotr Information
β β βββ followers/route.ts -> Followers List
β β βββ following/route.ts -> Following List
β β βββ inbox/route.ts -> Inbox
β β βββ outbox/route.ts -> outbox
β βββ usersui/[username]/
β β βββ page.tsx -> Timeline UI(Server, 404)
β β βββ ClientPage.tsx. -> Timeline UI(Client,Call Active Themes)
β β βββ _components/themes/
β β βββ themeex/ThemeexTheme.tsx -> Example Theme
β β βββ pinafore/PinaforeTheme.tsx -> Theme 1
β β βββ pinafore/FollowersList.tsx -> Theme 1, FollowersList
β β βββ pinafore/FollowingList.tsx -> Theme 1, FollowingList
β β βββ pinafore/NotificationsList.tsx -> Theme 1, NotificationsList
β β βββ mastodon/MastodonTheme.tsx -> Theme 2
β β βββ minimal/MinimaltTheme.tsx -> Theme 3
β βββ layout.tsx, page.tsx, globals.css
β βββ favicon.ico
βββ lib/
β βββ theme.tsx -> Theme Provider
β βββ watchThemes.ts -> Check real-time theme changes
β βββ auth.ts -> Authentication, User Management
β βββ ap.ts -> Follow,Undo,Create,Likes,Announce
β βββ db.ts -> DB connection
βββ data/
β βββ keys/userIDs/ -> private.pem, public.pem(New)
β βββ keys/ -> private.pem, public.pem(legacy)
βββ data.sqlite -> Database(1/3)
βββ data.sqlite-wal -> Database(2/3)
βββ data.sqlite-shm -> Database(3/3)
βββ Caddyfile -> https
βββ instrumentation.ts -> Background Server
βββ package.json
π νλ‘μ νΈ μμ / Project Start
π μ½λ μμ / Code modification
βοΈ next.config.ts
— ν
λ§νμΌμμ notifications λΆλΆμ 보μ¬μ£ΌκΈ° μν΄μ initialview μ μ‘ μ½λλ₯Ό μΆκ°ν©λλ€.
Add the code to pass the initialView in order to display the notifications section in the theme file.
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* allow domain*/
allowedDevOrigins: ['aloy-horizon.duckdns.org', '*.duckdns.org'],
/* host.domain.org/@userid */
async rewrites() {
return [
{
source: '/@:username',
destination: '/usersui/:username',
},
{
source: '/@:username/following',
destination: '/usersui/:username?view=following', // β
myapp43 - initialView
},
{
source: '/@:username/followers',
destination: '/usersui/:username?view=followers',
},
{ source: '/@:username/notifications', // β
myapp44 - initialView for notifications
destination: '/usersui/:username?view=notifications'
},
]
},
};
export default nextConfig;
βοΈ notificationλΌμ°νΈλ λ°λ‘ λ§λ€μ§ μκ³ κΈ°μ‘΄ λΌμ°νΈλ₯Ό μ¬νμ©ν©λλ€.
Instead of creating a separate notification route, the existing route is reused.
— app/api/v1/notifications/route.ts
βοΈ μν°λΈ ν
λ§ κΈ°λ₯μΌλ‘ ν
λ§λλ ν 리 λ΄μ νμΌμ΄λ¦μ “List”κ° μμΌλ©΄ ν
λ§νμΌλ‘ μΈμνμ§ μμ΅λλ€.(μ΄μ νλ‘μ νΈμμ μ²λ¦¬ ν¨.)
Due to the active theme feature, files in the theme directory with “List” in their names are not recognized as theme files (this was handled in a previous project).
— lib/watchThemes
βοΈ app/usersui/[username]/_components/theme/pinafore/PinaforeTheme.tsx
— λ³μμ λ¬ / Variable passing : paget.tsx -> ClientPage.tsx -> pinafore/PinaforeTheme.tsx
— initialview(=view)λ³μμ μ λ¬μ myap43μμ μ²λ¦¬νκΈ° λλ¬Έμ ν
λ§νμΌμμλ§ μμ ν©λλ€.
Since the passing of the initialview (or view) variable is handled in myap43, you only need to make modifications in the theme file.
— Home λ²νΌν΄λ¦μλ νμλΌμΈμ΄ 보μ΄λλ‘ μμ ν©λλ€.
The Home button is being modified so that the timeline appears when clicked.
... ...
import NotificationsList from './NotificationsList'; // β
myapp44
... ...
export function PinaforeTheme({ timeline, username, initialView, onBoost, onLike }: any) {
... ...
// β
myapp43 + myapp44
const [view, setView] = useState<'timeline' | 'followers' | 'following' | 'notifications'>(initialView || 'timeline');
... ...
{/** β
myapp44 */}
<button
onClick={(e) => switchView(e, 'timeline')}
style={{ fontWeight: view === 'timeline' ? 800 : 400 }}
>
π Home
</button>
<button
onClick={(e) => switchView(e, 'notifications')}
style={{ fontWeight: view === 'notifications' ? 800 : 400 }}
>
π Notifications
</button>
... ...
{view === 'notifications' && (
<NotificationsList username={username} style={{ padding: '0' }} />
)}
}
π ν μ€νΈ / Test

μν볡μ 8μ₯ 32μ / John 8:32
“κ·Έλ¦¬κ³ λν¬λ μ§λ¦¬λ₯Ό μκ² λ κ²μ΄λ©°, μ§λ¦¬κ° λν¬λ₯Ό μμ λ‘κ² ν κ²μ΄λ€.”
“Then you will know the truth ,and the truth will set you free”