Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate GitHub sync #389

Merged
merged 22 commits into from
Oct 25, 2020
Merged
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
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
<a href="https://travis-ci.org/taniarascia/takenote"><img src="https://travis-ci.org/taniarascia/takenote.svg?branch=master"></a>
</p>

<p align="center">A free, open-source notes app for the web. (WIP)</p>
<p align="center">A free, open-source notes app for the web. (Demo only)</p>

> **Warning**: TakeNote is in active development. You can visit [takenote.dev](https://takenote.dev) to see the work in progress, but your account and the notes you create are **temporary** will not be persisted. All data will be lost once GitHub integration is complete.
> **Note**: TakeNote is available as a demo only. You can use the app at [takenote.dev](https://takenote.dev) but the notes are only persisted in temporary local storage. However, you can download all notes as a zip.
![Screenshot](./assets/takenote-light.png)

## Features

- Open source and web-based
- Plain text notes
- Markdown preview
- Syntax highlighting
Expand All @@ -35,7 +34,39 @@

> _"I think the lack of extra crap is a feature."_ — Craig Lam
## Setup
TakeNote is a note-taking app for the web. You can use the demo app at [takenote.dev](https://takenote.dev). It is a static site without a database and does not sync your notes to the cloud. The notes are persisted temporarily in local storage, but you can download all notes in markdown format as a zip.

Hidden within the code is an alternate version that contain a Node/Express server and integration with GitHub. This version involves creating an OAuth application for GitHub and signing up to it with private repository permissions. Instead of backing up to local storage, your notes will back up to a private repository in your account called `takenote-data`. Due to the following reasons I'm choosing not to deploy or maintain this portion of the application:

- I do not want to maintain a free app with users alongside my career and other commitments
- I do not want to request private repository permissions from users
- I do not want to maintain an active server
- I do not want to worry about GitHub rate limiting from the server
- There is no way to batch create many files from the GitHub API, leading to a suboptimal GitHub storage solution

However, I'm leaving the code available so you can feel free to host your own TakeNote instance or study the code for learning purposes. I do not provide support or guidance for these purposes.

TakeNote was created with TypeScript, React, Redux, Node, Express, Codemirror, Webpack, Jest, Cypress, Feather Icons, ESLint, and Mousetrap, among other awesome open-source software.

## Demo Development

Clone and install.

```bash
git clone git@github.com:taniarascia/takenote
cd takenote
npm i
```

Run a development server.

```bash
npm run client
```

## Full Application Development

In `src/client/sagas/index.ts` and `src/client/components/LandingPage.tsx`, change `isDemo` to false.

### Pre-Installation

Expand Down Expand Up @@ -213,6 +244,7 @@ Thanks goes to these wonderful people:

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## Acknowledgements
Expand Down
58 changes: 21 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.4",
"faker": "^5.1.0",
"html-webpack-plugin": "^4.5.0",
"html-webpack-plugin": "^5.0.0-alpha.7",
"husky": "^4.3.0",
"image-webpack-loader": "^7.0.1",
"jest": "^26.5.3",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "TakeNote",
"name": "A web-based note-taking app with GitHub sync and Markdown support.",
"name": "A free, open-source notes app for the web.",
"icons": [
{
"src": "favicon.ico",
Expand Down
58 changes: 49 additions & 9 deletions src/client/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
import { welcomeNote } from '@/api/welcomeNote'
import { scratchpadNote } from '@/api/scratchpadNote'
import { v4 as uuid } from 'uuid'
import dayjs from 'dayjs'

import { NoteItem, SyncPayload, SettingsState } from '@/types'

const scratchpadNote = {
id: uuid(),
text: `# Scratchpad
The easiest note to find.`,
category: '',
scratchpad: true,
favorite: false,
created: dayjs().format(),
}

const markdown = `# Welcome to Takenote!
TakeNote is a free, open-source notes app for the web. It is a demo project only, and does not integrate with any database or cloud. Your notes are saved in local storage and will not be permanently persisted. You can download all notes in markdown format as a zip.
View the source on [Github](https://github.com/taniarascia/takenote).
## Features
- Plain text notes
- Markdown preview
- Syntax highlighting
- Keyboard shortcuts
- Drag and drop
- Favorites and categories
- Multi-note actions
- Multi-cursor editing
- Light/dark theme
- Search notes
- Prettify notes
- No WYSIWYG
- No database
- No tracking or analytics`

const welcomeNote = {
id: uuid(),
text: markdown,
category: '',
favorite: false,
created: dayjs().format(),
}

type PromiseCallback = (value?: any) => void
type GetLocalStorage = (
key: string,
Expand Down Expand Up @@ -45,13 +88,6 @@ const getUserNotes = () => (resolve: PromiseCallback, reject: PromiseCallback) =
}
}

export const requestNotes = () => new Promise(getUserNotes())

export const requestCategories = () => new Promise(getLocalStorage('categories'))

export const requestSettings = () =>
new Promise(getLocalStorage('settings', 'Could not load settings'))

export const saveState = ({ categories, notes }: SyncPayload) =>
new Promise((resolve) => {
localStorage.setItem('categories', JSON.stringify(categories))
Expand All @@ -65,3 +101,7 @@ export const saveState = ({ categories, notes }: SyncPayload) =>

export const saveSettings = ({ isOpen, ...settings }: SettingsState) =>
Promise.resolve(localStorage.setItem('settings', JSON.stringify(settings)))

export const requestNotes = () => new Promise(getUserNotes())
export const requestCategories = () => new Promise(getLocalStorage('categories'))
export const requestSettings = () => new Promise(getLocalStorage('settings'))
3 changes: 0 additions & 3 deletions src/client/api/scratchpadNote.md

This file was deleted.

35 changes: 0 additions & 35 deletions src/client/api/welcomeNote.md

This file was deleted.

12 changes: 0 additions & 12 deletions src/client/api/welcomeNote.ts

This file was deleted.

Loading