Exemplo n.º 1
0
        public void IsValidUrl_ChecksVimeoUrl_IsValid()
        {
            var url1 = "https://vimeo.com/12345678";
            var url2 = "http://vimeo.com/12345678";
            var url3 = "https://www.vimeo.com/12345678";
            var url4 = "http://vimeo.com/channels/12345678";
            var url5 = "https://vimeo.com/groups/name/videos/12345678";
            var url6 = "http://vimeo.com/album/2222222/video/12345678";
            var url7 = "http://vimeo.com/12345678?param=test";
            var url8 = "http://player.vimeo.com/video/12345678";

            var url9  = "http://www.google.com";
            var url10 = "http://www.vimeo.com/ABCDEFGH";

            Assert.True(SocialMediaHelper.IsValidUrl(url1, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url2, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url3, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url4, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url5, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url6, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url7, SocialMediaType.VimeoVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url8, SocialMediaType.VimeoVideo));

            Assert.False(SocialMediaHelper.IsValidUrl(url9, SocialMediaType.VimeoVideo));
            Assert.False(SocialMediaHelper.IsValidUrl(url10, SocialMediaType.VimeoVideo));

            Assert.Equal("12345678", SocialMediaHelper.GetId(url1, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url2, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url3, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url4, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url5, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url6, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url7, SocialMediaType.VimeoVideo));
            Assert.Equal("12345678", SocialMediaHelper.GetId(url8, SocialMediaType.VimeoVideo));
        }
Exemplo n.º 2
0
        public void IsValidUrl_ChecksFacebookUrl_IsValid()
        {
            var url1 = "https://www.facebook.com/example";
            var url2 = "http://facebook.com/example?parm=test";
            var url3 = "http://www.facebook.com/#!/example";
            var url4 = "http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555";
            var url5 = "http://www.facebook.com/pages/Vanity-Url/123456";
            var url6 = "http://www.facebook.com/bounce_page#!/pages/Vanity-Url/123456";
            var url7 = "http://www.facebook.com/bounce_page#!/example?v=app_166292090072334";

            var url9  = "http://www.google.com";
            var url10 = "http://www.twitter.com";

            Assert.True(SocialMediaHelper.IsValidUrl(url1, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url2, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url3, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url4, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url5, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url6, SocialMediaType.FacebookProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url7, SocialMediaType.FacebookProfile));

            Assert.False(SocialMediaHelper.IsValidUrl(url9, SocialMediaType.FacebookProfile));
            Assert.False(SocialMediaHelper.IsValidUrl(url10, SocialMediaType.FacebookProfile));

            Assert.Equal("example", SocialMediaHelper.GetId(url1, SocialMediaType.FacebookProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url2, SocialMediaType.FacebookProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url3, SocialMediaType.FacebookProfile));
            Assert.Equal("123456", SocialMediaHelper.GetId(url4, SocialMediaType.FacebookProfile));
            Assert.Equal("123456", SocialMediaHelper.GetId(url5, SocialMediaType.FacebookProfile));
            Assert.Equal("123456", SocialMediaHelper.GetId(url6, SocialMediaType.FacebookProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url7, SocialMediaType.FacebookProfile));
        }
Exemplo n.º 3
0
        public void IsValidUrl_ChecksYouTubeUrl_IsValid()
        {
            var url1 = "http://www.youtube.com/watch?v=-wtIMTCHWuI&param=test";

            var url2 = "https://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1";

            var url3 = "http://youtu.be/-wtIMTCHWuI";

            //not supported var url4 = "http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json";

            var url5 = "http://www.google.com";

            var url6 = "http://www.youtube.com/wtIMTCHWuI";

            Assert.True(SocialMediaHelper.IsValidUrl(url1, SocialMediaType.YouTubeVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url2, SocialMediaType.YouTubeVideo));
            Assert.True(SocialMediaHelper.IsValidUrl(url3, SocialMediaType.YouTubeVideo));
            //Assert.True(SocialMediaHelper.IsValidUrl(url4, SocialMediaType.YouTubeVideo));
            Assert.False(SocialMediaHelper.IsValidUrl(url5, SocialMediaType.YouTubeVideo));
            Assert.False(SocialMediaHelper.IsValidUrl(url6, SocialMediaType.YouTubeVideo));

            Assert.Equal("-wtIMTCHWuI", SocialMediaHelper.GetId(url1, SocialMediaType.YouTubeVideo));
            Assert.Equal("-wtIMTCHWuI", SocialMediaHelper.GetId(url2, SocialMediaType.YouTubeVideo));
            Assert.Equal("-wtIMTCHWuI", SocialMediaHelper.GetId(url3, SocialMediaType.YouTubeVideo));
        }
Exemplo n.º 4
0
        public void CategorizeUrl_ReturnsCorrect_SocialMediaType()
        {
            var url1 = "http://www.youtube.com/watch?v=-wtIMTCHWuI";
            var url2 = "http://www.google.com";
            var url3 = "https://vimeo.com/12345678";
            var url4 = "http://twitter.com/example";
            var url5 = "http://www.linkedin.com/in/some-name/";
            var url6 = "https://www.facebook.com/my_page_id";

            Assert.Equal(SocialMediaType.YouTubeVideo, SocialMediaHelper.CategorizeUrl(url1));
            Assert.Equal(SocialMediaType.Unknown, SocialMediaHelper.CategorizeUrl(url2));
            Assert.Equal(SocialMediaType.VimeoVideo, SocialMediaHelper.CategorizeUrl(url3));
            Assert.Equal(SocialMediaType.TwitterProfile, SocialMediaHelper.CategorizeUrl(url4));
            Assert.Equal(SocialMediaType.LinkedInProfile, SocialMediaHelper.CategorizeUrl(url5));
            Assert.Equal(SocialMediaType.FacebookProfile, SocialMediaHelper.CategorizeUrl(url6));
        }
Exemplo n.º 5
0
        public void IsValidUrl_ChecksLinkedInUrl_IsValid()
        {
            var url1 = "http://uk.linkedin.com/pub/some-name/1/1b3/b45/";
            var url2 = "https://nl.linkedin.com/pub/some-name/11/223/544";
            var url3 = "http://www.linkedin.com/in/some-name/";
            var url4 = "http://linkedin.com/in/some-name?param=test";
            var url5 = "http://nl.linkedin.com/in/some-name";
            var url6 = "http://nl.linkedin.com/in/some-name/";

            var url7 = "http://www.google.com";
            var url8 = "http://www.linkedin.com";

            Assert.True(SocialMediaHelper.IsValidUrl(url1, SocialMediaType.LinkedInProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url2, SocialMediaType.LinkedInProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url3, SocialMediaType.LinkedInProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url4, SocialMediaType.LinkedInProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url5, SocialMediaType.LinkedInProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url6, SocialMediaType.LinkedInProfile));

            Assert.False(SocialMediaHelper.IsValidUrl(url7, SocialMediaType.LinkedInProfile));
            Assert.False(SocialMediaHelper.IsValidUrl(url8, SocialMediaType.LinkedInProfile));
        }
Exemplo n.º 6
0
        public void IsValidUrl_ChecksTwitterUrl_IsValid()
        {
            var url1 = "http://twitter.com/example";
            var url2 = "https://twitter.com/example";
            var url3 = "http://www.twitter.com/example";
            var url4 = "https://www.twitter.com/example?param=test";

            var url5 = "http://www.google.com";
            var url6 = "http://www.twitter.com";

            Assert.True(SocialMediaHelper.IsValidUrl(url1, SocialMediaType.TwitterProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url2, SocialMediaType.TwitterProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url3, SocialMediaType.TwitterProfile));
            Assert.True(SocialMediaHelper.IsValidUrl(url4, SocialMediaType.TwitterProfile));

            Assert.False(SocialMediaHelper.IsValidUrl(url5, SocialMediaType.TwitterProfile));
            Assert.False(SocialMediaHelper.IsValidUrl(url6, SocialMediaType.TwitterProfile));

            Assert.Equal("example", SocialMediaHelper.GetId(url1, SocialMediaType.TwitterProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url2, SocialMediaType.TwitterProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url3, SocialMediaType.TwitterProfile));
            Assert.Equal("example", SocialMediaHelper.GetId(url4, SocialMediaType.TwitterProfile));
        }
Exemplo n.º 7
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            // Initialize variables
            string dataJobLocation = String.Empty, dataLogo = String.Empty, dataThemeColor = String.Empty, dataButtonSize = String.Empty, dataQuestions = String.Empty;
            string src       = "http://platform.linkedin.com/in.js";
            string apiKey    = LinkedInHelper.GetLinkedInApiKey(SiteContext.CurrentSiteName);
            string apiSecret = LinkedInHelper.GetLinkedInSecretKey(SiteContext.CurrentSiteName);

            // Check settings
            if (!String.IsNullOrEmpty(apiKey) && !String.IsNullOrEmpty(apiSecret))
            {
                // Check if optional parameters are set and transform them accordingly
                if (!string.IsNullOrEmpty(CompanyLogo))
                {
                    dataLogo = "data-logo=\"" + URLHelper.GetAbsoluteUrl(CompanyLogo) + "\"";
                }

                if (!string.IsNullOrEmpty(JobLocation))
                {
                    dataJobLocation = "data-joblocation=\"" + JobLocation + "\"";
                }

                if (!string.IsNullOrEmpty(ThemeColor))
                {
                    dataThemeColor = "data-themecolor=\"" + ThemeColor + "\"";
                }

                if (ButtonSize.EqualsCSafe("medium"))
                {
                    dataButtonSize = "data-size=\"medium\"";
                }

                // Parse questions string and format it
                if (!string.IsNullOrEmpty(Questions))
                {
                    dataQuestions = "data-questions='[";
                    string[] questionArray = Questions.Split(new string[1] {
                        Environment.NewLine
                    }, StringSplitOptions.None);
                    foreach (string s in questionArray)
                    {
                        dataQuestions += "{\"question\": \"" + s + "\"},";
                    }
                    dataQuestions  = dataQuestions.TrimEnd(',');
                    dataQuestions += "]'";
                }

                // Build plugin code
                string output = "<div style=\"overflow: hidden; width: {0}px;\"><script src=\"{1}\" type=\"text/javascript\">api_key: {2}</script><script type=\"IN/Apply\" data-companyid=\"{3}\" data-jobtitle=\"{4}\" data-email=\"{5}\" {6} data-phone=\"{7}\" data-coverletter=\"{8}\" {9} data-showtext=\"{10}\" {11} {12} {13}></script></div>";
                ltlPluginCode.Text = String.Format(output, Width, src, apiKey, CompanyID, JobTitle, DeliveryEmail, dataJobLocation, RequestPhone, RequestCoverLetter, dataLogo, ShowHelpText.ToString().ToLowerCSafe(), dataThemeColor, dataButtonSize, dataQuestions);
            }
            else
            {
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    string pathToSettings = SocialMediaHelper.GetPathToLinkedInSettings();

                    ltlPluginCode.Text = "<span class='ErrorLabel'>" + String.Format(ResHelper.GetString("socialnetworking.linkedin.settingsrequired"), pathToSettings) + "</span>";
                }

                // Log event
                EventLogProvider.LogException("SocialMedia", "LinkedInApplyWith", new Exception("Missing LinkedIn settings."));
            }
        }
    }
    /// <summary>
    /// Initializes the control properties
    /// </summary>
    protected override void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do not process
        }
        else
        {
            string apiKey      = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSGooglePlusClientID");
            string apiSecret   = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSGooglePlusClientSecret");
            string accessToken = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSGooglePlusAccessToken");

            // Check Social networking DLL and settings
            if (!SystemContext.IsFullTrustLevel)
            {
                // Error label is displayed in Design mode when Dll is renamed
                ShowDesignErrorOrHide(GetString("socialnetworking.fulltrustrequired"));
            }
            else if (String.IsNullOrEmpty(apiKey) || String.IsNullOrEmpty(apiSecret) || String.IsNullOrEmpty(accessToken))
            {
                // Error label is displayed in Design mode when missing settings
                string pathToSettings = SocialMediaHelper.GetPathToGooglePlusSettings();
                ShowDesignErrorOrHide(String.Format(GetString("socialnetworking.googleplus.allsettingsmissing"), pathToSettings));
            }
            else
            {
                // Process ID - it can be URL
                string showID = ExtractUserID(FeedID);

                GooglePlusPerson profile = null;

                // Fetch data from Google+
                try
                {
                    // Try to get person directly
                    profile = GooglePlusProvider.GetProfileInfo(showID);
                }
                catch
                {
                    try
                    {
                        // Try alternative approach (search for person)
                        profile = GooglePlusProvider.FindPerson(showID);
                    }
                    catch
                    {
                        ShowDesignErrorOrHide(String.Format(GetString("sm.googleplus.nopeoplefound"), showID));
                    }
                }


                if (profile != null)
                {
                    showID = profile.UserID;
                    List <GooglePlusActivity> activities = GooglePlusProvider.GetActivities(showID, NumberOfActivities);
                    // Build code for plugin
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<div class=\"gpaf-plugin\"><div class=\"gpaf-doc\" style=\"width: ");
                    sb.Append(Width);
                    sb.Append("px; height: ");
                    sb.Append(Height);
                    sb.Append("px; border: 1px solid ");
                    sb.Append(BorderColor);
                    sb.Append("; position: relative; background-color: ");
                    sb.Append(ShellBackgroundColor);
                    sb.Append("\"><div style=\"margin: 15px;\">");

                    // Build plugin header
                    sb.Append("<div class=\"gpaf-header\">");

                    sb.Append("<table><tr><td style=\"vertical-align: center;\">");
                    sb.Append("<a href=\"");
                    sb.Append(profile.URL);
                    sb.Append("\">");
                    sb.Append("<img src=\"");
                    string imageURL = profile.ImageURL.Remove(profile.ImageURL.Length - 2) + "40";
                    sb.Append(imageURL);
                    sb.Append("\" alt=\"");
                    sb.Append(profile.DisplayName);
                    sb.Append("\" style=\"float: left; border: none;\" />");
                    sb.Append("</a>");
                    sb.Append("</td>");

                    sb.Append("<td style=\"vertical-align: center; padding-left: 10px;\">");
                    sb.Append("<a href=\"");
                    sb.Append(profile.URL);
                    sb.Append("\" style=\"text-decoration: none; font-size: 25px; color: ");
                    sb.Append(ShellTextColor);
                    sb.Append(";\">");
                    sb.Append(profile.DisplayName);
                    sb.Append("</a>");
                    sb.Append("</td></tr></table>");

                    sb.Append("</div>");

                    // Insert section separator
                    sb.Append("<div class=\"gpaf-doc-separator\" style=\"height: 15px; margin-top: 15px; width: 100%; border-top: 1px solid ");
                    sb.Append(BorderColor);
                    sb.Append(";\"></div>");

                    // Build plugin body
                    sb.Append("<div class=\"gpaf-body\" style=\"height: ");
                    sb.Append(Height - 164);
                    sb.Append("px; overflow: ");
                    sb.Append((Scrollbar) ? "auto" : "hidden");
                    sb.Append(";\">");

                    int counting = 1;
                    foreach (GooglePlusActivity s in activities)
                    {
                        sb.Append("<div class=\"gpaf-activity\" style=\"color: ");
                        sb.Append(ActivityTextColor);
                        sb.Append("\">");
                        sb.Append("<div class=\"gpaf-activity-text\">");
                        sb.Append(s.Content);
                        sb.Append("</div>");
                        sb.Append("<div class=\"gpaf-activity-footer\" style=\"color: ");
                        sb.Append(ActivityFooterTextColor);
                        sb.Append("; font-size: 13px; margin-top: 3px;\">");
                        sb.Append(s.Published);
                        sb.Append("</div>");
                        sb.Append("</div>");

                        // Insert activity separator
                        if (counting < activities.Count)
                        {
                            sb.Append("<div class=\"gpaf-body-separator\" style=\"height: 10px; margin-top: 5px; width: 100%; border-top: 1px dashed ");
                            sb.Append(BorderColor);
                            sb.Append(";\"></div>");
                            counting++;
                        }
                    }
                    sb.Append("</div></div>");

                    // Insert section separator
                    sb.Append("<div style=\"margin: 15px; position: absolute; bottom: 0px; left: 0px; width: ");
                    sb.Append(Width - 30);
                    sb.Append("px;\">");
                    sb.Append("<div class=\"gpaf-doc-separator\" style=\"height: 15px; margin-top: 15px; width: 100%; border-top: 1px solid ");
                    sb.Append(BorderColor);
                    sb.Append(";\"></div>");

                    // Build plugin footer
                    sb.Append("<div class=\"gpaf-footer\">");
                    sb.Append("<a href=\"https://plus.google.com\">");
                    sb.Append("<img src=\"https://ssl.gstatic.com/images/icons/gplus-32.png\" alt=\"\" style=\"float: left; border: none;\" />");
                    sb.Append("</a>");

                    sb.Append("<div class=\"gpaf-footer-text\" style=\"text-align: left; margin-left: 50px;\">");
                    sb.Append("<table style=\"height: 32px;\"><tr><td style=\"vertical-align: center;\">");
                    sb.Append("<a href=\"");
                    sb.Append(profile.URL);
                    sb.Append("\" style=\"text-decoration: none; font-size: 12px; color: ");
                    sb.Append(ShellTextColor);
                    sb.Append(";\">");
                    sb.Append(ResHelper.GetString("socialnetworking.viewfullprofile"));
                    sb.Append("</a>");
                    sb.Append("</td></tr></table>");
                    sb.Append("</div>");

                    sb.Append("<div style=\"clear: both;\"></div>");
                    sb.Append("</div>");

                    // Close open divs and finish plugin
                    sb.Append("</div></div></div>");
                    ltlPluginCode.Text = sb.ToString();
                }
                else
                {
                    ShowDesignErrorOrHide(String.Format(GetString("sm.googleplus.nopeoplefound"), showID));
                }
            }
        }
    }