Giter VIP home page Giter VIP logo

hilarious-text-editor's Introduction

Overview

hilarious-text-editor lets you edit text files in a web browser. It autosaves every few seconds. You need to install Python 3.4 or higher before you can run it.

./hilarious.py --help

./hilarious.py path-to-file-or-directory-to-edit-things-in

Don't choose a directory with too many hundreds of text files in it. (See Limitations below.)

Follow the directions it shows on stdout for what link to open in your web browser. Probably http://localhost:3419/ and probably you'll then have a secret authentication token in your clipboard you can paste in to start editing. (See Security below for why there's a secret.)

I wrote this because Dragon NaturallySpeaking is pretty effective at controlling HTML <textarea>s in IE 11. My friends wanted a text editor for coding with Dragon that has fewer misfeatures for that purpose than DragonPad or Microsoft Word. If you have another use for this editor, I'd love to hear about it! Or even if you are using it for this purpose!

The editor could integrate something like http://ace.c9.io/ as an editor, but it probably won't because Dragon gets a little confused by the fancy things those editors do (in ace editor, for example, most of the text in the document is not in the <textarea> element at any given time, but is instead in other elements. Presumably so they can syntax hilight it and/or be more asymptotically efficient at editing. With the CodeMirror editor โ€” used for example by twine2 โ€” I am even less sure what exactly it's doing in the DOM.

Limitations

It doesn't work well when there are too many files in the directory.

It doesn't even let you edit sufficiently large text files, because it would be too slow in the browser and/or autosaving.

Security

Since you're (probably) a coder, you'll be editing scripts that you'll then (probably) be running in your user account, so you don't want other people to sneak in and edit your files over HTTP. If they could, they could then (probably) run their code as your user account.

Preventing this is implemented in parts:

  • Transport security: connecting to localhost or over HTTPS. (HTTPS not implemented yet; you can't use it remotely at all yet unless you hack the source code to do that insecurely.)

  • CSRF protection: all server requests involving private data are XHR2 Ajax POST requests with custom HTTP header fields that the server checks, in addition to checking Origin or Referer. This means they can't be posted to cross-domain.

  • What if someone else connects to the server:

    • When serving on localhost, only localhost users can connect at all
    • Unless you disable the random token, sending a correct token is required for all requests that involve private data. The random token is only sent to the clipboard and/or stdout, so other Unix/Windows users on the same system won't easily be able to get a copy of it.
  • The server not having bugs like memory corruption: it's Python with none of my code using the FFI, so that helps.

Anyone who can connect to the server can probably DOS it, but that's less of an issue. Let me know if you want me to do something about this. (A best solution would likely include putting it behind a reverse proxy such as nginx... so not suitable for all uses.)

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.