Skip to content

Commit 2af1d0a

Browse files
Merge branch 'main' into feature-toast_notifications
2 parents 8514b44 + 3d72ed1 commit 2af1d0a

4 files changed

Lines changed: 40 additions & 158 deletions

File tree

app/api/papers/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export async function POST(req: NextRequest) {
6767
}
6868

6969
//Validate files before buffering
70-
const maxBytes = 25 * 1024 * 1024
70+
const maxBytes = 10 * 1024 * 1024
7171
const allowed = new Set([
7272
'application/pdf',
7373
'image/png',
@@ -82,7 +82,7 @@ export async function POST(req: NextRequest) {
8282
}
8383
if ((file.size ?? 0) > maxBytes) {
8484
return NextResponse.json(
85-
{ message: 'File uploaded is too large' },
85+
{ message: 'File size must not exceed 10MB' },
8686
{ status: 413 }
8787
)
8888
}

app/quick-reads/page.tsx

Lines changed: 33 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,7 @@ const markdownComponents = {
3737
if (inline) {
3838
return (
3939
<code
40-
style={{
41-
backgroundColor: '#f0f0f0',
42-
color: '#24292e',
43-
padding: '0.2em 0.4em',
44-
margin: '0 0.2em',
45-
borderRadius: '3px',
46-
fontFamily: 'monospace',
47-
fontSize: '0.85em',
48-
whiteSpace: 'normal',
49-
fontStyle: 'normal',
50-
}}
40+
className="bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100 px-1.5 py-0.5 mx-0.5 rounded-sm font-mono text-[0.85em]"
5141
{...props}
5242
>
5343
{children}
@@ -56,11 +46,7 @@ const markdownComponents = {
5646
}
5747
return (
5848
<code
59-
style={{
60-
fontFamily: 'monospace',
61-
fontSize: '0.85em',
62-
color: '#24292e',
63-
}}
49+
className="font-mono text-[0.85em] text-gray-900 dark:text-gray-100"
6450
{...props}
6551
>
6652
{children}
@@ -70,14 +56,7 @@ const markdownComponents = {
7056
pre({ node, children, ...props }: MarkdownComponentProps) {
7157
return (
7258
<pre
73-
style={{
74-
backgroundColor: '#f6f8fa',
75-
padding: '16px',
76-
overflow: 'auto',
77-
borderRadius: '6px',
78-
border: '1px solid #d0d7de',
79-
marginBottom: '16px',
80-
}}
59+
className="bg-gray-50 dark:bg-gray-800/50 p-4 overflow-auto rounded-md border border-gray-200 dark:border-gray-700 mb-4"
8160
{...props}
8261
>
8362
{children}
@@ -86,7 +65,7 @@ const markdownComponents = {
8665
},
8766
p({ node, children, ...props }: MarkdownComponentProps) {
8867
return (
89-
<p style={{ marginBottom: '0.5em', lineHeight: '1.6' }} {...props}>
68+
<p className="mb-2 leading-relaxed" {...props}>
9069
{children}
9170
</p>
9271
)
@@ -95,16 +74,7 @@ const markdownComponents = {
9574
return (
9675
<a
9776
href={href}
98-
style={{
99-
color: '#0969da',
100-
textDecoration: 'none',
101-
cursor: 'pointer',
102-
borderBottom: '1px solid #0969da',
103-
}}
104-
onMouseEnter={(e) =>
105-
(e.currentTarget.style.textDecoration = 'underline')
106-
}
107-
onMouseLeave={(e) => (e.currentTarget.style.textDecoration = 'none')}
77+
className="text-blue-600 dark:text-blue-400 no-underline border-b border-blue-600 dark:border-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:border-blue-800 dark:hover:border-blue-300"
10878
{...props}
10979
>
11080
{children}
@@ -113,61 +83,29 @@ const markdownComponents = {
11383
},
11484
h1({ node, children, ...props }: MarkdownComponentProps) {
11585
return (
116-
<h1
117-
style={{
118-
fontSize: '2em',
119-
fontWeight: 'bold',
120-
marginBottom: '0.5em',
121-
marginTop: '1em',
122-
}}
123-
{...props}
124-
>
86+
<h1 className="text-2xl font-bold mb-2 mt-4 text-gray-900 dark:text-gray-100" {...props}>
12587
{children}
12688
</h1>
12789
)
12890
},
12991
h2({ node, children, ...props }: MarkdownComponentProps) {
13092
return (
131-
<h2
132-
style={{
133-
fontSize: '1.5em',
134-
fontWeight: 'bold',
135-
marginBottom: '0.4em',
136-
marginTop: '0.8em',
137-
}}
138-
{...props}
139-
>
93+
<h2 className="text-xl font-bold mb-1.5 mt-3 text-gray-900 dark:text-gray-100" {...props}>
14094
{children}
14195
</h2>
14296
)
14397
},
14498
h3({ node, children, ...props }: MarkdownComponentProps) {
14599
return (
146-
<h3
147-
style={{
148-
fontSize: '1.25em',
149-
fontWeight: 'bold',
150-
marginBottom: '0.3em',
151-
marginTop: '0.6em',
152-
}}
153-
{...props}
154-
>
100+
<h3 className="text-lg font-bold mb-1 mt-2 text-gray-900 dark:text-gray-100" {...props}>
155101
{children}
156102
</h3>
157103
)
158104
},
159105
blockquote({ node, children, ...props }: MarkdownComponentProps) {
160106
return (
161107
<blockquote
162-
style={{
163-
borderLeft: '4px solid #d1d9e0',
164-
color: '#57606a',
165-
paddingLeft: '16px',
166-
marginLeft: '0',
167-
marginRight: '0',
168-
marginTop: '0',
169-
marginBottom: '16px',
170-
}}
108+
className="border-l-4 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 pl-4 my-2"
171109
{...props}
172110
>
173111
{children}
@@ -642,15 +580,18 @@ export default function QuickReads() {
642580
<div className="container mx-auto p-4 md:p-8 max-w-7xl">
643581
{/* Toast */}
644582
{toast && (
645-
<div className="fixed top-4 right-4 z-[60] max-w-sm animate-in slide-in-from-top-2 fade-in duration-300">
646-
<div className="bg-yellow-50 dark:bg-yellow-900/30 border border-yellow-200 dark:border-yellow-700 text-yellow-800 dark:text-yellow-200 px-4 py-3 rounded-lg shadow-lg flex items-start gap-3">
647-
<ClipboardList className="h-5 w-5 mt-0.5 shrink-0" />
648-
<p className="text-sm font-medium">{toast}</p>
583+
<div className="fixed top-20 right-6 z-[100] max-w-sm animate-in slide-in-from-top-2 fade-in duration-300">
584+
<div className="bg-yellow-50 dark:bg-zinc-950 border border-yellow-200 dark:border-yellow-600/50 text-yellow-900 dark:text-yellow-50 px-4 py-3 rounded-lg shadow-[0_8px_30px_rgb(0,0,0,0.12)] dark:shadow-[0_8px_30px_rgba(234,179,8,0.1)] flex items-start gap-3 backdrop-blur-md">
585+
<div className="bg-yellow-100 dark:bg-yellow-500/20 p-1 rounded-md shrink-0 mt-0.5">
586+
<ClipboardList className="h-4 w-4 text-yellow-700 dark:text-yellow-400" />
587+
</div>
588+
<p className="text-sm font-medium leading-relaxed mt-0.5">{toast}</p>
649589
<button
650590
onClick={() => setToast(null)}
651-
className="ml-auto text-yellow-600 hover:text-yellow-800"
591+
aria-label="Close toast"
592+
className="ml-auto text-yellow-600 dark:text-yellow-500 hover:text-yellow-800 dark:hover:text-yellow-300 mt-0.5"
652593
>
653-
594+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
654595
</button>
655596
</div>
656597
</div>
@@ -810,14 +751,7 @@ export default function QuickReads() {
810751

811752
{/* Editor / Preview pane */}
812753
{showPreview ? (
813-
<div
814-
className="max-w-none min-h-[400px]"
815-
style={{
816-
padding: '24px',
817-
backgroundColor: '#ffffff',
818-
color: '#24292e',
819-
}}
820-
>
754+
<div className="max-w-none min-h-[400px] p-6 bg-white dark:bg-background text-gray-900 dark:text-gray-100">
821755
{editContent ? (
822756
<ReactMarkdown
823757
remarkPlugins={[remarkGfm]}
@@ -826,7 +760,7 @@ export default function QuickReads() {
826760
{editContent}
827761
</ReactMarkdown>
828762
) : (
829-
<p style={{ fontStyle: 'italic', color: '#6a737d' }}>
763+
<p className="italic text-gray-500 dark:text-gray-400">
830764
Nothing to preview.
831765
</p>
832766
)}
@@ -859,8 +793,8 @@ export default function QuickReads() {
859793
<span
860794
className={`text-[10px] px-2 py-0.5 rounded-full font-semibold border ${
861795
getVisibility() === 'college_only'
862-
? 'bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/30 dark:border-blue-800'
863-
: 'bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-900/30 dark:border-emerald-800'
796+
? 'bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/30 dark:text-blue-300 dark:border-blue-800'
797+
: 'bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-300 dark:border-emerald-800'
864798
}`}
865799
>
866800
{getVisibility() === 'college_only' ? 'College Only' : 'Public'}
@@ -878,39 +812,12 @@ export default function QuickReads() {
878812
</div>
879813

880814
{/* Rendered content */}
881-
<div
882-
className="max-w-none min-h-[300px]"
883-
style={{
884-
padding: '24px',
885-
backgroundColor: '#ffffff',
886-
color: '#24292e',
887-
}}
888-
>
815+
<div className="max-w-none min-h-[300px] p-6 bg-white dark:bg-background text-gray-900 dark:text-gray-100">
889816
{getVisibility() === 'college_only' &&
890817
!session?.user?.email?.endsWith('@iiitl.ac.in') &&
891818
!canManage ? (
892-
<div
893-
style={{
894-
display: 'flex',
895-
flexDirection: 'column',
896-
alignItems: 'center',
897-
justifyContent: 'center',
898-
height: '250px',
899-
color: '#b45309', // amber-700
900-
backgroundColor: '#fffbeb', // amber-50
901-
border: '1px solid #fde68a', // amber-200
902-
borderRadius: '0.5rem',
903-
margin: '1rem',
904-
}}
905-
>
906-
<div
907-
style={{
908-
backgroundColor: '#fcd34d',
909-
padding: '16px',
910-
borderRadius: '50%',
911-
marginBottom: '16px',
912-
}}
913-
>
819+
<div className="flex flex-col items-center justify-center h-[250px] m-4 rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-700 dark:text-amber-400 border border-amber-200 dark:border-amber-800">
820+
<div className="bg-amber-300 dark:bg-amber-700 p-4 rounded-full mb-4 text-amber-800 dark:text-amber-100">
914821
<svg
915822
xmlns="http://www.w3.org/2000/svg"
916823
width="48"
@@ -926,22 +833,8 @@ export default function QuickReads() {
926833
<path d="M7 11V7a5 5 0 0 1 10 0v4" />
927834
</svg>
928835
</div>
929-
<h3
930-
style={{
931-
fontSize: '1.25rem',
932-
fontWeight: 'bold',
933-
marginBottom: '8px',
934-
}}
935-
>
936-
Restricted Access
937-
</h3>
938-
<p
939-
style={{
940-
fontSize: '0.875rem',
941-
maxWidth: '300px',
942-
textAlign: 'center',
943-
}}
944-
>
836+
<h3 className="text-xl font-bold mb-2">Restricted Access</h3>
837+
<p className="text-sm max-w-[300px] text-center">
945838
This file is marked as <strong>College Only</strong>. You must
946839
be logged in with a valid @iiitl.ac.in email address to view
947840
its contents.
@@ -955,20 +848,9 @@ export default function QuickReads() {
955848
{content}
956849
</ReactMarkdown>
957850
) : (
958-
<div
959-
style={{
960-
display: 'flex',
961-
flexDirection: 'column',
962-
alignItems: 'center',
963-
justifyContent: 'center',
964-
height: '192px',
965-
color: '#a0aec0',
966-
}}
967-
>
968-
<AlertCircle
969-
style={{ height: '32px', width: '32px', marginBottom: '8px' }}
970-
/>
971-
<p style={{ fontSize: '0.875rem' }}>
851+
<div className="flex flex-col items-center justify-center h-48 text-gray-400 dark:text-gray-500">
852+
<AlertCircle className="h-8 w-8 mb-2" />
853+
<p className="text-sm">
972854
This file is empty.{' '}
973855
{isLoggedIn && 'Click Edit to add content.'}
974856
</p>
@@ -1010,10 +892,10 @@ export default function QuickReads() {
1010892
<span
1011893
className={`px-1.5 py-0.5 rounded font-bold ${
1012894
pc.changeType === 'add'
1013-
? 'bg-green-100 text-green-700'
895+
? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400'
1014896
: pc.changeType === 'edit'
1015-
? 'bg-yellow-100 text-yellow-700'
1016-
: 'bg-red-100 text-red-700'
897+
? 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400'
898+
: 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400'
1017899
}`}
1018900
>
1019901
{pc.changeType.toUpperCase()}

app/upload-papers/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ const UploadPaperPage = () => {
132132
return
133133
}
134134

135-
// Validate file size (25MB max)
136-
const maxSize = 25 * 1024 * 1024 // 25MB in bytes
135+
// Validate file size (10MB max)
136+
const maxSize = 10 * 1024 * 1024 // 10MB in bytes
137137
if (formData.uploaded_file.size > maxSize) {
138138
const msg = 'File size must be less than 25MB'
139139
addToast(msg)
@@ -448,7 +448,7 @@ const UploadPaperPage = () => {
448448
: 'Click to upload file'}
449449
</p>
450450
<p className="text-xs text-muted-foreground">
451-
PDF, PNG, JPG, JPEG, WEBP (Max 25MB)
451+
PDF, PNG, JPG, JPEG, WEBP (Max 10MB)
452452
</p>
453453
</div>
454454
</div>
@@ -496,7 +496,7 @@ const UploadPaperPage = () => {
496496
</h4>
497497
<ul className="space-y-1 ml-4">
498498
<li>• Ensure the paper is clear and readable</li>
499-
<li>• Maximum file size: 25MB</li>
499+
<li>• Maximum file size: 10MB</li>
500500
<li>• Supported formats: PDF, PNG, JPG, JPEG, WEBP</li>
501501
<li>• All fields marked with * are required</li>
502502
<li>

middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export async function middleware(request: NextRequest) {
8787
// Check request size
8888
const contentLength = request.headers.get('content-length')
8989
if (contentLength && parseInt(contentLength) > MAX_REQUEST_SIZE) {
90-
return NextResponse.json({ message: 'Request too large' }, { status: 413 })
90+
return NextResponse.json({ message: 'File size exceeds the maximum limit of 10MB. Please upload a smaller file.' }, { status: 413 })
9191
}
9292

9393
// Check if the path needs rate limiting

0 commit comments

Comments
 (0)