Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340439 - [client] Be able to open /coding.html in the read-only mode
Summary: [client] Be able to open /coding.html in the read-only mode
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 0.2   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 334213
  Show dependency tree
 
Reported: 2011-03-18 11:06 EDT by Szymon Brandys CLA
Modified: 2011-09-01 11:41 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2011-03-18 11:06:49 EDT
I would like to use coding.html to show the content of Git commits. We can't edit Git states so opening the editor in the read-only mode seems like the right thing to do. We can't do that through the URI yet.
Comment 1 Szymon Brandys CLA 2011-03-18 12:30:50 EDT
It would be good to have it fixed in m7.  Otherwise users may try to save/edit the commit content what causes errors in the console.
Comment 2 Szymon Brandys CLA 2011-05-11 08:41:49 EDT
Silenio, could you look at it during M8?
Comment 3 Silenio Quarti CLA 2011-05-11 10:30:17 EDT
The editor widget supports read-only mode already. Changes have to done on top of the editor to expose this feature (probably in editorContainer.js).

The original request was to change coding.html to accept a read-only parameter in the URI somehow, but I believe it has been decided that coding.html is not consumable.

Some work was done in editorContainer to make it more consumable (bug#337647). Susan, was this addressed as part of that bug?
Comment 4 Susan McCourt CLA 2011-05-11 12:57:38 EDT
The underpinnings are all there, what we need is either a flag in the URI or a separate read-only page.  There are things we would want to disable at the page level (such as the save command), as well as setting the property in the editor.  I'll figure out which makes sense.
Comment 5 Susan McCourt CLA 2011-05-20 00:14:04 EDT
After looking at the code, I opted for a separate html file.
To edit a file:
http://localhost:8080/edit/edit.html#/file/A/static/edit/edit.js

To view a file:
http://localhost:8080/edit/readonly.html#/file/A/static/edit/edit.js

This lets us remove scripts that won't be used at all (such as content assist, etc.) and prevents polluting all the hash checking with something that only needs to be known once up front.  

The "glue" code is now parameterized to readOnly so that it does not have to be maintained in two places.

cc'ing Simon because I ended up copying "edit.css" to "readonly.css".  This seemed kind of dumb but you wanted "one css file for each html file" so I supposed this should be done.  If this was the wrong decision, please advise.

cc'ing Andrew because I ended up adding a script tag in edit.html in HEAD but after the <!-- INSERT:coding-editor.js -->

I assume this will do the right thing.  I want the call in HEAD because it parameterizes the glue.  We should decide if we want to optimize the building of the readonly.html.  For now I assumed we would not.
Comment 6 Susan McCourt CLA 2011-05-24 17:00:36 EDT
(In reply to comment #5)

> cc'ing Simon because I ended up copying "edit.css" to "readonly.css".  This
> seemed kind of dumb but you wanted "one css file for each html file" so I
> supposed this should be done.  If this was the wrong decision, please advise.

Discussed with Simon.  For now this is the right decision.  We'll have one css per html file and later if we decide to optimize for identical content, we can.

> 
> cc'ing Andrew because I ended up adding a script tag in edit.html in HEAD but
> after the <!-- INSERT:coding-editor.js -->

Talked to Simon about this.  I had a js one-liner in the script tag rather than making the js one-liner its one file.  This is a no-no and won't work correctly with require.js.

So I changed the files again.
- rename parameterized glue code from edit.js to setup.js
- create glue code one-liners edit.js and readonly.js, which call the function in setup.js
- added setup.js to the closure.xml file for the editor case