Example #1
0
        public static Uri UrlForCollection(string superCollection, string collection)
        {
            if (superCollection == null || collection == null || string.IsNullOrEmpty(superCollection) || string.IsNullOrEmpty(collection))
            {
                return(null);
            }

            return(new Uri(_hostPath.Value + "/" + FriendlyUrl.FriendlyUrlEncode(superCollection) + "/" + FriendlyUrl.FriendlyUrlEncode(collection) + "/"));
        }
Example #2
0
 public static bool IsTimeline(string id)
 {
     if (IsGuid(id))
     {
         Guid parsedId = Guid.Parse(id);
         return(_storage.Timelines.Any(candidate => candidate.Id == parsedId));
     }
     else
     {
         string parsedTitle = FriendlyUrl.FriendlyUrlDecode(id);
         return(_storage.Timelines.Any(candidate => candidate.Title == parsedTitle));
     }
 }
Example #3
0
        public static string RootTimelineId(Uri collection)
        {
            string root = "00000000-0000-0000-0000-000000000000";

            if (collection != null)
            {
                if (IsGuid(collection.Segments[collection.Segments.Length - 1]))
                {
                    if (IsTimeline(collection.Segments[collection.Segments.Length - 1]))
                    {
                        Timeline timeline = _storage.GetRootTimeline(_storage.GetCollectionFromGuid(Guid.Parse(collection.Segments[collection.Segments.Length - 1])));
                        Guid     rootGuid = timeline.Id;
                        if (Guid.Parse(root) != rootGuid)
                        {
                            root = rootGuid.ToString();
                        }
                    }
                    if (IsExhibit(collection.Segments[collection.Segments.Length - 1]))
                    {
                        Timeline exhibit  = _storage.GetRootTimeline(_storage.GetCollectionFromExhibitGuid(Guid.Parse(collection.Segments[collection.Segments.Length - 1])));
                        Guid     rootGuid = exhibit.Id;
                        if (Guid.Parse(root) != rootGuid)
                        {
                            root = rootGuid.ToString();
                        }
                    }
                    if (IsContentItem(collection.Segments[collection.Segments.Length - 1]))
                    {
                        Timeline contentItem = _storage.GetRootTimeline(_storage.GetCollectionFromContentItemGuid(Guid.Parse(collection.Segments[collection.Segments.Length - 1])));
                        Guid     rootGuid    = contentItem.Id;
                        if (Guid.Parse(root) != rootGuid)
                        {
                            root = rootGuid.ToString();
                        }
                    }
                }
                else
                {
                    string   title    = FriendlyUrl.FriendlyUrlDecode(UrlCollection(collection).Substring(0, UrlCollection(collection).Length - 1));
                    Timeline timeline = _storage.GetRootTimeline(_storage.GetCollectionGuid(title));

                    if (timeline != null)
                    {
                        root = timeline.Id.ToString();
                    }
                }
            }

            return(root);
        }
Example #4
0
        /// <summary>
        /// Validates if a supercollection is present.
        /// </summary>
        /// <param name="superCollection"></param>
        /// <returns>Boolean value</returns>
        public static bool IsSuperCollectionPresent(string superCollection)
        {
            string _superCollection = FriendlyUrl.FriendlyUrlDecode(superCollection);

            if (_storage.SuperCollections.Any(candidate => candidate.Title.ToLower() == _superCollection))
            {
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Redirect("/");
                return(false);
            }
        }
Example #5
0
        protected static Uri UrlForCollection(SuperCollection superCollection, Collection collection)
        {
            if (superCollection == null || collection == null || string.IsNullOrEmpty(superCollection.Title) || string.IsNullOrEmpty(collection.Title))
            {
                return(null);
            }

            string path = _hostPath.Value + "/" + FriendlyUrl.FriendlyUrlEncode(superCollection.Title) + "/";

            if (string.CompareOrdinal(superCollection.Title, collection.Title) != 0)
            {
                path += FriendlyUrl.FriendlyUrlEncode(collection.Title) + "/";
            }

            return(new Uri(path));
        }
Example #6
0
        public static string GetTitle(Uri url)
        {
            StringBuilder title = new StringBuilder();

            string urlGuid = UrlGuid(url);

            if (url != null && url.Segments.Length > 1 && IsGuid(url.Segments[url.Segments.Length - 1]))
            {
                if (IsTimeline(urlGuid))
                {
                    title.Append(Timelines(urlGuid).Title + " - ");
                }
                else if (IsExhibit(urlGuid))
                {
                    title.Append(Exhibits(urlGuid).Title + " - ");
                }
                else if (IsContentItem(urlGuid))
                {
                    title.Append(ContentItems(urlGuid).Title + " - ");
                }
            }

            title.Append("ChronoZoom");

            if (!string.IsNullOrEmpty(UrlSuperCollection(url)))
            {
                if (UrlSuperCollection(url) != ConfigurationManager.AppSettings["DefaultSuperCollection"])
                {
                    title.Append(FriendlyUrl.FriendlyUrlDecode(" (" + UrlSuperCollection(url)) + ")");
                }
            }
            else if (!string.IsNullOrEmpty(UrlCollection(url)))
            {
                title.Append(FriendlyUrl.FriendlyUrlDecode(" (" + UrlCollection(url)) + ")");
            }

            return(title.ToString());
        }