public BlogController(IBlogService blog, IFileService files, IOptionsSnapshot <BlogSettings> settings, WebManifest manifest) { _blog = blog; _files = files; _settings = settings; _manifest = manifest; }
public MappyController(ILogger <MappyController> logger, RegionContext cx, WebManifest manifest) { _logger = logger; _cxt = cx; _manifest = manifest; }
public BlogController(IBlogService blog, ILogger <BlogController> logger, IOptionsSnapshot <BlogSettings> settings, WebManifest manifest) { _logger = logger; _blog = blog; _settings = settings; _manifest = manifest; }
public RobotsController(IBlogService blog, IOptionsSnapshot <BlogSettings> settings, WebManifest manifest) { _blog = blog; _settings = settings; _manifest = manifest; }
public EditModel(SiteSettings siteSettings, IOptionsSnapshot <BlogSettings> blogSettings, IBlogService blogService, WebManifest webManifest) { SiteSettings = siteSettings; BlogSettings = blogSettings; BlogService = blogService; Manifest = webManifest; }
public RobotsController( IBlogService blogService, IOptionsSnapshot <BlogOptions> blogSettings, WebManifest webManifest) { this._blogService = blogService; this.blogSettings = blogSettings; this.webManifest = webManifest; }
public BlogController( IBlogService blog, IOptionsSnapshot <BlogSettings> blogSettings, IOptionsSnapshot <NotificationSettings> notificationSettings, IEmailSender emailSender, WebManifest manifest) { this.blog = blog; this.emailSender = emailSender; this.blogSettings = blogSettings; this.notificationSettings = notificationSettings; this.manifest = manifest; }
private async Task <RerumManifestResponse> MakeRequest(WebManifest manifest, string method) { var rt = new RerumManifestResponse(); using (var client = new HttpClient()) { client.DefaultRequestHeaders .Add("Accept", new[] { Constants.MediaTypes.ApplicationJSon, Constants.MediaTypes.ApplicationJSonLD }); var authToken = await _tokenManager.GetTokenAsync(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken.AccessToken); var jsonSettings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }, NullValueHandling = NullValueHandling.Ignore }; var json = JsonConvert.SerializeObject(manifest, jsonSettings); var content = new StringContent(json, Encoding.UTF8, Constants.MediaTypes.ApplicationJSon); HttpResponseMessage response = null; string url = null; if (method.Equals("post", StringComparison.InvariantCultureIgnoreCase)) { url = $"{_rerumApiUrl}/api/create.action"; response = await client.PostAsync(url, content); // await client.PostAsJsonAsync(url, manifest); } else if (method.Equals("put", StringComparison.InvariantCultureIgnoreCase)) { url = $"{_rerumApiUrl}/api/update.action"; response = await client.PutAsync(url, content); } var jsonResponse = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) { _logger.LogDebug($"Manifest: Context: {manifest.Context}, id: {manifest.Id} post\\update successful."); rt = JsonConvert.DeserializeObject <RerumManifestResponse>(jsonResponse, jsonSettings); } else { _logger.LogWarning($"Unable to post\\update manifest: Context: {manifest.Context}, id: {manifest.Id}."); } } return(rt); }
/// <summary> /// Tries to create the <see cref="WebManifest"/> from configuration values /// </summary> /// <returns><c>true</c>, if get web manifest was created, <c>false</c> otherwise.</returns> /// <param name="dynamicWebManifest">Dynamic web manifest.</param> bool TryGetWebManifestFromConfiguration(out WebManifest dynamicWebManifest) { dynamicWebManifest = null; WebManifest webManifest = new WebManifest() { Name = Configuration["blog_name"] ?? Configuration["blog:name"], Description = Configuration["blog_description"] ?? Configuration["blog:description"], ShortName = Configuration["blog_shortname"] ?? Configuration["blog:shortname"], BackgroundColor = "#fff", ThemeColor = "#fff", StartUrl = "/", Display = "standalone", Icons = new Icon[] { new Icon() { Src = "/img/icon192x192.png", Sizes = "192x192" }, new Icon() { Src = "/img/icon512x512.png", Sizes = "512x512" } } }; if (webManifest.IsValid(out var webManifestError)) { // Do not send 'null' properties as they generate warnings on Chrome dev tools var rawJson = JsonConvert.SerializeObject(webManifest, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); // Using reflection because the property setter for "RawJson" is internal webManifest.GetType().GetProperty("RawJson").SetValue(webManifest, rawJson); dynamicWebManifest = webManifest; return(true); } return(false); }
public async Task <WebManifest> GetByAnnotationSourceId(long id) { var annotationSource = await _annotationSources.SingleOrDefaultAsync(s => s.AnnotationSourceId == id); var annotations = _annotations .Include(a => a.Target) .ThenInclude(t => t.Source) .Include(a => a.License) .Include(a => a.AnnotationType) .Include(a => a.Annotations) .Include(a => a.Tags).ThenInclude(t => t.Tag) .Where(a => a.Target.AnnotationSourceId == id && a.ParentId == null); var images = new List <WebAnnotation>(); await annotations.ForEachAsync(a => { images.AddRange(WebAnnotationService.ConvertAnnotationsToWebAnnotation(a, _apiBaseUrl)); }); var canvases = new List <WebCanvas>(); canvases.Add(new WebCanvas { Id = $"{_apiBaseUrl}/api/WebCanvases/{annotationSource.AnnotationSourceId}", Images = images }); var sequence = new WebSequence(); sequence.Canvases = canvases; var sequences = new List <WebSequence>(); sequences.Add(sequence); var manifest = new WebManifest { Id = annotationSource.RerumStorageUrl, Context = $"{_apiBaseUrl}/api/WebManifests/{annotationSource.AnnotationSourceId}/context.json", Sequences = sequences }; return(manifest); }
public PageController(IPageService page, IOptionsSnapshot <PageSettings> settings, WebManifest manifest) { _page = page; _settings = settings; _manifest = manifest; }
public BlogController(IBlogService blog, IOptionsSnapshot <BlogSettings> settings, WebManifest manifest) { this.blog = blog; this.settings = settings; this.manifest = manifest; }
public async Task <RerumManifestResponse> PutManifest(WebManifest manifest) { _logger.LogDebug($"Putting manifest: Context: {manifest.Context}, id: {manifest.Id}."); return(await MakeRequest(manifest, "put")); }