Analysis
Overview
Comment frames allow a book to have an interactive space for dialoging between readers that have the same book open.
Comment frames refer the so called 'comment streams', which live either the server or on local machine and thus may require a Sophie Server to function. However, a Sophie book that uses comment frames does not need to be on a Sophie Server. When a book has comment frames, users can add comments. These comments are uploaded to the Sophie Server and are made available for reading to everyone with an open copy of the book.
A comment frame is added to a book the same way as every other frame type. Comment frames have a the same HUDs as do all frame types.
A comment frame allows adding a comment. There is a form inside the frame, allowing a comment to be entered. Comments can be added to a comment frame in Test mode or in Sophie Reader, but not in Author mode.
Once a comment has been added, a Reply function is displayed to allow the user to reply. Replies are indented. Replies to replies are further indented. If there are enough comments to fill the comment frame, the comment frame must generate scroll bars.
Comments can be added to any open copy of a Sophie book.
There should be ability for the owner do manage comments.
Task requirements
- Model
- Create "comment stream" - the resource which lives (mainly) on the server. It could have appropriate helper in order to ease implementations.
- Create comment frame. Since it will be a resource frame, it can refer a concrete stream. Keep in mind that the resource must be kept synchronized.
- Manipulation
- On inserting new frame, a comment stream will be automatically created in the book.
- Since the security model on the server is not quite stable, user rights will probably be ignored for this revision.
- Decide how will a stream be created / destroyed - from client, from web U.I. or both.
- Every comment should have a "reply" button, popping up a dialog for entry.
- At the frame bottom there will be a "add comment" button, which will popup a dialog for a new comment on click.
- View
- The comment content must be able to auto-refresh itself.
- The comment frame must be editable only in preview mode / reader mode. Comment frame interactions must be defined.
- The location of the input form must be inside the frame. It must be editable only in preview mode, must have Post button.
- The comment frame must have scroll bar.
- For this revision scroll bar could include only up and down arrow.
- The text in comment frame must be properly formatted - indent, header style. Consider using the current hot text model. Visibly the comment should include:
- User ID or name
- Date and time in ISO format
- Text content
- Huds?
Task result
- New comment frame functionality.
Implementation idea
- Scroll bars should appear only if they are needed.
- There should be some text formatting for the comments in order to increase the readability of this frame. Adding empty line between different comments could do the job.
- Also different color for the user ID(name) could increase the readability too.
- If the user is not authenticated should appear as anonymous
- Sample scenario for this revision:
- User creates a book (offline)
- The user inserts a comment frame - it is empty, since the location is not set yet (maybe a default location should be set, it does not make difference).
- The comment frame content refreshes it's view.
- The user enters some text and clicks "post".
- The same way, the comment is sent to the remote location and handled by the server.
- The comment content refreshes again to show the new comment.
Related
GROUP_APP_SERVER_RESOURCE_ACCESS_R0
S2S_WS_CONNECTOR_R0
GROUP_BASE_SECURITY_R0
How to demo
- Create new book and new server comment stream.
- Place comment frame inside of it, pointing to the stream.
- Go to preview mode add some comments
- Update the comment frame content.
- Open the book again in reader and type some comments again.
Design
Create a new Module org.sophie2.extra.comment. It should have the following packages:
- dialogs
- AddCommentDialog - Constructed by a replyToId (If the new comment is a reply so other comment), containing author field and a text field, OK and CANCER buttons.
- logic
- CommentHudLogic - Logic, handling target change. Sets the MAIN_RESOURCE of the current frame.
- CommentLogic - Responsible for adding comment, scrolling views. Adding comment changes the model, scrolling changes some property in the current FrameView.
- model
- Comment - Immutable, persistable. Contains author, date, text, generated id, parent id, constructor with id (for loading from file), helper method for building a formatted text. The date must be immutable, so make also ImmDate and ImmDatePersister.
- CommentFrameH, CommentFrameR4 - Nothing special. Their implementation is trivial and there is no need to explain what they contain.
- CommentStream - extends ResourceR4, contains immmutable list of comments. Helper methods for getting specific comments, calculating indent, aligning by some criteria, what's needed. ImmTreeListPersister is missing, so create it.
- persist
- CommentPersister - Persister for Comments. Its implementation is trivial, since it persists immutables.
- view
- CommentEntryView - contains a view for the "reply" button, as well as the view for the comment text (of type CommentTextView).
- CommentTextView - extends SceneTextView, associated 1:1 to a comment. Overrides the needed methods in order to layout some ImmHotText.
- CommentFrameView - Consists of a panel with the scroll buttons and "add comment" button. Also Contains a CommentStreamView, which is scrolled. So, also has a "position" prop.
- CommentStreamView - Contains a list of CommentEntryView-s, clips itself according to the parent's size. It layouts all the CommentEntryView-s and shows what's visible. This way, a comment entry will not be laid out every time a user clicks the scroll button.
- CommentPropertiesHaloButton - a hud halo button, which is attached in a ContentHaloMenu. Nothing special, it just shows the comment properties hud. The content halo menu must be implemented in order to see the result - its location and visibility should be computable, so the frameLogic must be able to detect a mouse click in s frameview and write it down in the view. So, the content menu will set its position at the last click position.
- CommentPropertiesHud - Simple hud with a textField for resouceRef to the frame's main resource. The validation will consist of checking whether the string passed is a valid ResourceRefR4.
- InsertCommentItem - Simple menu item for a new Comment Frame.
- ReplyCommentView - extends BaseManipulationView. Positioned on the commentView's bottom. BaseManipulationView must be a base implementation for the content manipulation views, not dependent on a concrete frame view. This way, a reply comment view will be able to be attached to a concrete comment view (which is not a frame view).
- ScrollDownView, ScrollUpView - They just extend ContentManipulationView.
Tests
Implementation
Known issues
- Scrolling causes some problems around clipping.. The clipped element is not really clipped - fixed (Some small changes in scene element helpers..)
- Formatting the text in the comments sometimes works individually - patched (There is a bu with the foreground color of the text and the PG indentation is not implemented. Some temporary fixed are applied).
- Content buttons work in author mode, they should not - fixed (the logic performs a check for preview mode).
- The hud sometimes throws bad exceptions - fixed (stronger requirements for the bound validation).
- The add comment dialog pops up again at Cancel - fixed (the logic returned false).
- There is not fine way to determine the needed area for a layout, so a constant of 20 is used for a default line height. For now it works OK.
- Trying to write some text in the comment views throws exceptions. It should not handle events at all - fixed (the event that modifies the text now really uses the supposed value.. nagivation operations are still working - I find them useful).
- ContentHaloMenu did not compute its position - fixed.
- Content manipulation buttons used to go invisible when clicked around 10 times - fixed.
- Some methods are not used at all - fixed (1 method was deleted, some classes were changed in order to improve performance a lot, so other 2 methods became unnecessary).
- Some tests related to comment frames are not starting - fixed (provided the needed modules, fixed small problems).
- A demo would be cool.
Merged into the trunk in [6677].
TODOs
- A system test, involving client-server communication.
- Comment's text style should be improved (after some particular text tasks / bugfixes).
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)
Attachments
- comment_frames_draft.png (102.6 KB) - added by dido 16 years ago.
- Comment Frames.png (53.2 KB) - added by kyli 16 years ago.