/// <summary> /// Provides a view of features packages that have recently bee updated in the repository group. /// Return the three most recently updated packages in the group. /// </summary> public ActionResult BrowsePackages() { log.DebugFormat("Controller action requested"); var searchParameters = new PackageSearchParameters(); searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup()); // Set up the pagination Pager pager = new Pager(1, SettingsHelper.GetSearchResultsPerPage()); searchParameters.Offset = pager.RecordOffset; searchParameters.Limit = pager.RecordsPerPage; PackageSearchResultsModel model = new PackageSearchResultsModel(); model.SearchParameters = searchParameters; model.SearchResults = CkanHelper.GetClient().SearchPackages <Package>(searchParameters, new CacheSettings(SettingsHelper.GetSearchResultsCacheDuration())); SettingsHelper.FilterTitles(model.SearchResults.Results); model.Pager = pager; // Set the number of records to be paged pager.RecordCount = model.SearchResults.Count; // Render the view return(View(model)); }
public ActionResult Clear(string token, string id) { CheckToken(token); CkanClient client = CkanHelper.GetClient(); if (String.IsNullOrEmpty(id)) { client.ClearCache(); } else { client.ClearCache(id); } return(RedirectToAction("Index", new { token = token })); }
public ActionResult Index(string package) { log.DebugFormat("Controller action requested for package {0}", package); Package packageFound = CkanHelper.GetClient().GetPackage(package, new CacheSettings(SettingsHelper.GetPackageCacheDuration())); SettingsHelper.FilterTitle(packageFound); TagHelper.FilterTags(packageFound.Tags); if (package != null) { this.ConfigureBreadCrumbs(packageFound); this.ConfigureMetaTags(packageFound); } return(View(packageFound)); }
/// <summary> /// Provides a view of features packages in the repository group. Featured /// packages are those that are tagged with "featured". /// </summary> public ActionResult FeaturedPackages() { log.DebugFormat("Controller action requested"); // Create the CKAN search parameters var searchParameters = new PackageSearchParameters(); searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup()); searchParameters.Limit = SettingsHelper.GetHomeFeaturedPackageLimit(); searchParameters.Tags.Add(SettingsHelper.GetHomeFeaturedPackagesTag()); // Collect the results PackageSearchResponse <Package> results = CkanHelper.GetClient().SearchPackages <Package>(searchParameters, new CacheSettings(SettingsHelper.GetFeaturedPackagesCacheDuration())); SettingsHelper.FilterTitles(results.Results); // Render the view return(View(results)); }
// // GET: /Cache/ public ActionResult Index(string token) { CheckToken(token); CkanClient client = CkanHelper.GetClient(); var cachedItems = client.GetCachedRequests(); // Set up the breadcrumbs for this action var breadCrumbs = new BreadCrumbs(); breadCrumbs.Add(new BreadCrumb(SettingsHelper.GetCatalogBreadcrumbsBaseLabel(), "Index", "Home")); breadCrumbs.Add(new BreadCrumb("Admin")); breadCrumbs.Add(new BreadCrumb("Cache")); ViewData["BreadCrumbs"] = breadCrumbs; // Disable analytics on admin pages ViewData["DisableAnalytics"] = true; return(View(cachedItems)); }
public ActionResult Index(string q, int?page, string order_by, string tag, string mode) { log.DebugFormat("Controller action requested"); this.ConfigureBreadCrumbs(q, tag); // Create the CKAN search parameters var searchParameters = new PackageSearchParameters(); searchParameters.AggregateTagCounts = true; searchParameters.Query = q; searchParameters.Groups.Add(SettingsHelper.GetCatalogGroup()); // Ordering if (!String.IsNullOrEmpty(order_by)) { searchParameters.OrderBy = order_by; } // Tag if (!String.IsNullOrEmpty(tag)) { searchParameters.Tags.Add(tag); } // Build the view model for the results PackageSearchResultsModel model = new PackageSearchResultsModel(); Pager pager = null; if (mode == "table") { model.DisplayMode = ResultsDisplayMode.Table; searchParameters.Offset = 0; // TODO: In the table mode all results are currently returned and paginated client side. // This isn't scalable so this will need looked at in the future (AJAX pagination maybe?) searchParameters.Limit = CkanHelper.GetPackageCount(); } else // mode == list (default) { // Set up the pagination int pageNumber = 1; if (page != null) { pageNumber = (int)page; } pager = new Pager(pageNumber, SettingsHelper.GetSearchResultsPerPage()); searchParameters.Offset = pager.RecordOffset; searchParameters.Limit = pager.RecordsPerPage; } // Execute the search model.SearchParameters = searchParameters; model.SearchResults = CkanHelper.GetClient().SearchPackages <Package>(searchParameters, new CacheSettings(SettingsHelper.GetSearchResultsCacheDuration())); // Filter the titles SettingsHelper.FilterTitles(model.SearchResults.Results); // Filter the tags model.SearchResults.Tags = TagHelper.FilterTags(model.SearchResults.Tags); // Set the pager if we are using it if (pager != null) { // Set the number of records to be paged pager.RecordCount = model.SearchResults.Count; // Add the pager to the model model.Pager = pager; } // Render the view return(View(model)); }