Skip to content

Commit 9b9e10a

Browse files
author
Ahtesham Quraish
committed
adding code for curd operation
1 parent e51ab9c commit 9b9e10a

File tree

14 files changed

+676
-106
lines changed

14 files changed

+676
-106
lines changed

articles/validators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"ul",
1717
"li",
1818
# Links
19+
# blocks
20+
"iframe",
21+
"div",
1922
"a",
2023
# Images
2124
"figure",
@@ -33,7 +36,10 @@
3336
"attributes": {
3437
"a": {"href", "hreflang"},
3538
"img": {"alt", "height", "src", "width", "srcset", "sizes"},
36-
"figure": {"class"},
39+
"figure": {"class", "width", "style"},
40+
"div": {"class", "style", "data-oembed-url"},
41+
"h3": {"class"},
42+
"iframe": {"class", "style", "src", "width", "height", "frameborder", "allow", "allowfullscreen"},
3743
"oembed": {"url"},
3844
},
3945
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use client"
2+
import React from "react"
3+
import { ArticleDetail } from "ol-ckeditor"
4+
5+
const ArticleDetailPage: React.FC<{ articleId: number }> = ({ articleId }) => {
6+
return <ArticleDetail articleId={articleId} />
7+
}
8+
9+
export { ArticleDetailPage }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use client"
2+
import React from "react"
3+
import { CkeditorArticlesList } from "ol-ckeditor"
4+
5+
const ArticlesListPage: React.FC = () => {
6+
return <CkeditorArticlesList />
7+
}
8+
9+
export { ArticlesListPage }
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
"use client"
22
import React from "react"
3-
import { CKEditorClient } from "ol-ckeditor"
4-
import { ckeditorApi } from "api/clients"
3+
import { CkeditorArticle } from "ol-ckeditor"
54

6-
const ArticlesPage: React.FC = () => {
7-
const getCKEditorTokenFetchUrl = async () => {
8-
const response = await ckeditorApi.ckeditorRetrieve()
9-
return response.data.token
10-
}
11-
12-
return (
13-
<div>
14-
<CKEditorClient
15-
value={""}
16-
getCKEditorTokenFetchUrl={getCKEditorTokenFetchUrl}
17-
uploadUrl={process.env.NEXT_PUBLIC_CKEDITOR_UPLOAD_URL || ""}
18-
onChange={() => {}}
19-
/>
20-
</div>
21-
)
5+
const ArticlesPage: React.FC<{ articleId: number }> = ({ articleId }) => {
6+
return <CkeditorArticle articleId={articleId} />
227
}
238

249
export { ArticlesPage }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react"
2+
import { Metadata } from "next"
3+
import { standardizeMetadata } from "@/common/metadata"
4+
import { ArticleDetailPage } from "@/app-pages/Articles/ArticleDetailPage"
5+
6+
export const metadata: Metadata = standardizeMetadata({
7+
title: "Article Detail",
8+
})
9+
10+
interface PageProps {
11+
params: {
12+
id: number
13+
}
14+
}
15+
16+
const Page: React.FC<PageProps> = ({ params }) => {
17+
return <ArticleDetailPage articleId={params.id} />
18+
}
19+
20+
export default Page
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from "react"
2+
import { Metadata } from "next"
3+
import { standardizeMetadata } from "@/common/metadata"
4+
import { ArticlesPage } from "@/app-pages/Articles/ArticlesPage"
5+
6+
export const metadata: Metadata = standardizeMetadata({
7+
title: "Article Detail",
8+
})
9+
10+
interface PageProps {
11+
params: {
12+
id: number
13+
}
14+
}
15+
16+
const Page: React.FC<PageProps> = ({ params }) => {
17+
return <ArticlesPage articleId={params.id} />
18+
}
19+
20+
export default Page
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from "react"
2+
import { Metadata } from "next"
3+
import { standardizeMetadata } from "@/common/metadata"
4+
import { ArticlesListPage } from "@/app-pages/Articles/ArticlesListPage"
5+
6+
export const metadata: Metadata = standardizeMetadata({
7+
title: "Articles List",
8+
})
9+
10+
const Page: React.FC<PageProps<"/articles/list">> = () => {
11+
return <ArticlesListPage />
12+
}
13+
14+
export default Page
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"use client"
2+
3+
import React from "react"
4+
import { useArticleDetail } from "api/hooks/articles"
5+
import "ckeditor5/ckeditor5.css"
6+
import "./styles.css"
7+
8+
export const ArticleDetail = ({ articleId }: { articleId: number }) => {
9+
const id = Number(articleId)
10+
const { data, isLoading } = useArticleDetail(id)
11+
12+
if (isLoading) {
13+
return (
14+
<div className="article-detail-container">
15+
<div className="loader">Loading article...</div>
16+
</div>
17+
)
18+
}
19+
20+
if (!data) {
21+
return (
22+
<div className="article-detail-container">
23+
<p className="empty">Article not found.</p>
24+
</div>
25+
)
26+
}
27+
28+
return (
29+
<div className="article-detail-container">
30+
<h1 className="article-title">{data.title}</h1>
31+
32+
{/* Render article HTML */}
33+
<div
34+
className="ck-content"
35+
dangerouslySetInnerHTML={{ __html: data.html }}
36+
/>
37+
</div>
38+
)
39+
}

0 commit comments

Comments
 (0)