Giter VIP home page Giter VIP logo

caesarnote's Introduction

Caesarnote

Caesarnote is a cryptographic cloud-based note-taking app inspired (heavily) by Evernote. Caesarnote implements many of the core features of Evernote, including:

  • Secure user authentication
  • Note creation, editing, and deletion with full-featured rich-text editing, autosave, and full-screen mode
  • Notebooks and tags for note organization
  • Shortcuts for faster navigation
  • Search by note content
  • Trash bin for retrieval of deleted notes

Unlike Evernote, which has been subject to data leaks in the past, Caesarnote ships with state-of-the-art note encryption to make your data cryptographically impenetrable.

Caesarnote's tech stack consists of React and Redux on the front end and Ruby on Rails and PostgreSQL on the backend. The project incorporates the React-Quill library for rich-text editing. Caesarnote was designed and built in 10 days.

splash

Key Features

Note Processing

main

Each time notes are rendered, they are sorted and filtered by various parameters. In order to keep code clean and readable as the number of processing parameters grows, a modularized note processing procedure was developed as follows:

  processNotes() {
    this.sortNotes();
    return this.filterNotes();
  }

  sortNotes() {
    this.props.notes.sort((a, b) => a.updated_at < b.updated_at ? 1 : -1);
  }

  filterNotes() {
    return this.props.notes
      .filter(this.searchFilter())
      .filter(this.trashFilter());
  }

  searchFilter() {
    let { searchQuery } = this.props;
    searchQuery = searchQuery.toLowerCase();

    return note => note.title.toLowerCase().includes(searchQuery) || note.body.toLowerCase().includes(searchQuery);
  }

  trashFilter() {
    const { trash } = this.props;
    return note => note.is_trashed === trash;
  }

Though the application currently only supports one sort parameter and two filter parameters, future versions may include many different sort parameters (chronological by date created, alphabetical by title) and filter parameters (tags). This structure will allow for easy additions of future parameters while maintaining readable and modular code.

Note Encryption

ciphered

There is no known algorithm for a rich-text Caesar cipher (suprising, given how practical an application it is). A conventional Caesar cipher won't work since rich-text tags (<img>, <em>) and reserved characters (&amp;, &nbsp;) must be preserved while their inner HTML should be ciphered. A hand-rolled algorithm was implemented as follows:

export const richCaesarCipher = (htmlString, shift = 0, mode = 'encode') => {
  let cipheredHtml = '';
  let inHtmlTag = false;
  let inReservedChar = false;

  for (let i = 0; i < htmlString.length; i++) {
    const char = htmlString.charAt(i);

    if (char === '<') {
      inHtmlTag = true;
    } else if (char === '>') {
      inHtmlTag = false;
    } else if (char === '&') {
      inReservedChar = true;
    } else if (char === ';') {
      inReservedChar = false;
    }

    if (inHtmlTag || inReservedChar) {
      cipheredHtml += char;
    } else {
      cipheredHtml += (mode === 'encode' ? caesarShift(char, shift) : caesarShift(char, -shift));
    }
  }

  return cipheredHtml;
};

export const caesarShift = (char, shift) => {
  if (!char.match(/[a-z]/i)) {
    return char;
  }

  let startPos;
  let endPos;

  if (char === char.toUpperCase()) {
    startPos = 'A'.charCodeAt(0);
    endPos = 'Z'.charCodeAt(0);
  } else if (char === char.toLowerCase()) {
    startPos = 'a'.charCodeAt(0);
    endPos = 'z'.charCodeAt(0);
  }

  const shifted = (char.charCodeAt(0) - startPos + shift) % 26;
  if (shifted >= 0) {
    return String.fromCharCode(shifted + startPos);
  } else if (shifted % 26 === 0) {
    return String.fromCharCode(shifted + endPos);
  } else {
    return String.fromCharCode(shifted + endPos + 1); 
  }
};

Further, the application must maintain state of whether a note is ciphered so as to cipher or decipher appropriately. This was implemented via a database column containing the cipher key for each note. The cipher key defaults to 0 when a new note is created and is randomly chosen when the note is first ciphered.

cipherNote() {
    const randomKey = Math.floor(Math.random() * 25) + 1;
    const key = this.state.cipher_key ? -this.state.cipher_key : randomKey;

    this.setState({
      title: richCaesarCipher(this.state.title, key),
      body: richCaesarCipher(this.state.body, key),
      is_ciphered: !this.state.is_ciphered,
      cipher_key: key
    });
  }

Future Features

Given the 10-day timeline of this project, it was not possible to implement all desired features. Top priorities for further work include:

  • Additional note filtering and sorting
  • Dark theme
  • Note sharing

Image Gallery

login

notebooks

caesarnote's People

Contributors

micah-jaffe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

caesarnote's Issues

Proposal

Wiki Page Home

  • Is the first page you see upon entering the wiki
  • Contains a welcome message
  • Contains a link/placeholder for a link to the live page
  • All links in the right sidebar should contain each wiki page and link to the correct page
  • Correctly formatted
    • each wiki page is listed in bullet points
    • all links route the correct page

Comments


MVP List

  • Should have 7 MVPs.
    • 3 of those are User Auth, Heroku, and Production README.
    • The other 4 are from the MVP List or they have clarified them with you
  • Contains a description sentence of the app
    • Includes the following list for the 4 app specific MVPs:
      • Adequate styling
      • Smooth, bug-free navigation
      • Adequate and appropriate seeds to demonstrate the feature
  • At least one CRUD feature, which states what CRUD operations are planned (creation, reading, updating, deletion)
  • Estimates how long it will take the code each MVP
  • Correctly formatted
    • MVPs are listed in an ordered list
    • Each MVP is broken down into bullet points

Comments


Database Schema

  • Contains correct datatypes

  • Contains appropriate constraints/details

    • primary key
    • not null
    • unique
    • indexed
    • foreign key
  • Contains bullet points after the table that state which foreign keys will reference to which table, or references to the associations which will be made

  • Correctly formatted

    • schema is written in a table format
    • the table's name are back_ticked
    • the table header column names are bolded
    • columns names are lowercased and snaked_cased and back_ticked

Comments


Sample State

  • State shape is flat!
  • State's keys are camelCased
  • All keys within the values in the state are accessible in the schema
  • Correctly formatted
    • Sample state is rendered with triple backticks, and the language ```javascript...```). This will display the state as a code block instead of a giant line of text
    • Top level slices
      • entities
      • session
      • errors (here or in ui)
      • ui (if needed)
    • Should NOT have nested slices, aka comments inside of posts
      • Some info from other tables is ok, for instance:
        • the author username and imageurl for a post. basically any info that the user can't change
        • like count and a boolean on whether the user likes the post instead of a likes slice

Comments


Backend Routes

  • Contains the following sections: HTML, API Endpoints(Backend)
  • Each route has a description
  • API Endpoint routes contains wildcard variables written in snake_case
  • Routes does not contain superfluous routes
  • Have API routes that will allow the front end to get all info it needs and does not have unneeded routes:
    • probably doesn't need a GET likes api endpoint because that info comes through the post show

Comments


Frontend Routes

  • Frontend routes contains wildcard variables written in camelCase
  • Correctly formatted
    • Routes are displayed with inline coding text (backticks)

Comments

PA Review: Notebooks MVP

  • Backend: DB, model, controller, views
  • Redux Loop: ajax, actions, reducer
  • Presentational Components and Containers
    • User can create new notebook via clicking a button and submitting a form in modal
    • User can update and delete notebooks by clicking the actions icon in notebooks index
  • Styling
  • Smooth, bug-free navigation
    • User can navigate to notebooks index page via link in main sidebar
    • User can navigate to notebook show page by clicking link on notebooks index page
  • Adequate and appropriate seeds

PA Review: Tags

  • Backend: DB, model, controller, views
  • Presentational Components and Containers
    • User can add and remove tags
    • User can delete all instances of a tag from tags page
    • User can delete taggings from a note without deleting all instances of the tag
  • Styling
  • Smooth, bug-free navigation
  • Adequate and appropriate seeds

PA Review: Notes MVP

I finished most of the Notes MVP over the weekend. The rich text editor is still a bit buggy but since that's technically a separate MVP I figured I would put this one up for review. Notebooks and notes go hand in hand so they can probably be reviewed together.

  • Backend: DB, model, controller, views
  • Redux Loop: ajax, actions, reducer
  • Presentational Components and Containers
    • User can create new notes from notebook show page
    • User can create a new note in default notebook from All Notes page
    • User can view all notes in given notebook on notebook show page
    • User can view all notes on All Notes page
    • User can update notes by changing the title or body - notes will autosave
  • Styling
  • Smooth, bug-free navigation
    • User can navigate between All Notes and Notebooks via sidebar
    • Modals and dropdowns display appropriately and lead to correct places
  • Adequate and appropriate seeds

PA Review: Rich Text editing

  • Backend: DB, model, controller, views
  • Presentational Components and Containers
    • User can add rich text features to notes
  • Rich text features persist to database
  • Styling
  • Smooth, bug-free navigation
    • User can navigate adequately in rich text editor
  • Adequate and appropriate seeds

PA Review: User Authentication

  • Backend: DB, model, controller, views
  • Redux Loop: ajax, actions, reducer
  • Presentational Components and Containers
  • Styling
  • Smooth, bug-free navigation
  • Adequate and appropriate seeds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.