MartinSGill / TodoTxtJs

A Javascript web app implementation of TodoTxt
72 stars 29 forks source link

How to run on one's own server? #59

Closed richardofoz closed 10 years ago

richardofoz commented 10 years ago

I'd like to run it on my own server. Is that possible? If yes, how?

BTW I love this webapp, by far the best out of those on todotxt.com.

blackm commented 10 years ago

The same thing just crossed my mind....how to store in OwnCloud (or any other web dav server)? Can this be implemented?

MartinSGill commented 10 years ago

Depends on what you mean by "on my own server".

The page itself can be hosted from any webserver, it's just HTML and JavaScript. It's always been written with that intention. I host it on my own site mostly for myself and to demo the code. Of course that makes it convenient for others as well :)

Storing your Todos somewhere else though is harder. Because the page is designed to run entirely in the browser (i.e. with no back-end server) whatever you want to use to store the TODOs will need to be fully supported in JavaScript. Dropbox provided a nice JS library for their API, so that was easy to do.

A quick look around GitHub shows a couple of Javascript WebDav libraries, so it should be possible. I also designed the code to be easily expanded with new storage providers.

If you want to run it entirely on your own web server and store data locally then a simple storage provider that POSTs to a URL and GETs from a URL should be very easy to do. Security would need to be handled by the webserver, e.g using basic auth.

The first step would be expanding the storage provider framework to support providers that need configuration data, e.g. username, password, URL etc. Dropbox was easy the URL is known and it handles authentication entirely by itself.

Once that's done, it becomes simply a case of creating a new provider and implementing the load/save methods.

richardofoz commented 10 years ago

Thanks for the quick response!

I would be happy with the 'todo.txt' in the same folder, I just don't know which file to call with the browser.

I am not too proficient in this, sorry.

So far I've only been dealing with 'index.php' and 'index.html' files, but this webapp is different. Extracting the github folder into a subfolder on a webserver and calling ../src/todotxt.html did not work (browser shows '...Loading...'). Couldn't find any other .html files.

MartinSGill commented 10 years ago

It's not that simple, I'm afraid. First of all the site needs to be built/compiled. It's not in GitHub in a state ready to host in a webserver. See the build folder, there's a readme.md in there. I can make a "ready to install" version available to you, but that won't solve your bigger problem.

You web server is basically a read-only type thing, it's not allowed to directly make changes to the file system. So you can host a TODO.txt on your webserver, but without changes to the webapp you won't be able to save changes.

What you need is a script or tool on the webserver that can do the saving for you. This app doesn't come with one.

So there are two steps.

  1. you need something (a script) on your server that can receive the todo.txt file.
  2. you need to change the webapp so that it knows how to send the todo.txt file to that script.
richardofoz commented 10 years ago

Great answer, thanks!

Will try and build it on a local Debian server, to maybe fulfill my need for self-sufficiency (as in http://indiewebcamp.com/why). Trying not to use Dropbox either.

Storing the todo.txt on the same self-hosted server would serve mobility: there'd be no need to have it locally on a phone - although my old Symbian phone's browser also just shows 'Loading' (but it's okay, we can use todo.sh through ssh).

Using your website for now, it works perfectly. Kudos!

blackm commented 10 years ago

Am I right when I say that the TODOs are stored in cookies? If you only use the webinterface you can use firefox + owncloud + mozilla sync service (hosted on your owncloud server) to share todo's between multiple computer.

MartinSGill commented 10 years ago

Not sure what the mozilla sync service covers.

The todos are stored in browser local storage. If mozzilla/firefox sync includes that, then that would be a good solution for you.

richardofoz commented 10 years ago

Hi,

On a current Debian Stable with Apache running, I have installed node.js, npm, grunt, grunt-cli, everything as you write in /build/README.md.

app.js?

In /build/README.md:

Only src/app.js is actually needed by the webpage. clean.ps1 removes unneeded *.js files.

...but there is no src/app.js.

in line 46 /build/GruntFile.js has:

dest: '../src/js/app.js'

...but there is no /src/js/app.js either.

symptom

/usr/src/TodoTxtJs-2014-02-12/build# grunt

runs, but the browser only shows ...Loading... screenshot from 2014-02-12 23 20 29

Please help me understand this statement: "Only src/app.js is actually needed by the webpage" What is to be copied into /var/www? (If anything?)

MartinSGill commented 10 years ago

Sorry there's a step missing. Grunt in default mode watches for changes. if you run

/build# grunt typescript less

That will perform the initial compile

If you then run grunt without arguments will start a webserver, load the page and then watch for changes, automatically re-compiling.

Once you've compiled everything once, then you should see an app.js file. Don't forget that if you want dropbox functionality you need your own key, read sample_dropbox_key.js

hmm. I should probably figure out how to add a "build" task. I'm new to grunt myself.

If you still have problems please run:

/build# grunt --verbose typescript less

and post the output, as something might not be compiling properly.

good luck.

richardofoz commented 10 years ago

Hi,

Thanks for keeping an eye on this, and helping!

I don't want Dropbox functionality, I'd just like to d&d my local todo.txt into this fine webapp running locally.

/build# grunt typescript less gave "Done, without errors.", and there is a /src/js/app.js now.

You might want to write /src/js/app.js instead of /src/app.js near the end of /build/README.md.

This is the full --verbose output:

Initializing
Command-line options: --verbose

Reading "GruntFile.js" Gruntfile...OK

Registering Gruntfile tasks.

Registering "grunt-typescript" local Npm module tasks.
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-typescript/package.json...OK
Parsing /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-typescript/package.json...OK
Loading "typescript.js" tasks...OK
+ typescript

Registering "grunt-contrib-watch" local Npm module tasks.
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-watch/package.json...OK
Parsing /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch

Registering "grunt-contrib-connect" local Npm module tasks.
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-connect/package.json...OK
Parsing /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect

Registering "grunt-open" local Npm module tasks.
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-open/package.json...OK
Parsing /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-open/package.json...OK
Loading "open.js" tasks...OK
+ open

Registering "grunt-contrib-less" local Npm module tasks.
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-less/package.json...OK
Parsing /usr/src/TodoTxtJs-2014-02-12/build/node_modules/grunt-contrib-less/package.json...OK
Loading "less.js" tasks...OK
+ less
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "GruntFile.js" tasks...OK
+ default

Running tasks: typescript, less

Running "typescript" task

Running "typescript:base" (typescript) task
Verifying property typescript.base exists in config...OK
Files: ../src/js/lib/dropbox.d.ts, ../src/js/lib/jquery.d.ts, ../src/js/lib/jquery.jgrowl.d.ts, ../src/js/lib/jqueryui.d.ts, ../src/js/lib/knockout.d.ts, ../src/js/model/regex.ts, ../src/js/model/todo.ts, ../src/js/model/todoHtmlRender.ts, ../src/js/model/todomanager.ts, ../src/js/storage/IStorageProvider.d.ts, ../src/js/storage/storage_browser.ts, ../src/js/storage/storage_dropbox.ts, ../src/js/utils/datetime.ts, ../src/js/utils/events.ts, ../src/js/views/displayOptions.ts, ../src/js/views/exporting.ts, ../src/js/views/importing.ts, ../src/js/views/options.ts, ../src/js/views/todotxt.ts -> ../src/js/app.js
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/typescript/bin/typescript.js...OK
Options: module="commonjs", target="es5", sourcemap, fullSourceMapPath
>> fullSourceMapPath not supported.
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/lib/dropbox.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/lib/jquery.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/lib/jquery.jgrowl.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/lib/jqueryui.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/lib/knockout.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/model/regex.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/model/todo.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/utils/datetime.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/utils/events.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/views/todotxt.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/model/todoHtmlRender.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/model/todomanager.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/views/options.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/storage/IStorageProvider.d.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/storage/storage_browser.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/storage/storage_dropbox.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/views/displayOptions.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/views/importing.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/src/js/views/exporting.ts...OK
Reading /usr/src/TodoTxtJs-2014-02-12/build/node_modules/typescript/bin/lib.d.ts...OK
Writing /usr/src/TodoTxtJs-2014-02-12/src/js/app.js.map...OK
Writing /usr/src/TodoTxtJs-2014-02-12/src/js/app.js...OK
File /usr/src/TodoTxtJs-2014-02-12/src/js/app.js created.
js: 1 file, map: 1 file, declaration: 0 files

Running "less" task

Running "less:production" (less) task
Verifying property less.production exists in config...OK
Files: ../src/css/simple_default.less -> ../src/css/simple_default.css
Files: ../src/css/simple_solarized_dark.less -> ../src/css/simple_solarized_dark.css
Files: ../src/css/simple_solarized_light.less -> ../src/css/simple_solarized_light.css
Options: yuicompress
Reading ../src/css/simple_default.less...OK
Writing ../src/css/simple_default.css...OK
File ../src/css/simple_default.css created.
Reading ../src/css/simple_solarized_dark.less...OK
Writing ../src/css/simple_solarized_dark.css...OK
File ../src/css/simple_solarized_dark.css created.
Reading ../src/css/simple_solarized_light.less...OK
Writing ../src/css/simple_solarized_light.css...OK
File ../src/css/simple_solarized_light.css created.

Done, without errors.

Running /build# grunt started the browser with a "No D-BUS daemon running" warning message. DBUS is running, I don't even know if it's relevant: screenshot from 2014-02-16 12 16 28

By the way, why is running '/build# grunt' optional?

Should I copy some files into /var/www? I am guessing at http://todo.martinsgill.co.uk you have it running from the webserver's www folder. Copying /src into /var/www/ as /todotxtjs brings up the same ...Loading... page in the web browser at localhost/todotxtjs/todotxt.html If I open the Web Developer toolbar and refresh the page, there appears a bunch of Not Modified and Not Found net errors. screenshot from 2014-02-16 14 33 21 But the files are there, and I've even done a chmod -R 777 on them.

I am sorry for not having more understanding, I am kind of over my head here. :)

blackm commented 10 years ago

@MartinSGill can you create a "release" that works out of the box? Just unpack into a webfolder and that's it?! Or pack the content of http://todo.martinsgill.co.uk/ and offer this for download?

I am asking because if like the software and want to run it on my own server....which does not seem to be straight forward....

Thanks :-)

MartinSGill commented 10 years ago

@blackm Yeah I might do that.

@richardofoz It should be working... your grunt output indicates it built successfully

Writing /usr/src/TodoTxtJs-2014-02-12/src/js/app.js...OK

And the browser loaded all the files ok. The missing events.js and dropbox_key.js should be ok. It's supposed to run without those, I might look into that to see if there might be a problem there.

richardofoz commented 10 years ago

Thanks Martin!

In the mean time, could someone else please try the same thing I have (installing and running on a local web server)? Maybe it would work for someone else, meaning that the problem is on my end.

MartinSGill commented 10 years ago

Ok... turns out that was my bad. While it should have worked with the dropbox key missing, it didn't, so no fault of yours @richardofoz .

If you pull the latest the issue should be fixed.

there's also a "grunt build" action now to make sure everything is built, and for convenience the default action also calls that.

I'll close this issue for now. If you still can't get it working after getting latest, please reopen this issue.

richardofoz commented 10 years ago

The new version works! Thanks ever so much!

For the sake of perfection /build/README.md line 61 "Only the generated src/app.js is actually needed by the webpage. clean.ps1 removes unneeded *.js files." could have '/src/js/app.js' and '/build/clean.ps1'

And yes, after a

# cp -R src /var/www/todo && chmod 755 /var/www/todo

visiting localhost/todo/todotxt.html will bring up the webapp