Feature Spec: Memento Hashtags - Pixanthropy/pixanthropy-web GitHub Wiki
#Overview Hashtags (text prefixed with # and terminated with a non-alpha character) are used to describe, group, and discover related mementos. Hashtags can be entered in the Memento's description text. Multiple hashtags can be associated with a single memento. When entering a hashtag, available matching tags should be suggested to the user. Hashtags should also be highlighted in the editor control, if possible.
##Requirements
- Hashtags are searchable from the user's memento feed
- Matching hashtags are suggested when typing a hashtag in the Memento description editor
- Hashtags are hyperlinked to the
/hashtag/{hashtag_without_pound_sign}
- Search is case-insensitive
#Technical Specifications ##Database ###Hashtags Table Create a table for hashtags. Hashtags are stored in lower case. Hashtag value is a unique index (key?). There's really no other information which seems necessary for that table.
###Memento Hashtags Table
Cross-reference table to store relationship between Hashtags
table and Mementos
table. Fields include:
- MementoId
- HashTag
##API
###Create & Update Memento
When memento's are created or updated, parse the description field for any instances of hashtags and update the Hashtags
and MemementoHashtags
tables accordingly.
Routes:
POST: /api/mementos
PUT: /api/mementos/{id}
Rules for Hashtag Parsing:
- Must contain at least one alpha character
- Hashtags cannot contain spaces or non-alphanumeric characters with the exception of underscore (allowed characters include upper- and lowercase letters, digits, and underscore)
- Max length: 50
- No min length
###Memento Details
Route: GET: /api/mementos/{id}
Response Body:
Memento should include Dictionary property keying hyperlinks by hashtags as follows: { "#{hashtag_value}", "<a href="~/hashtag/{hashtag_value}">#{hashtag_value}</a>" }
.
###Search Hashtags
The hashtag search route will return paged memento data (MementoBadgesResponse
) with mementos containing the hashtag value. Use the last query timestamp to return new mementos with the next page.
Route: GET: /api/hashtag/{value}
Querystring Parameters:
- skip count
- Page size
- last query timestamp
Response Body:
Return memento data as an enumerable of MementoBadgesResponse
sorted by the Memento's date created in descending order.
###Lookup Matching Hashtags Returns hashtags starting with the value received in the param. Compare the lower-case version of the search text with the lower-case text in the database.
Route: GET: /api/hashtag?match={searchText}
Querystring Parameters:
- Search text - the text for which to return matching hashtags
Response Body: Return an enumerable of resulting hashtag matches with their case-formatting. Return the first 25 results sorted alphabetically.
##UI ###Memento Editor When creating a new Memento or editing the description of an existing Memento, users can add hashtags to the memento's description. When the user begins typing a hashtag (see below for hashtag rules), call the Search Hashtag API Endpoint to get a collection of know hashtags matching the supplied text.
Here's a jQuery plugin which seem well suited for the job. Along with the auto-complete functionality, the plugin claims to be compatible with another called jQuery.overlay to enable the hashtag to be highlighted within the editor controls.
###Memento Details When displaying the Memento Details view, the hashtag values within the description will need to have hyperlinks injected. The Memento Details API response will include a member containing a dictionary of hashtags with the url to search for mementos with the same hashtag. Do a case-insensitive search on the key (hashtag) and replace with the linked value.
NOTE: Use the actual text from the description as the link text so that the case-formatting is preserved.