<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cristian Tountzis on Medium]]></title>
        <description><![CDATA[Stories by Cristian Tountzis on Medium]]></description>
        <link>https://medium.com/@ctountzis?source=rss-1a1b2e01cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0_1iSbbZWrQPuzAhxZlxPw.jpeg</url>
            <title>Stories by Cristian Tountzis on Medium</title>
            <link>https://medium.com/@ctountzis?source=rss-1a1b2e01cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:04:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ctountzis/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Adding UserVoice Widget to an Ember.js app]]></title>
            <link>https://medium.com/@ctountzis/adding-uservoice-widget-to-an-ember-js-app-20808380f3b4?source=rss-1a1b2e01cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/20808380f3b4</guid>
            <dc:creator><![CDATA[Cristian Tountzis]]></dc:creator>
            <pubDate>Mon, 08 Dec 2014 06:36:27 GMT</pubDate>
            <atom:updated>2014-12-08T06:36:27.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzxVs9uxgXJlocoSef-EEQ.png" /></figure><p>UserVoice is a pretty cool help desk/feedback platform that automates a lot of the customer interaction for you through some pretty smart and powerful widgets. You can check UserVoice out here: <a href="https://www.uservoice.com/">https://www.uservoice.com/</a></p><p>Adding these widgets to an Ember.js app is pretty straight forward, I’ll be showing you how to add the contact widget, but it should work for any of them.</p><p>First we need to create the initialiser:</p><pre># in initializers/uservoice.js.coffee</pre><pre>Ember.Application.initializer<br>  name: &#39;uservoice&#39;<br>  after: &#39;store&#39;<br>  <br>  initialize: (container, application) -&gt;<br>    UserVoice = window.UserVoice or []<br>    (-&gt;<br>      uv = document.createElement(&quot;script&quot;)<br>      uv.type = &quot;text/javascript&quot;<br>      uv.async = true<br>      uv.src = &quot;path/to/your/widget.js&quot; <br>      #This will be on UserVoice in the widgets area<br>      s = document.getElementsByTagName(&quot;script&quot;)[0]<br>      s.parentNode.insertBefore uv, s<br>      return<br>    )()</pre><p>Next, we need to create a controller to hold the current user from the session to pass it to the UserVoice widget.</p><pre># in controllers/uservoice_controller.js.coffee</pre><pre>App.UservoiceController = Ember.Controller.extend<br>  currentUser : Em.computed.alias &#39;user.session&#39;</pre><p>After that we can create a small template for the controller that will render the view we will create below</p><pre># in templates/uservoice.js.emblem</pre><pre>view uservoice currentUser=currentUser</pre><p>Then we need to create a view so we can include the javascript for the widget in the DOM. (Yeh, this is the hacky/messy part)</p><pre># in views/uservoice_view.js.coffee</pre><pre>App.UservoiceView = Ember.View.extend<br>  didInsertElement: -&gt;<br>    UserVoice.push [<br>      &quot;set&quot;<br>      {<br>        accent_color: &quot;#448dd6&quot;<br>        trigger_color: &quot;white&quot;<br>        trigger_background_color: &quot;rgba(46, 49, 51, 0.6)&quot;<br>      }<br>    ]</pre><pre>    UserVoice.push [<br>      &quot;identify&quot; <br>      { <br>        email : @get &#39;currentUser.email&#39;<br>        name : @get &#39;currentUser.fullName&#39;<br>        created_at : @get &#39;currentUser.created_at&#39;<br>        id : @get &#39;currentUser.id&#39;<br>        type : @get &#39;currentUser.role&#39;<br>      }<br>    ]</pre><pre>    UserVoice.push [<br>      &quot;addTrigger&quot;<br>      {<br>        mode: &quot;contact&quot;<br>        trigger_position: &quot;bottom-right&quot;<br>      }<br>    ]</pre><pre>    UserVoice.push [<br>      &quot;autoprompt&quot;<br>      {<br>      }<br>    ]</pre><p>Then you should see the UserVoice widget included at the bottom right of your app. All the configuration options come from UserVoice, and there is a lot more you can add to the widgets so check them out.</p><p>Here’s a screenshot of the widget after adding the code above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*CPKmIK1XYSJf_Fyws--bEA.png" /></figure><p>Sorry <a href="http://twitter.com/sugarpirate">@sugarpirate</a> had to take out your feedback form for this ☺</p><p>And that’s it. Hope this helps some people out there looking to use UserVoice’s widgets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20808380f3b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking Signed In Users With Ember.js and Pusher Presence Channels]]></title>
            <link>https://medium.com/@ctountzis/tracking-signed-in-users-with-ember-js-and-pusher-presence-channels-50e11603b735?source=rss-1a1b2e01cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e11603b735</guid>
            <dc:creator><![CDATA[Cristian Tountzis]]></dc:creator>
            <pubDate>Fri, 24 Oct 2014 11:15:24 GMT</pubDate>
            <atom:updated>2014-10-24T11:15:24.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*RrEEHoqrIXqaMRPl6qmg4Q.jpeg" /></figure><p>It turns out keeping track of who is signed in to your application is pretty easy using Pusher Presence Channels.</p><p>Not having played around with Pusher much, my first instinct was to override our devise sessions controllers to write to the database when a user signed in our out. Not the best solution in the world.</p><p>A better and more flexible solution is to use Pusher presence channels. Pusher presence channels extend on private channel security, and give you an awareness of who is subscribed to that channel (you can check the docs here: <a href="http://pusher.com/docs/client_api_guide/client_presence_channels">http://pusher.com/docs/client_api_guide/client_presence_channels</a>)</p><p>I’m not going to jump into the rails side, but we use the pusher-gem (<a href="https://github.com/pusher/pusher-gem">https://github.com/pusher/pusher-gem</a>) to handle that. To get started, we need to set our channel in ember -</p><p><a href="http://twitter.com/set"><em>@set</em></a><em> ‘presenceChannel’, pusher.subscribe(</em><a href="http://twitter.com/get"><em>@get</em></a><em>(‘presenceChannelName’))</em></p><p>and then bind three of the presence channel events to some functions-</p><p><a href="http://twitter.com/get"><em>@get</em></a><em>(‘presenceChannel’).bind ‘pusher:subscription_succeeded’, </em><a href="http://twitter.com/handlePresenceChanne"><em>@handlePresenceChanne</em></a><em>lSubscription.bind(this)</em></p><p><a href="http://twitter.com/get"><em>@get</em></a><em>(‘presenceChannel’).bind ‘pusher:member_added’, </em><a href="http://twitter.com/handlePresenceChanne"><em>@handlePresenceChanne</em></a><em>lMemberAdded.bind(this)</em></p><p><a href="http://twitter.com/get"><em>@get</em></a><em>(‘presenceChannel’).bind ‘pusher:member_removed’, </em><a href="http://twitter.com/handlePresenceChanne"><em>@handlePresenceChanne</em></a><em>lMemberRemoved.bind(this)</em></p><p><em>pusher:subscription_succeeded </em>is called when your presence channel is subscribed to, so we can use it to store an array of member’s ids who are online -</p><p><em>handlePresenceChannelSubscription: (members) -&gt; userIds = [] members.each (m) -&gt; userIds.push(+m.id) </em><a href="http://twitter.com/set"><em>@set</em></a><em> ‘onlineUserIds’, userIds</em></p><p><em>pusher:member_added </em>gets called when a user joins the channel. This only gets triggered the first time a member joins, so opening multiple tabs or signing in twice from different browsers won’t matter. In this callback we can push the member object onto our list of members -</p><p><em>handlePresenceChannelMemberAdded: (member) -&gt; members = </em><a href="http://twitter.com/get"><em>@get</em></a><em> ‘onlineUserIds’ members.pushObject +member.id</em></p><p><em>pusher:member_removed </em>gets called when a user leaves the channel, so we can remove the member from the members list in this callback.</p><p><em>handlePresenceChannelMemberRemoved: (member) -&gt; members = </em><a href="http://twitter.com/get"><em>@get</em></a><em> ‘onlineUserIds’ members.removeObject +member.id</em></p><p>So now we have an list of members who are online all handled by pusher in realtime. So lets use it in our app. Lets add a function to the streaming service to return the list of online users.</p><p><em>onlineUsers: (-&gt; store = </em><a href="http://twitter.com/get"><em>@get</em></a><em> ‘store’ </em><a href="http://twitter.com/get"><em>@get</em></a><em>(‘onlineUserIds’).map (id) -&gt; store.getById ‘user’, id ).property ‘onlineUserIds.</em><a href="http://twitter.com/each"><em>@each</em></a><em>’</em></p><p>Then we need to inject the streaming service in an initialiser so it is available in our controller.</p><p><em>application.inject ‘controller’, ‘streaming’, ‘streaming:service’</em></p><p>Now we can can use a computed property to check if a user is online in the controller.</p><p><em>isSignedIn: (-&gt; users = </em><a href="http://twitter.com/get"><em>@get</em></a><em>(‘streaming.onlineUsers’) users.contains </em><a href="http://twitter.com/get"><em>@get</em></a><em>(‘model’) ).property ‘streaming.onlineUsers.</em><a href="http://twitter.com/each"><em>@each</em></a><em>’</em></p><p>And that’s it. Call that method in your template to see if a user is signed in. Right now we use this show online/offline status, but with a bit of tweaking it can be used for things like chat rooms, online games or document collaboration.</p><p>Big thanks to <a href="https://twitter.com/itscatkins">@itscatkins</a> for pairing with me for this one, first time playing with Pusher went pretty sweet thanks to your help bud!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e11603b735" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>