From 88afdf115e9953e3e6986398ef008266e640faf1 Mon Sep 17 00:00:00 2001 From: Emmanuel Prochasson Date: Wed, 24 Jul 2013 18:13:23 +0800 Subject: [PATCH] Some documentation. Fix the "friend list" widget thingy. --- README.md | 147 ++++++++++++++++++++++ TODO | 1 + client/helpers/router.js | 1 - client/main.js | 3 +- client/views/home/home.html | 3 + client/views/profile/profile.html | 4 + client/views/widgets/friends/friends.html | 3 - client/views/widgets/friends/friends.js | 3 +- lib/collections/conversations.js | 4 +- lib/collections/friends.js | 4 +- server/config.js | 0 server/publications.js | 15 ++- 12 files changed, 176 insertions(+), 12 deletions(-) delete mode 100644 server/config.js diff --git a/README.md b/README.md index f6b4752..f75a78d 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,153 @@ There is a lot left to do and little time. Among the list: - Some design. Current one is pretty minimalist. The UI in general is pretty much only what [Boostrap](https://github.com/twitter/bootstrap) offers. - Security might not be horrible, but it is certainly not good. User input are validated but not sanitized at the moment. +## API + +API is a big word, but here are a few of the useful helpers/methods implemented in Socialite. + +### Publications + +#### myData + +The current user data: full profile, settings and if the profile is completed (to be able to display the profile creation flow otherwise). + +On-ready, sets the `settings` and `profileComplete` Session variable. to indicate that 1. the profile is loaded and allow for easy access of those information. + +#### myPictures + +All the current user Photos. + +#### myNotification + +Notification for the current user, with potential related users (if the notification is "friend request from A", we also publish a light version of A's information, to display with the notification. + +#### myFriendlist + +All my friends (from Friends) and the related users information (Meteor.users. + +#### myNews + +Information happening to me and my interactions with other users (from Activities). + +#### myConversations + +The list of my current conversations with people, friend or not (from Conversations) and their info (from Meteor.users). + +#### questions + +The list of questions. + +#### oneConversation + +Depends on the Session variable `currentConversation`. Get some of the messages (from Messages) for a given conversation. + +#### userProfile + +Depends on the Session variable `currentUserProfile` (set when visiting a user profile). Publish user information from Meteor.users. + +#### oneUserPicture + +Publish pictures (from Photos) for the user set in `currentUserProfile`. TODO: merge with `userProfile`. + +#### oneUserActivities + +Publish activities for a given user (from `currentUserProfile`). TODO: merge with `userProfile`. + +#### searchResults + +Publish a list of users (from Meteor.users) matching a search query. On-ready, set the `searchQueryDone` Session variable, for client side update of the template. +Publish related Presences objects to know the online status of users in the search results. + +### Collections + +Not really API stuff, but help to understand the architecture of the app. + +#### Meteor.users + +The default Meteor.users collection, with nit much change. The profile information are stored in the `profile` field of a user document. + +#### Activities + +Register the things happening to the users. Some are public (this can be tuned in the config file), some are for logging purpose only. The public activities are used to generate a user newsfeed. + +Activities are meant to be updates on the server side through different user action on the site. + +#### Comments + +Meant to attach comment to different objects (Photos, ...). Implemented by not plugged to anything at the moment. + +#### Conversations + +Register who's talking to who, useful to list all the conversation for a given user (the mailbox). Denormalize the last message of the conversation, the last time something happened and if the current conversation has been read or not. + +A conversation belong to one user and indicates the other participant. Hence, a conversation with A and B has two documents, one for A to B, and one for B to A. This allow for easy retrieving of one user's live conversations. + +#### Messages + +Register messages users send to each other. Each message is associated to both A to B and B to A conversation. + +#### Friends + +Register the asymetric relation between users. If A and B are friends, we record a relation from A to B and B to A. If A or B breaks the relationship, both relation are destroyed. If A sends a friend request to B, only the A to B relation is created. If B confirms, the relation B to A is added, and both relations are marked as "reciprocal". Only reciprocal relations are published. +Also denormalize the online status of users to their friends. When A is connected, it broadcast its online status to all its friend in the associated Friends document. + +#### Notifications + +Stuff that are to be shown in the navbar. Notifications include things like friend request, friend request confirmation. And that's basically it for now. + +#### Photos + +Pictures user can upload. The Photos collection is based on filepicker. A previous version (Pictures) used CollectionFS to store the picture locally. Store the url of a picture and the owner. + +#### Presences + +Record user presence, last time they were seen, if they are online and the time they spent on the site. + +#### Questions + +Stores the questions to be retrieve to create the form for the users. Questions define their template (how to render them), their type, their name (to associate the question and the field in a user profile) their validation (typically, what kind of options are available in a dropdown) and can easily be extended (check servers/helpers/forms.js). + +Questions can be presented to a user using the general helper `make_question(name)`, name being the unique name of a question. When user submit a form containing a question, the validation associated with it is used. + +### Methods + +#### update_profile(values) + +Updates the current user profile. It can only apply to the profile of the user calling it. `values` contains an Object where the keys are a Question id. This guarantee that a user can only add/update information of his profile from a predefined Question in the database. This method also validate the value according to the validation embedded with the Question. + +A few values have special processing: +- the `location` field is used to create a mongo 2d index value (for proximity-based search) +- the `dob` (date of birth) field is copied in the `dobtime` field as a Unix timestamp for easier manipulation later on. + +#### denormalizeProfilePicture(picture) + +Set `profile.picture` to point to the url of the Photos document whose _id is `picture`. Basically tell that this picture is the user's current profile picture. + +#### profile_completed() + +Check that a user profile is complete. This can be tuned in the `main.config.js` file, variable `Meteor.profileCreation.requiredFieldForCompletion`. Check that all the fields are defined. If yes, sets the `profile_complete` and `visible` field of the current user to 1. The user is now visible to other user and can be searched for by other users. + +#### sendComment + +Unused. + +#### validateInput(value, docid, validations) + +Allow for client side validation of form input, using the Questions validation. + +#### addAsFriend + +#### removeFriend + +#### sendMessage + +#### uploadPhoto + +#### setUserPresence + +#### setInvisible + + ## License stuff This project is licensed with the MIT license. diff --git a/TODO b/TODO index 7edfebe..9857c83 100644 --- a/TODO +++ b/TODO @@ -8,3 +8,4 @@ Profile picture update field allow empty images. Also, show the image uploaded, Profile edition. Add possibility to comment on activity. Add a friendlist page. +Put user Profile and user Picture together \ No newline at end of file diff --git a/client/helpers/router.js b/client/helpers/router.js index 9d3db92..9b39eaf 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -1,6 +1,5 @@ // Is there a better way to do that? var resetSession = function(){ - console.log('resetting session'); Session.set('currentConversation', null); Session.set('currentUserProfile', null); Session.set('currentQuery', null); diff --git a/client/main.js b/client/main.js index 821974e..433b282 100644 --- a/client/main.js +++ b/client/main.js @@ -14,7 +14,7 @@ Meteor.startup(function(){ myNewsFeedHandle = Meteor.subscribeWithPagination('myNewsfeed', Newsfeed.activitiesPerPage); // My conversations - conversationsHandle = Meteor.subscribeWithPagination('myConversations', 3); + conversationsHandle = Meteor.subscribeWithPagination('myConversations', 10); // Questions for the profile form. Meteor.subscribe('questions'); @@ -44,7 +44,6 @@ Meteor.startup(function(){ if(Session.get("searchQuery")){ searchHandle = Meteor.subscribe("searchResults", Session.get("searchQuery"), Meteor.users.searchResultsLimit, function(){ Session.set('searchQueryDone', Session.get('searchQuery')); - console.log('updating publication searchResults'); }); } }); diff --git a/client/views/home/home.html b/client/views/home/home.html index 9149924..3326726 100644 --- a/client/views/home/home.html +++ b/client/views/home/home.html @@ -6,7 +6,10 @@
{{> online_friends}} +

Your friends

+
{{> friends}} +
diff --git a/client/views/profile/profile.html b/client/views/profile/profile.html index 2a68781..17e7bb3 100644 --- a/client/views/profile/profile.html +++ b/client/views/profile/profile.html @@ -55,6 +55,10 @@

{{profile.name}}

+

{{profile.name}}'s friends

+
+ {{> friends}} +
{{> modal_picture}} diff --git a/client/views/widgets/friends/friends.html b/client/views/widgets/friends/friends.html index 7e4fb12..c66f1f5 100644 --- a/client/views/widgets/friends/friends.html +++ b/client/views/widgets/friends/friends.html @@ -1,12 +1,9 @@