I'm using tiddlywiki [1] and I absolutely love it. You can host it where you want (owncloud works fine), and it has basically everything you just described.
I edit mainly using the web interface, but you can also edit the "tiddlers" (each note) using any text editor. The note has it's metadata at the beginning of the file.
I think I'm only using a very small % of TW's capabilities, but it feels like a very powerful tool.