Community

On this page

Overview

Below is a list of all the available drops on the community object


Name Description
community.groups Always a list of the top-level groups
community.group The relevant group for the page
community.posts A list of posts
community.post The releavant post for the page
community.current_profile The logged in profile, nil for anonymous acccess
community.profile The current viewed profile
community.by_url[:url] Any group selected by url
community.by_url:.url Any group selected by url, provided syntax works
community.latest_posts The twenty latest posts made
community.latest_posts_by_membership The twenty latest posts made in any group where
the current user is a member
community.profile_by_uuid Any profile selected by uuid

 


Javascript

 

Community class

The Community Class is a javascript representation of the Liquid Community drop and has many similarities to the its Liquid counterpart. The Community class enables dynamic access and editing of a Community.

 

Methods

Parameter names on the tabels below represents the corresponding property in the Liquid community drop.

 

get

Community.get contains methods used fo fetch community-related data. Returns a jQuery Ajax request.

Name Description
all Returns an object containing links for
fetching groups, latest_posts, latest_posts_by_membership,
notificaions and profile data.
profile Returns a object containing the users profile information.
user (profile.uuid) Returns a object containing a specified users profile information.
groups Returns a object containing all accessible groups.
group (group.url) Returns a object containing a specified group.
memberships Returns a object containing users memberships.
members Returns a object containing all the groups members.
notifications Returns a object containing all notifications.
posts (group.url) Returns a object containing all posts from a group.
postsByMembership Returns a object containing posts by members of a group.

 


Snippets

<script>Community.get.group('{{ community.group.url }}')</script>

Community.get.group('my_group_path')

Community.get.groups().then((groups) -> Community.get.group(groups[0].group.url).then((response)-> console.log('group:', response.group) ) )

add

Community.add contains methods used to add content to a community.

Name Description
posts (group.url [, data:Object, callback:Function]) Adds a post to a
specified group

 

If no files are attached to the post and no callback function is set, this method will return a jQuery ajax request.
 

Important! When adding a post, the data parameter only becomes optional if at least one file has been added to the post using Community.addFile or Community.addFileList.


Snippets

post = {
  content: 'Hi there!'
  locale: 'en'
}

Community.add.post('mygroup', post)

files = $('input.my-file-input')[0].files
callback = (resp) -> console.log('File was posted to group!', resp)

Community.addFileList(files)
Community.add.post('mygroup', null, callback)

 

addFile

Scans for the first occurrence of a element with the selector '[name="post[files]"]' and attaches its files to the next submitted post.


addFileList

parameters: (FileList || Array[files])

Recieves a list of files and attaches them to the next submitted post.

Updated: 2020-06-16