23 Replies Latest reply: Jan 15, 2014 3:05 PM by Mark Zoeckler RSS

    Tag Watching & RSS Feeds

    Scott Finkel

      In attempting to create a Lobby or landing page for all Social Groups, I'd like to be able to highlight certain types of groups, e.g. Engineering, or Learning, or Mobile. At first, I created a plugin which extended the Watch a Tag widget, and turned off all the content types in the widget properties, hoping it would then only display Social Groups and Space/sub-spaces. But it still includes People as well.

       

      Tried using an RSS widget instead, with the Feed URL for a given tag

       

      http://<hostname>/community/feeds/tags/engineering

       

      but this pretty much has the same problem, and I'm now wondering if there are any URL params I could tack on there to limit the scope of the feed, and  indicate the ID of a specific content type. For example, below contentType=3 might be the ID of the content type "Social Group"

       

      http://<hostname>/community/feeds/tags/engineering?contentType=3

       

      Are there any URL flags available for /feeds/tags/ ?

       

      Alternatively, if there is a way I can limit the scope of my Watch a Tag widget to exclude People, that might also work.

        • Re: Tag Watching & RSS Feeds
          Ryan Rutan

          I created a "Groups by Tag Widget" widget has been useful for similar functionality, showing a rich view of Groups that all match the specified tag.  In addition, I am about 40% done with creating this Group Taxonomy plugin...

          Feature Request - Browse Groups via Registry

           

          Also sounds like it might be helpful..or along the same lines. Let me know if you are interested and/or chime in on the functionality addendums on the above request.  If you are interested....will happily share the source code to the Groups by Tag Widget.

            • Re: Tag Watching & RSS Feeds
              Scott Finkel

              Thanks Ryan, I'd love to see the src of your Groups by Tag widget! Does it allow for multiple tag variants too? For example, eng && engineering?

               

              I can't seem to view the discussion you linked to. Says I'm not authorized.

                • Re: Tag Watching & RSS Feeds
                  Ryan Rutan

                  Doh!  Thought it was public...I haven't looked at the source in a while...will post it in just a sec....pretty sure you could easily make it do AND logic.. with few changes if it were necessary.

                  -RR

                   

                  Here is the Source-Code for the Widget, it was written about a year ago with 2.5.x:

                   

                  @WidgetTypeMarker({WidgetType.COMMUNITY, WidgetType.HOMEPAGE, WidgetType.PROJECT, WidgetType.PERSONALIZEDHOMEPAGE, WidgetType.SOCIALGROUP})
                  @PropertyNames({"tags", "numResults"})
                  public class GroupsByTagWidget extends BaseWidget {
                      protected static final String FREEMARKER_TEMPLATE = TEMPLATE_ROOT+"/widget-groupsByTag.ftl";
                      protected SocialGroupManager m_socialGroupManager;
                      protected TagManager m_tagManager;
                      protected int m_numResults;
                      protected List<ContentTag> m_tagList;
                      protected JiveIterator<SocialGroup> m_groups;
                      protected boolean m_isAndOperator;
                      protected String m_tags;
                      
                      public GroupsByTagWidget() {
                           m_isAndOperator = true;
                           m_tagList = Collections.emptyList();
                      } // end constructor
                      
                      public void setSocialGroupManager(SocialGroupManager socialGroupManager) {
                          m_socialGroupManager = socialGroupManager;
                      } // end setSocialGroupManager - SPRING INJECTED
                  
                      public void setTagManager(TagManager tagManager) {
                          m_tagManager = tagManager;
                      } // end setTagManager - SPRING INJECTED
                      
                      public boolean isEnabled(WidgetContext widgetContext) {
                          return JiveGlobals.getJiveBooleanProperty("xxx.widgets.groupsByTag.enabled",true);
                      } // end isEnabled
                      
                      public String getTags() { return m_tags; }
                      public void setTags(String tags) {
                          m_tags = tags;
                          if (tags == null || tags.trim().length() < 1) {
                              return;
                          } // end if
                          String[] theTags = tags.split("( |,)");
                          m_tagList = new ArrayList<ContentTag>();
                          for (String tag : theTags) {
                              try {
                                  m_tagList.add(m_tagManager.getTag(tag));
                              } catch (TagObjectNotFoundException e) {
                                  Log.warn("Tag["+tag+"] is not currently a system tag, and cannot be filtered on");
                              } // end try/catch
                          } // end for tag
                      } // end setTags
                      
                      public boolean getIsAndOperator() { return m_isAndOperator; }
                      public void setIsAndOperator(boolean isAndOperator) {
                          m_isAndOperator = true; // isAndOperator; //TODO: UNDO WHEN JDBC ISSUE WITH SocialGroupManager IS FIXED FOR OR Condition
                      } // end setTagOperator
                      
                      public int getNumResults() { return m_numResults; }
                      public void setNumResults(int numResults) {
                          m_numResults = numResults;
                      } // end setNumResults
                      
                      /* (non-Javadoc)
                       * @see com.jivesoftware.community.widget.Widget#getDescription(com.jivesoftware.community.widget.WidgetContext)
                       */
                      public String getDescription(WidgetContext widgetContext) {
                          return this.getLocalizedString("xxx.jive-ext.widgets.groupsByTag.description",widgetContext);
                      }
                  
                      /* (non-Javadoc)
                       * @see com.jivesoftware.community.widget.Widget#getTitle(com.jivesoftware.community.widget.WidgetContext)
                       */
                      public String getTitle(WidgetContext widgetContext) {
                          return this.getLocalizedString("
                  xxx.
                  jive-ext.widgets.groupsByTag.gtitle",widgetContext);
                      }
                  
                      /* (non-Javadoc)
                       * @see com.jivesoftware.community.widget.Widget#render(com.jivesoftware.community.widget.WidgetContext, com.jivesoftware.community.widget.Widget.ContainerSize)
                       */
                      public String render(WidgetContext widgetContext, ContainerSize size) {        
                          return applyFreemarkerTemplate(widgetContext, size,FREEMARKER_TEMPLATE);
                      } // end render
                      
                      protected Map<String, Object> loadProperties(WidgetContext widgetContext, Widget.ContainerSize size) {
                          Map<String, Object> properties = super.loadProperties(widgetContext, size);
                  
                          SocialGroupResultFilter filter = SocialGroupResultFilter.createDefaultFilter();
                          if (m_tagList.size() > 0) {
                              for (ContentTag tag : m_tagList) {
                                  filter.addTag(tag);
                              } // end for
                              filter.setAllTagsRequired(m_isAndOperator);
                          } // end if
                          m_groups = m_socialGroupManager.getSocialGroups(filter);
                          
                          properties.put("tags", m_tagList);
                          properties.put("groups",m_groups);
                          properties.put("numResults", m_numResults);
                          properties.put("widget",this);
                          
                          return properties;
                      } // end loadProperties
                  
                      public boolean getIsSocialGroupImageAvailable(SocialGroup group,int size) {
                          return (m_socialGroupManager.getSocialGroupImageID(group,size) > 0);
                      } // end getIsSocialGroupImageAvailable
                      
                      public JiveIterator<ContentTag> getGroupTags(SocialGroup group) {
                          return m_tagManager.getTags(group);
                      } // end getGroupTags
                  
                  } // end GroupsByTagWidget
                  

                   

                  FTL is pretty straight forward...

                   

                  Message was edited by: Ryan Rutan

                    • Re: Tag Watching & RSS Feeds
                      Scott Finkel

                      Thanks a ton, Ryan! Of course you knew that I was going to ask about the FTL - tried this using the base tag-widget.ftl, which takes a tag as a param, but that didn't work. (I'm sure when i go look it'll be obvious why, but if you care to share your .ftl too that might help - if not, no worries, I'll figure it out)

                       

                      Again, thank you.

                        • Re: Tag Watching & RSS Feeds
                          Ryan Rutan

                          Not at my work computer, but I know I basically styled this after the social group browse FTL...lifted most of the code from the Your Groups Widget..if I remember correctly.  Will try to remember to attach tomorrow...sorry in/out a lot today...and not a lot of time to pull this out of source control. =)

                          • Re: Tag Watching & RSS Feeds
                            Ryan Rutan

                            Sorry got distracted yesterday....here is the FTL code that I have for this Widget:

                             

                            <#include "/template/socialgroup/include/socialgroup-macros.ftl"/>
                            <div>
                                <div>
                                    <span><@s.text name="xxxx.widgets.groupsByTag.tags.label"/><@s.text name="global.colon"/></span>
                                    <#list tags as tag>
                                        <a href="<@s.url value='/tags'/>?taggableTypes=SOCIAL_GROUP&tags=${tag.name?url}">${tag.name?html}</a><#if (tag_has_next)>,</#if>
                                    </#list>
                                </div>
                                
                                <div>
                                    <#assign resultCount = 0>
                                    <#assign imageSize = 0>
                                    <#if containerSize == enums['com.jivesoftware.community.widget.Widget$ContainerSize'].LARGE>
                                        <#assign imageSize = 1>
                                    </#if>
                                    <#if (groups.hasNext())>
                                        <#list groups as socialGroup>
                                        <div>
                                            <#assign socialGroupImageAvailable = widget.getIsSocialGroupImageAvailable(socialGroup,imageSize)>
                                            <#if (resultCount < numResults)>
                                                <div>
                                                    <a href="<@s.url value='${JiveResourceResolver.getJiveObjectURL(socialGroup)}'/>"><@displaySocialGroupImage socialGroup socialGroupImageAvailable false imageSize /></a>
                                                </div>
                                                <div>
                                                    <p>
                                                        <a href="<@s.url value='${JiveResourceResolver.getJiveObjectURL(socialGroup)}'/>">${socialGroup.name?html}</a>
                                                    </p>
                                                       <p>
                                                       <strong><@s.text name='sgroup.overview.tags'/></strong>
                                                       <#list widget.getGroupTags(socialGroup) as tag>
                                                           <a href="<@s.url value='/tags'/>?tags=${tag.name?url}">${tag.name?html}</a><#if (tag_has_next)>,</#if>
                                                           </#list>
                                                       </p>
                                                    <p>
                                                        <strong><@s.text name='sgroup.overview.createdate'/></strong> ${socialGroup.creationDate?date}
                                                    </p>
                                                    <p>
                                                         <strong><@s.text name='sgroup.overview.grouptype'/></strong>
                                                         <#if socialGroup.type == "SECRET">
                                                             <span><@s.text name="sgroup.secret"/> <span id="tags-tooltip"> </span></span>
                                                         <#elseif socialGroup.type == "PRIVATE">
                                                             <span><@s.text name="sgroup.private"/> <span id="tags-tooltip"> </span></span>
                                                         <#elseif socialGroup.type == "OPEN">
                                                             <span><@s.text name="sgroup.form.type.open.label"/> <span id="tags-tooltip"> </span></span>
                                                         <#elseif socialGroup.type == "MEMBER_ONLY">
                                                             <span><@s.text name="sgroup.form.type.member.label"/> <span id="tags-tooltip"> </span></span>
                                                         </#if>
                                                    </p>
                                                </div>
                                                <#assign resultCount = (resultCount+1)>
                                            <#else>
                                                    <#assign hasMoreGroups = true>
                                            </#if>
                                          </div>
                                        </#list>
                                    <#else>
                                        <div align="center">
                                            <span><@s.text name="xxxx.widgets.groupsByTag.msg.noGroupsFound"/></span>
                                        </div>
                                    </#if>
                                </div>
                                
                                <div>
                                        <#if (hasMoreGroups?exists && hasMoreGroups)>
                                                <#assign urlSuffix = "/?taggableTypes=SOCIAL_GROUP">
                                                <#list tags as tag>
                                                        <#assign urlSuffix = "${urlSuffix}&tags=${tag.name?url}">
                                                </#list>
                                                <a href="<@s.url value='/tags'/>${urlSuffix}"><@s.text name="xxxx.widgets.groupsByTag.viewMore.label"/></a>
                                        <#else>
                                                <a href="<@s.url value='/groups'/>"><@s.text name="xxxx.widgets.groupsByTag.viewAll.label"/></a>
                                        </#if>
                                </div>
                            </div>
                            
                              • Re: Tag Watching & RSS Feeds
                                Scott Finkel

                                Ryan, no problem about the delay, I've got a few other things I'm working on too. Thank you so much for posting that!! Please let me know if you're ever in San Diego, I will buy you a beer.

                                • Re: Tag Watching & RSS Feeds
                                  Scott Finkel

                                  Ryan, Just curious what version you're running this against today? I've installed it locally under 4.0.5 and although the properties of the widget display when editing, overall it doesn't seem to work. Will debug on my own, but if you're already running this against the same version, that will tell me i've done something wrong.

                                   

                                  Thanks again.

                                    • Re: Tag Watching & RSS Feeds
                                      Ryan Rutan

                                      We compiled this and have been running it against 2.5.15.  Just talked to our developer who's been tasked with upgrading all of our extensions to 4.x, and he said he needed to make the following changes in the FTL.

                                       

                                      Line #7:

                                      <#list tags as tag>
                                                 <a href="<@s.url value='/tags'/>?taggableTypes=700&tags=${tag.name?url}">${tag.name?html}</a><#if (tag_has_next)>,</#if>
                                             </#list>

                                       

                                      Line #66

                                      <#if (hasMoreGroups?exists && hasMoreGroups)>
                                                         <#assign urlSuffix = "/?taggableTypes=700">
                                                         <#list tags as tag>
                                                                 <#assign urlSuffix = "${urlSuffix}&tags=${tag.name?url}">
                                                         </#list>
                                                         <a href="<@s.url value='/tags'/>${urlSuffix}"><@s.text name="ni.devzone.widgets.groupsByTag.viewMore.label"/></a>
                                                 <#else>
                                                         <a href="<@s.url value='/groups'/>"><@s.text name="ni.devzone.widgets.groupsByTag.viewAll.label"/></a>
                                                 </#if>

                                       

                                      At first glance, these changes are pretty benign, but they were made.  I did have to strip out some minor stuff that referenced my companies internal specifics, but I think I replaced them all with xxx's.  What kind of error are you seeing?  hope this helps.

                                        • Re: Tag Watching & RSS Feeds
                                          Scott Finkel

                                          Thanks - I made those changes but still no dice.

                                           

                                          I'm not seeing any errors in std out at all. When I drop the widget on a sub-space page, I get this:

                                           

                                          2010-04-07_1235.png

                                          from there I can edit the settings just fine:

                                           

                                          2010-04-07_1237.png

                                           

                                          When I save the props, the result is the same as the first image above. (and yes, I am using a tag which exists, and is attributed to a social group)

                                           

                                          Last night I stepped through the code using the remote debugger in eclipse, and didn't hit any exceptions there either.

                                           

                                          It could be that enough has changed since initial dev on this that the underlying class isn't doing it's job properly, but one would think that if that were the case, I'd see an err. Weird.

                                          • Re: Tag Watching & RSS Feeds
                                            Scott Finkel

                                            FYI I just rebuilt the plugin with /template/socialgroup/include/socialgroup-macros.ftl alongisde the rest of the theme files, just in case that wasn't being gobbled up properly. Same result.

                                              • Re: Tag Watching & RSS Feeds
                                                Ryan Rutan

                                                Scott,

                                                 

                                                I've confirmed with our developer that it is working on 4.0.5.   Will get in touch with you tomorrow and see if we cant sink up the assets...it should be pretty straight forward....the migration was pretty superficial..

                                                  • Re: Tag Watching & RSS Feeds
                                                    Scott Finkel

                                                    Thanks Ryan, you rock!

                                                     

                                                    Here's what I've been able to find out. Using the freemarker template debugger plugin (http://www.jivesoftware.com/jivespace/docs/DOC-4066), I see that my widget's .ftl file isn't getting called (I would think this would throw an error, but it doesn't).

                                                     

                                                    In the widget code you posted, you have

                                                      protected static final String FREEMARKER_TEMPLATE = TEMPLATE_ROOT+"/widget-groupsByTag.ftl";

                                                     

                                                     

                                                    I'm not sure where TEMPLATE_ROOT gets set, so I just made that

                                                     

                                                    protected static final String FREEMARKER_TEMPLATE = "/template/widget/groups-bytag.ftl";

                                                     

                                                     

                                                    So I think that might be the problem(?) Can you tell me which file I should declare the TEMPLATE_ROOT var in? (apologies for being a noob here, and yes, i searched around on jivespace for that info)

                                                      • Re: Tag Watching & RSS Feeds
                                                        Ryan Rutan

                                                        That is going to be the path of your plugin..whereever you have it installed....and if you are getting no output...sounds like it could be the culprit.  TEMPLATE_ROOT is usually /plugins/PLUGIN_NAME/resources  from there /template/widget-groupsByTag.ftl.  This is one of the things I stripped out...so it's highly likely this is he culprit.  Good catch =)

                                                          • Re: Tag Watching & RSS Feeds
                                                            Scott Finkel

                                                            Ok, cool, I wasn't storing the template in the right place at all. (had it with my theme customizations) Once I put the template in the resources path of my plugin, it works!

                                                             

                                                            So the final template declaration is simply

                                                             

                                                            protected static final String FREEMARKER_TEMPLATE = "/template/widget/groups-bytag.ftl";

                                                             

                                                             

                                                             

                                                            AWESOME! THANK YOU!!

                                        • Re: Tag Watching & RSS Feeds
                                          Mark Zoeckler

                                          Hi Ryan -- I am interested in your taxonomy efforts, but cannot access the link you provided to the widget?  How can I get access or see what you are doing?

                                        • Re: Tag Watching & RSS Feeds
                                          Scott Finkel

                                          Follow up note: The entire reason I was able to figure out that my FTL template was in the wrong path was due to this fantastic plugin:

                                           

                                          http://www.jivesoftware.com/jivespace/docs/DOC-4066

                                           

                                          Once I installed that on my local instance, I noticed right away that my template was not in the list.

                                           

                                          Many thanks to the fine folk @ Swift Notion Software!

                                          • Re: Tag Watching & RSS Feeds
                                            mdolbec

                                            I am extremely interested in that widget that you eventually got to work.

                                             

                                            However, I am also a total newb with respect to Widgets.  I can figure out how to install them if they are in JAR format, but do not understand how to take the information you have shared in this thread and create my own widget.

                                             

                                            Do you think it is possible to package up what you have done so that others might download a JAR and install it?

                                             

                                            Thank you.  =Mike