Example #1
0
        /// <summary>
        /// Enables processing of the result of an action method by a custom type that inherits from the <see cref="T:System.Web.Mvc.ActionResult"/> class.
        /// </summary>
        /// <param name="context">The context in which the result is executed. The context information includes the controller, HTTP content, request context, and route data.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";
            string format = string.IsNullOrEmpty(Format) ? "rss" : Format.ToLower();

            FeedBuilder.Build(Feed, context.HttpContext.Response.Output, format);
        }
Example #2
0
        private HttpResponseMessage Search(string key, int page)
        {
            var searchResults = this.service.GetSearchResults(key, page);

            if (searchResults == null)
            {
                this.service.CreateSearch(key.ToSearch <TContract>());
                searchResults = this.service.GetSearchResults(key, page);
            }
            if (searchResults == null)
            {
                throw new NotFoundException(string.Format("Search results not found for key {0}/{1}", key, page));
            }

            var feedBuilder = new FeedBuilder()
                              .WithEntityName(this.entityName)
                              .WithId("search")
                              .WithTitle("Search Results")
                              .WithItemTitle(this.entityName)
                              .WithItems(searchResults.Contracts);

            if (searchResults.NextPage.HasValue)
            {
                feedBuilder.AddMoreResultsLink(this.Request.RequestUri, searchResults.SearchResultsKey, searchResults.NextPage);
            }

            var feed = feedBuilder.Build();

            return(this.Request.CreateResponse(HttpStatusCode.OK, feed, new AtomSyndicationFeedFormatter(), "application/xml"));
        }
        private NewFeedWizard(IOpenPgp openPgp)
        {
            InitializeComponent();

            // Pages
            var downloadPage              = new DownloadPage(_feedBuilder, _installerCapture);
            var archiveExtractPage        = new ArchiveExtractPage(_feedBuilder);
            var entryPointPage            = new EntryPointPage(_feedBuilder);
            var installerCaptureStartPage = new InstallerCaptureStartPage(_installerCapture, _feedBuilder);
            var installerCaptureDiffPage  = new InstallerCaptureDiffPage(_installerCapture, _feedBuilder);
            var installerCollectFilesPage = new InstallerCollectFilesPage(_installerCapture);
            var installerAltDownloadPage  = new DownloadPage(_feedBuilder, _installerCapture);
            var installerExtractPage      = new ArchiveExtractPage(_feedBuilder, _installerCapture);
            var installerEntryPointPage   = new EntryPointPage(_feedBuilder);
            var detailsPage  = new DetailsPage(_feedBuilder);
            var iconPage     = new IconPage(_feedBuilder);
            var securityPage = new SecurityPage(_feedBuilder, openPgp);
            var donePage     = new DonePage();

            // Flows
            downloadPage.AsArchive    += () => PushPage(archiveExtractPage);
            downloadPage.AsSingleFile += () =>
            {
                _feedBuilder.GenerateCommands();
                PushPage(detailsPage);
            };
            downloadPage.AsInstaller += () => PushPage(installerCaptureStartPage);
            archiveExtractPage.Next  += () => PushPage(entryPointPage);
            entryPointPage.Next      += () =>
            {
                _feedBuilder.GenerateCommands();
                PushPage(detailsPage);
            };
            installerCaptureStartPage.Next            += () => PushPage(installerCaptureDiffPage);
            installerCaptureStartPage.Skip            += () => PushPage(archiveExtractPage);
            installerCaptureDiffPage.AsArchive        += () => PushPage(installerExtractPage);
            installerCaptureDiffPage.AltSource        += () => PushPage(installerCollectFilesPage);
            installerCollectFilesPage.Next            += () => PushPage(installerEntryPointPage);
            installerCollectFilesPage.ExistingArchive += () => PushPage(installerAltDownloadPage);
            installerAltDownloadPage.AsArchive        += () => PushPage(installerExtractPage);
            installerExtractPage.Next    += () => PushPage(installerEntryPointPage);
            installerEntryPointPage.Next += () =>
            {
                _installerCapture.CaptureSession.Finish();
                PushPage(detailsPage);
            };
            detailsPage.Next  += () => PushPage(iconPage);
            iconPage.Next     += () => PushPage(securityPage);
            securityPage.Next += () => PushPage(donePage);
            donePage.Finish   += () =>
            {
                _signedFeed = _feedBuilder.Build();
                Close();
            };

            // Start
            PushPage(downloadPage);
        }
        /// <summary>
        /// Convert this to a feed.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="author"></param>
        /// <param name="description"></param>
        /// <param name="title"></param>
        /// <param name="uri">The uri of the request</param>
        public static SyndicationFeed AsFeed <T>(Uri uri, string author, string title, string description)
        {
            IEntityService <T>   service = EntityRegistration.GetService <T>();
            IList <IPublishable> entries = service.GetRecentAs <IPublishable>(1, 20);
            //http://localhost:49739/Post/rss/

            string host = uri.Host;

            if (host.Contains("localhost"))
            {
                host = "http://localhost.com";
            }
            else
            {
                host = uri.AbsoluteUri;
            }
            var feed = FeedBuilder.Build(author, title, description, host, entries);

            return(feed);
        }
Example #5
0
        private ExitCode Finish()
        {
            if (_additionalArgs.Count != 3)
            {
                return(PrintHelp());
            }
            string snapshotFile = _additionalArgs[1];
            string feedFile     = _additionalArgs[2];

            if (FileExists(feedFile))
            {
                return(ExitCode.IOError);
            }

            var feedBuilder = new FeedBuilder();
            var session     = CaptureSession.Load(snapshotFile, feedBuilder);

            session.InstallationDir = _installationDirectory;
            session.Diff(_handler);

            feedBuilder.MainCandidate = string.IsNullOrEmpty(_mainExe)
                ? feedBuilder.Candidates.FirstOrDefault()
                : feedBuilder.Candidates.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(FileUtils.UnifySlashes(x.RelativePath), _mainExe));
            session.Finish();

            if (!string.IsNullOrEmpty(_zipFile))
            {
                if (FileExists(_zipFile))
                {
                    return(ExitCode.IOError);
                }

                var relativeUri = new Uri(Path.GetFullPath(feedFile)).MakeRelativeUri(new Uri(Path.GetFullPath(_zipFile)));
                session.CollectFiles(_zipFile, relativeUri, _handler);
                Log.Warn("If you wish to upload this feed and ZIP archive, make sure to turn the <archive>'s relative href into an absolute one.");
            }

            feedBuilder.Build().Save(feedFile);

            return(ExitCode.OK);
        }
Example #6
0
        private ExitCode Finish()
        {
            if (_additionalArgs.Count != 3) return PrintHelp();
            string snapshotFile = _additionalArgs[1];
            string feedFile = _additionalArgs[2];
            if (FileExists(feedFile)) return ExitCode.IOError;

            var feedBuilder = new FeedBuilder();
            var session = CaptureSession.Load(snapshotFile, feedBuilder);

            session.InstallationDir = _installationDirectory;
            session.Diff(_handler);

            feedBuilder.MainCandidate = string.IsNullOrEmpty(_mainExe)
                ? feedBuilder.Candidates.FirstOrDefault()
                : feedBuilder.Candidates.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(FileUtils.UnifySlashes(x.RelativePath), _mainExe));
            session.Finish();

            if (!string.IsNullOrEmpty(_zipFile))
            {
                if (FileExists(_zipFile)) return ExitCode.IOError;

                var relativeUri = new Uri(Path.GetFullPath(feedFile)).MakeRelativeUri(new Uri(Path.GetFullPath(_zipFile)));
                session.CollectFiles(_zipFile, relativeUri, _handler);
                Log.Warn("If you wish to upload this feed and ZIP archive, make sure to turn the <archive>'s relative href into an absolute one.");
            }

            feedBuilder.Build().Save(feedFile);

            return ExitCode.OK;
        }
Example #7
0
 private void donePage_Commit(object sender, WizardPageConfirmEventArgs e)
 {
     _signedFeed = _feedBuilder.Build();
 }
Example #8
0
        static void Main(string[] args)
        {
            FeedBuilder fb = new FeedBuilder();

            fb.Build();
        }