public IndexPage()
        {
            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl      = settings.SiteUrl;
            SiteName     = settings.SiteName;
            SiteKeywords = settings.SiteKeywords;
            SiteSummary  = settings.SiteSummary;
            SiteAuthors  = settings.SiteAuthors;
            PageUrl      = settings.IndexPageUrl();

            IndexContent = Db.MainFeedRecentDynamicContent(20).Result.OrderByDescending(x => x.CreatedOn).ToList();

            var mainImageGuid = IndexContent
                                .FirstOrDefault(x => x.GetType() == typeof(PostContent) && x.MainPicture != null)?.MainPicture;

            if (mainImageGuid != null)
            {
                MainImage = new PictureSiteInformation(mainImageGuid);
            }

            if (!IndexContent.Any())
            {
                PreviousPosts = new List <IContentCommon>();
            }
            else
            {
                DateTime previousDate = IndexContent.Skip(_numberOfContentItemsToDisplay - 1).Max(x => x.CreatedOn);

                var previousLater = Tags.MainFeedPreviousAndLaterContent(6, previousDate);

                PreviousPosts = previousLater.previousContent;
            }
        }
Ejemplo n.º 2
0
        public SinglePhotoDiv(PhotoContent dbEntry)
        {
            DbEntry = dbEntry;

            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl  = settings.SiteUrl;
            SiteName = settings.SiteName;
            PageUrl  = settings.PhotoPageUrl(DbEntry);

            PictureInformation = new PictureSiteInformation(DbEntry.ContentId);
        }
Ejemplo n.º 3
0
        public SingleLinePage(LineContent dbEntry)
        {
            DbEntry = dbEntry;

            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl  = settings.SiteUrl;
            SiteName = settings.SiteName;
            PageUrl  = settings.LinePageUrl(DbEntry);

            if (DbEntry.MainPicture != null)
            {
                MainImage = new PictureSiteInformation(DbEntry.MainPicture.Value);
            }
        }
        public SingleFilePage(FileContent dbEntry)
        {
            DbEntry = dbEntry;

            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl  = settings.SiteUrl;
            SiteName = settings.SiteName;
            PageUrl  = settings.FilePageUrl(DbEntry);

            var db = Db.Context().Result;

            if (DbEntry.MainPicture != null)
            {
                MainImage = new PictureSiteInformation(DbEntry.MainPicture.Value);
            }
        }
        public SinglePostPage(PostContent dbEntry)
        {
            DbEntry = dbEntry;

            var settings = UserSettingsSingleton.CurrentSettings();

            SiteUrl  = settings.SiteUrl;
            SiteName = settings.SiteName;
            PageUrl  = settings.PostPageUrl(DbEntry);

            var db = Db.Context().Result;

            if (DbEntry.MainPicture != null)
            {
                MainImage = new PictureSiteInformation(DbEntry.MainPicture.Value);
            }

            var previousLater = Tags.MainFeedPreviousAndLaterContent(3, DbEntry.CreatedOn);

            PreviousPosts = previousLater.previousContent;
            LaterPosts    = previousLater.laterContent;
        }
        public static async Task <CameraRollGalleryPage> CameraRoll(DateTime?generationVersion,
                                                                    IProgress <string> progress)
        {
            var db = await Db.Context();

            progress?.Report("Starting Camera Roll Generation");

            var allDates = (await db.PhotoContents.Select(x => x.PhotoCreatedOn).ToListAsync()).Select(x => x.Date)
                           .Distinct().OrderByDescending(x => x).ToList();

            progress?.Report($"Found {allDates.Count} Dates with Photos for Camera Roll");

            if (allDates.Count == 0)
            {
                return new CameraRollGalleryPage
                       {
                           CreatedBy             = UserSettingsSingleton.CurrentSettings().DefaultCreatedBy,
                           PageUrl               = UserSettingsSingleton.CurrentSettings().CameraRollPhotoGalleryUrl(),
                           CameraRollContentTag  = new NoTag(),
                           SiteName              = UserSettingsSingleton.CurrentSettings().SiteName,
                           LastDateGroupDateTime = DateTime.MinValue,
                           MainImage             = null,
                           GenerationVersion     = generationVersion
                       }
            }
            ;

            var loopGoal = allDates.Count;

            var cameraRollContainer = new DivTag().AddClass("camera-roll-list");

            PictureSiteInformation mainImage = null;
            var isFirstItem  = true;
            var currentYear  = -1;
            var currentMonth = -1;

            var yearList = allDates.Select(x => x.Year).Distinct().OrderByDescending(x => x).ToList();

            for (var i = 0; i < allDates.Count; i++)
            {
                var loopDate = allDates[i];

                var newYear  = false;
                var newMonth = false;

                if (loopDate.Year != currentYear)
                {
                    newYear     = true;
                    currentYear = loopDate.Year;

                    var yearNavigationDiv = new DivTag().AddClass("camera-roll-year-list-container");

                    var yearLabelContainer = new DivTag().AddClass("camera-roll-year-list-item");
                    var yearLabel          = new DivTag().Text("Years:").AddClass("camera-roll-year-list-label");
                    yearLabelContainer.Children.Add(yearLabel);
                    yearNavigationDiv.Children.Add(yearLabelContainer);

                    foreach (var loopYear in yearList)
                    {
                        var yearContainer = new DivTag().AddClass("camera-roll-year-list-item");

                        if (loopYear == currentYear)
                        {
                            var activeYearContent = new DivTag().Text(loopYear.ToString())
                                                    .AddClass("camera-roll-year-list-content")
                                                    .AddClass("camera-roll-nav-current-selection");
                            yearContainer.Children.Add(activeYearContent);
                        }
                        else
                        {
                            var activeYearContent =
                                new LinkTag(loopYear.ToString(), $"#{loopYear}").AddClass(
                                    "camera-roll-year-list-content");
                            yearContainer.Children.Add(activeYearContent);
                        }

                        yearNavigationDiv.Children.Add(yearContainer);
                    }

                    cameraRollContainer.Children.Add(yearNavigationDiv);
                }

                if (loopDate.Month != currentMonth || newYear)
                {
                    newMonth     = true;
                    currentMonth = loopDate.Month;

                    var currentYearMonths = allDates.Where(x => x.Year == currentYear).Select(x => x.Month).Distinct()
                                            .OrderBy(x => x).ToList();

                    var monthNavigationDiv = new DivTag().AddClass("camera-roll-month-list-container");

                    var monthLabelContainer = new DivTag().AddClass("camera-roll-month-list-item");
                    var monthLabel          = new DivTag(currentYear.ToString()).Text("Months:")
                                              .AddClass("camera-roll-month-list-label");
                    monthLabelContainer.Children.Add(monthLabel);
                    monthNavigationDiv.Children.Add(monthLabelContainer);

                    for (var j = 1; j < 13; j++)
                    {
                        var monthContainer =
                            new DivTag($"{currentYear}-{currentMonth}").AddClass("camera-roll-month-list-item");

                        var monthText = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(j);

                        if (j == currentMonth)
                        {
                            var activeMonthContent = new DivTag().Text(monthText)
                                                     .AddClass("camera-roll-month-list-content")
                                                     .AddClass("camera-roll-nav-current-selection");
                            monthContainer.Children.Add(activeMonthContent);
                        }
                        else if (!currentYearMonths.Contains(j))
                        {
                            var activeMonthContent = new DivTag().Text(monthText)
                                                     .AddClass("camera-roll-month-list-content")
                                                     .AddClass("camera-roll-nav-unused-selection");
                            monthContainer.Children.Add(activeMonthContent);
                        }
                        else
                        {
                            var activeMonthContent =
                                new LinkTag(monthText, $"#{currentYear}-{j}").AddClass(
                                    "camera-roll-month-list-content");
                            monthContainer.Children.Add(activeMonthContent);
                        }

                        monthNavigationDiv.Children.Add(monthContainer);
                    }

                    cameraRollContainer.Children.Add(monthNavigationDiv);
                }

                if (i % 10 == 0)
                {
                    progress?.Report($"Camera Gallery Section - {loopDate:D} - {i} of {loopGoal}");
                }

                var startsAfterOrOn = loopDate.Date;
                var endsBefore      = loopDate.AddDays(1).Date;

                var datePhotos = await db.PhotoContents
                                 .Where(x => x.PhotoCreatedOn >= startsAfterOrOn && x.PhotoCreatedOn < endsBefore)
                                 .OrderBy(x => x.PhotoCreatedOn).ToListAsync();

                var infoItem = new DivTag().AddClass("camera-roll-info-item-container");

                var dateLink = new LinkTag($"{loopDate:yyyy MMMM d, dddd}",
                                           UserSettingsSingleton.CurrentSettings().DailyPhotoGalleryUrl(loopDate),
                                           "camera-roll-info-date-link");
                var dateDiv = new DivTag().AddClass("camera-roll-info-date");

                if (newMonth)
                {
                    dateDiv.Id($"{currentYear}-{currentMonth}");
                }

                dateDiv.Children.Add(dateLink);
                infoItem.Children.Add(dateDiv);

                var cameras = datePhotos
                              .Where(x => !string.IsNullOrWhiteSpace(x.CameraMake) && !string.IsNullOrWhiteSpace(x.CameraModel))
                              .Select(x => $"{x.CameraMake.Trim()} {x.CameraModel.Trim()}").Distinct().OrderBy(x => x).ToList()
                              .JoinListOfStringsToCommonUsageListWithAnd();
                infoItem.Children.Add(new DivTag().AddClass("camera-roll-info-camera").Text(cameras));

                var lenses = datePhotos.Where(x => !string.IsNullOrWhiteSpace(x.Lens)).Select(x => x.Lens.Trim())
                             .Distinct().OrderBy(x => x).ToList().JoinListOfStringsToCommonUsageListWithAnd();
                infoItem.Children.Add(new DivTag().AddClass("camera-roll-info-lens").Text(lenses));

                cameraRollContainer.Children.Add(infoItem);

                foreach (var loopPhotos in datePhotos)
                {
                    var listItemPhotoListItem = new DivTag().AddClass("camera-roll-photo-item-container");
                    var photoItem             = new PictureSiteInformation(loopPhotos.ContentId);
                    listItemPhotoListItem.Children.Add(
                        photoItem.PictureFigureWithLinkToPicturePageTag("(min-width: 1200px) 20vw, 120px"));

                    cameraRollContainer.Children.Add(listItemPhotoListItem);

                    if (isFirstItem)
                    {
                        isFirstItem = false;
                        mainImage   = photoItem;
                    }
                }
            }

            var createdByEntries =
                (await db.PhotoContents.GroupBy(x => x.PhotoCreatedBy).Select(x => x.Key).ToListAsync())
                .Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => x.Trim()).OrderBy(x => x).ToList();

            var toReturn = new CameraRollGalleryPage
            {
                CreatedBy             = string.Join(",", createdByEntries),
                PageUrl               = UserSettingsSingleton.CurrentSettings().CameraRollPhotoGalleryUrl(),
                CameraRollContentTag  = cameraRollContainer,
                SiteName              = UserSettingsSingleton.CurrentSettings().SiteName,
                LastDateGroupDateTime = allDates.First().Date,
                MainImage             = mainImage,
                GenerationVersion     = generationVersion
            };

            return(toReturn);
        }
    }