问题
Suppose that I want to customize the indentation rules of the foton document editor, where and how can I do that?
I'll elaborate.
The foton editor lays out document like this: (which to my flavor is completely annoying)
{
"_id": "1326017821636",
"_rev": "2-51ab614953437181a24f1c073fbc6201",
"doc_type": 0,
"step": 2,
"data": {
"map1": {
"attr1": 73031,
"attr2": "strval"
},
"map2": {
"att1": 52001,
"att2": "strval"
},
"mapmap": {
"map": {
"id11": {
"id": "id11",
"attr": "attr",
"attr2": 2222
},
"id1211": {
"id": "id1211",
"attr": "attr",
"attr2": 2222
}
}
}
}
}
And what would I want to change, you may ask? It seems pritty standard. Well, I'm not a standard person. To my observations many standards evolved arbitrarily and suffer lack of thought. Besides, if I was a standard-follower I was not asking about customization ;)
Shortly - - 3 spaces tab indent. Why 3? not 2 and not 4. just 3? LOL - block formation - opening a block draws down a line in the worng place - commas are in the wrong side
So I want it to be like this: (and I even have the JS code that does it, I just need help in where to put it)
{ "_id" : "1326017821636"
, "_rev" : "2-51ab614953437181a24f1c073fbc6201"
, "doc_type" : 0
, "step" : 2
, "data" :
{ "map1" :
{ "attr1" : 73031
, "attr2" : "strval"
}
, "map2" :
{ "att1" : 52001
, "att2" : "strval"
}
, "mapmap" :
{ "map" :
{ "id11" :
{ "id" : "id11"
, "attr" : "attr"
, "attr2" : 2222
}
}
, { "id1122" :
{ "id" : "id11"
, "attr" : "attr"
, "attr2" : 2222
}
}
}
}
}
Why I do it this way? - it looks more tabular. All syntax scuffold of same object/array are in the same column (who placed the comma in the wrong side of the statement anyway) - no redunand wasted empty lines - only the start-block is an edge case (opposed to in the other way you have a case for begining a block and a case for ending a block and a case for every line).
It would have been fine if I could perform my indentations and the foton will not ruin them everytime it validates the document. But, since it does, I need to get into this mechanism and replace it's indentor with one of my own.
Any directions?
P.S: If you know the answer here - you might know the answer to this question: couchdb futon document editor - can I customize the document validation part?
回答1:
Again, after a quick browse, this is where you might want to look:
https://github.com/apache/couchdb/blob/master/share/www/script/futon.browse.js#L899
You will have a corresponding /share/www/script folder on your local couchdb instance if you want to play around editing it live.
来源:https://stackoverflow.com/questions/8786845/couchdb-futon-document-editor-can-i-customize-the-indentation-rules