Skip to content

Commit

Permalink
chore: clean up codebase and code organization (rupali-codes#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal authored Jun 13, 2023
1 parent 696bead commit 706aa6a
Show file tree
Hide file tree
Showing 89 changed files with 1,633 additions and 1,609 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
}
18 changes: 6 additions & 12 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@

# Security Policy




## Introduction

This document outlines the security policy for the [Linkshub](https://linkshub.vercel.app/) open source project that provides links to websites for courses across the internet. The policy is intended to provide guidelines and procedures for reporting, triaging, and addressing security vulnerabilities in the project.

## Scope

The security policy covers the codebase and documentation of the open source project, as well as the external links to websites for courses.

## Vulnerability Disclosure Process

The project will provide a dedicated email address (rupali7487@gmail.com) for submitting vulnerability reports related to the [Linkshub](https://linkshub.vercel.app/) website or any of the linked websites. Vulnerability reports will be reviewed and triaged by the project's maintainers. The owner will aim to respond to vulnerability reports within 72 hours, and will provide regular updates on the status of the vulnerability and any remediation efforts.

## Roles and Responsibilities

The maintainers are responsible for handling vulnerability reports and making decisions about how to address them. They will also work with contributors and external website owners to resolve the issue(s) as quickly as possible.



## Response Timeline

LinksHub will aim to resolve critical vulnerabilities within 30 days and non-critical vulnerabilities within 90 days. These deadlines may extend if additional time is needed to address the issue(s).


## Secure Coding Practices
## Secure Coding Practices

LinksHub will provide guidance on secure coding practices for contributors, including guidelines for input validation, authentication, authorization, and data protection.

## Regular Review and Update

The security policy will be regularly reviewed and updated to ensure that it remains effective and relevant. The maintainers will evaluate the vulnerability disclosure process, update secure coding guidelines, and revise the response timeline as needed.

## Disclosure Policy

LinksHub will follow a coordinated disclosure policy, which means that vulnerabilities will be disclosed publicly only after they have been remediated. The project may work with external website owners to coordinate disclosure of vulnerabilities that affect their websites.


## Legal Disclaimer

The security policy includes a legal disclaimer that limits the liability of the project maintainers and contributors for any security vulnerabilities or incidents that occur as a result of using[Linkshub's](https://linkshub.vercel.app/) website or any of the linked sources.


## Contact Information

If you have any questions or concerns about the security policy or any security vulnerabilities in the project, please contact us at _linkshub.opensource@gmail.com_.


By implementing this security policy, we aim to ensure that vulnerabilities are addressed in a timely manner, and that users and contributors can use [Linkshub](https://linkshub.vercel.app/) and its linked sources safely and securely.

2 changes: 1 addition & 1 deletion app/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SCROLL_LIMIT = 200;
export const SCROLL_LIMIT = 200
10 changes: 5 additions & 5 deletions assets/icons/SearchIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { SVGProps } from "react";
import React from 'react'
import { SVGProps } from 'react'
const SearchIcon = ({ ...rest }: SVGProps<SVGSVGElement>) => {
return (
<svg
Expand All @@ -15,7 +15,7 @@ const SearchIcon = ({ ...rest }: SVGProps<SVGSVGElement>) => {
clipRule="evenodd"
></path>
</svg>
);
};
)
}

export default SearchIcon;
export default SearchIcon
8 changes: 4 additions & 4 deletions components/Aside/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FC } from "react";
import { SideNavbarBody } from "components/SideNavbar/SideNavbarBody";
import { FC } from 'react'
import { SideNavbarBody } from 'components/SideNavbar/SideNavbarBody'

export const Aside: FC<{}> = () => {
return (
<aside className="fixed top-[76px] left-0 z-[20] hidden h-screen w-[290px] lg:block">
<SideNavbarBody />
</aside>
);
};
)
}
46 changes: 23 additions & 23 deletions components/BackToTop/BackToTopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import React, { useEffect, useState } from "react";
import { useTransition } from "react-transition-state";
import { FaArrowUp } from "react-icons/fa";
import { SCROLL_LIMIT } from "app/constants";
import React, { useEffect, useState } from 'react'
import { useTransition } from 'react-transition-state'
import { FaArrowUp } from 'react-icons/fa'
import { SCROLL_LIMIT } from 'app/constants'

export const BackToTopButton = () => {
const [scrollY, setScrollY] = useState(0);
const [scrollY, setScrollY] = useState(0)
const [{ isMounted, status }, toggle] = useTransition({
mountOnEnter: true,
unmountOnExit: true,
preEnter: true,
});
})

useEffect(() => {
const handleScroll = () => {
setScrollY(window.scrollY);
};
setScrollY(window.scrollY)
}

handleScroll();
handleScroll()

window.addEventListener("scroll", handleScroll);
window.addEventListener('scroll', handleScroll)

return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);
window.removeEventListener('scroll', handleScroll)
}
}, [])

useEffect(() => {
toggle(scrollY > SCROLL_LIMIT);
}, [scrollY]);
toggle(scrollY > SCROLL_LIMIT)
}, [scrollY])

const handleClick = () => {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};
behavior: 'smooth',
})
}

return isMounted ? (
<div
className={`group fixed z-20 bottom-12 right-12 transform transition duration-300${
status === "preEnter" || status === "exiting"
? " opacity-0 translate-y-3"
: ""
status === 'preEnter' || status === 'exiting'
? ' opacity-0 translate-y-3'
: ''
}`}
>
<button
Expand All @@ -55,5 +55,5 @@ export const BackToTopButton = () => {
👾
</span>
</div>
) : null;
};
) : null
}
2 changes: 1 addition & 1 deletion components/BackToTop/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { BackToTopButton } from "./BackToTopButton";
export { BackToTopButton } from './BackToTopButton'
17 changes: 10 additions & 7 deletions components/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { FC } from "react";
import { createPortal } from "react-dom";
import { FC } from 'react'
import { createPortal } from 'react-dom'

export const Backdrop: FC<{ onClick: (() => void) | undefined, className?: string | undefined }> = (props) => {
const { onClick, className } = props;
export const Backdrop: FC<{
onClick: (() => void) | undefined
className?: string | undefined
}> = (props) => {
const { onClick, className } = props

return createPortal(
<div
<div
className={`fixed inset-0 z-50 h-full w-full cursor-pointer bg-black/80 ${className}`}
onClick={onClick}
></div>,
document.getElementById('backdrop-root')!
);
};
)
}
29 changes: 19 additions & 10 deletions components/Cards/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { FC,useState, useRef, useEffect } from 'react'
import { FC, useState, useRef, useEffect } from 'react'
import { BsBoxArrowUpRight } from 'react-icons/bs'
import { CopyToClipboard } from 'components/CopyToClipboard'
import type { IData } from 'types'

const Card: FC<{ data: IData }> = (props) => {
const { data } = props
const { name, description, url } = data
const descriptionRef = useRef(document.createElement("p"));
const [isOverflow, setIsOverflow] = useState(false);
useEffect (() => {
setIsOverflow(descriptionRef.current?.scrollHeight > descriptionRef.current?.offsetHeight);
const descriptionRef = useRef(document.createElement('p'))
const [isOverflow, setIsOverflow] = useState(false)
useEffect(() => {
setIsOverflow(
descriptionRef.current?.scrollHeight >
descriptionRef.current?.offsetHeight
)
}, [])

return (
Expand All @@ -25,11 +28,17 @@ const Card: FC<{ data: IData }> = (props) => {
<CopyToClipboard url={url} />
</header>
<div className="h-[7rem]">
<p ref={descriptionRef} className="h-24 w-full overflow-hidden font-sans text-ellipsis line-clamp-4">{description}</p>
{
(isOverflow) &&
<p className="text-sm underline text-violet-600 dark:text-violet-400 text-right hover:text-violet-400 dark:hover:text-violet-300" >Read More</p>
}
<p
ref={descriptionRef}
className="h-24 w-full overflow-hidden font-sans text-ellipsis line-clamp-4"
>
{description}
</p>
{isOverflow && (
<p className="text-sm underline text-violet-600 dark:text-violet-400 text-right hover:text-violet-400 dark:hover:text-violet-300">
Read More
</p>
)}
</div>
<footer className="card-actions justify-end">
<a
Expand Down
51 changes: 25 additions & 26 deletions components/Cards/CardsList.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
import { FC, useState } from "react";
import { BackToTopButton } from "../BackToTop/BackToTopButton";
import Popup from "components/popup";
import CardsListItem from "./CardsListItem";
import type { IData } from "types";
import { FC, useState } from 'react'
import { BackToTopButton } from '../BackToTop/BackToTopButton'
import Popup from 'components/popup'
import CardsListItem from './CardsListItem'
import type { IData } from 'types'

const CardsList:FC<{ cards: IData[] }> = (props) => {
const { cards } = props;
const [currentCard, setCurrentCard] = useState<IData | null>(null);
const CardsList: FC<{ cards: IData[] }> = (props) => {
const { cards } = props
const [currentCard, setCurrentCard] = useState<IData | null>(null)

const getCardId = (item: IData | null) => {
setCurrentCard(item);
};
setCurrentCard(item)
}

const removeCurrentCard = () => {
setCurrentCard(null);
setCurrentCard(null)
}

cards.sort((a: IData, b: IData) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});
if (a.name < b.name) return -1
if (a.name > b.name) return 1
return 0
})

return (
<>
<ul className={`flex w-full w-full flex-wrap content-start gap-4 md:flex-row`}>
<ul
className={`flex w-full w-full flex-wrap content-start gap-4 md:flex-row`}
>
{cards.map((data: IData) => (
<CardsListItem
<CardsListItem
key={data.id}
data={data}
onClick={() => getCardId(data)}
data={data}
onClick={() => getCardId(data)}
/>
))}
</ul>
<BackToTopButton />
<Popup
currentCard={currentCard}
onClose={removeCurrentCard}
/>
<Popup currentCard={currentCard} onClose={removeCurrentCard} />
</>
);
};
)
}

export default CardsList;
export default CardsList
14 changes: 7 additions & 7 deletions components/Cards/CardsListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FC } from "react";
import Card from "./Card";
import type { IData } from "types";
import { FC } from 'react'
import Card from './Card'
import type { IData } from 'types'

const CardsListItem: FC<{ data: IData, onClick: () => void }> = (props) => {
const { data, onClick } = props;
const CardsListItem: FC<{ data: IData; onClick: () => void }> = (props) => {
const { data, onClick } = props

return (
<li
<li
className="w-full cursor-pointer transition-all duration-100 ease-in hover:scale-[1.02] md:w-72"
onClick={onClick}
>
Expand All @@ -15,4 +15,4 @@ const CardsListItem: FC<{ data: IData, onClick: () => void }> = (props) => {
)
}

export default CardsListItem;
export default CardsListItem
8 changes: 4 additions & 4 deletions components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const Footer: FC = () => {
<p className="leading-7 tracking-wide text-center text-black dark:text-violet-400">
<span>&copy; {new Date().getFullYear()} LinksHub | </span>
Developed by{' '}
<Link
href="https://linkfree.io/rupali-codes"
target="_blank"
<Link
href="https://linkfree.io/rupali-codes"
target="_blank"
rel="noopener noreferrer"
>
<span className="dark:text-gray-200 underline">Rupali Haldiya</span>
Expand All @@ -21,7 +21,7 @@ export const Footer: FC = () => {
rel="noopener noreferrer"
>
<span className="dark:text-gray-200 underline">
Open Source Community
Open Source Community
</span>
</Link>
</p>
Expand Down
2 changes: 1 addition & 1 deletion components/Footer/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import { Footer } from './Footer'
import { Footer } from './Footer'
Loading

0 comments on commit 706aa6a

Please sign in to comment.