Skip to content

Commit

Permalink
GUI updates, fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerlrhodes committed Nov 26, 2017
1 parent b8d962c commit 99523b0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
21 changes: 19 additions & 2 deletions src/Bagombo/Services/MetaWebLogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Extensions.Logging;

namespace Bagombo.Services
{
Expand All @@ -27,14 +28,16 @@ public class MetaWebLogProvider : IMetaWeblogProvider
private readonly IHttpContextAccessor _context;
private readonly BagomboSettings _settings;
private readonly IImageService _imageService;
private readonly ILogger _logger;

public MetaWebLogProvider(IQueryProcessorAsync qp,
ICommandProcessorAsync cp,
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager,
IOptions<BagomboSettings> settings,
IHttpContextAccessor context,
IImageService imageService)
IImageService imageService,
ILogger<MetaWebLogProvider> logger)
{
_qp = qp;
_cp = cp;
Expand All @@ -43,6 +46,7 @@ public MetaWebLogProvider(IQueryProcessorAsync qp,
_settings = settings.Value;
_context = context;
_imageService = imageService;
_logger = logger;
}

private bool validateUser(string username, string password)
Expand All @@ -53,9 +57,11 @@ private bool validateUser(string username, string password)

if (result.Succeeded)
{
_logger.LogInformation($"Successful login for MetaWeblog for {username}");
return true;
}

_logger.LogWarning($"Failed login for MetaWeblog for {username}");
return false;
}

Expand Down Expand Up @@ -84,6 +90,7 @@ private string getImgUrl(string content)

public int AddCategory(string key, string username, string password, NewCategory category)
{
_logger.LogError("MetaWeblog - AddCategory not supported");
throw new NotImplementedException();
}

Expand All @@ -110,6 +117,7 @@ public string AddPost(string blogid, string username, string password, Post post

if (result.Succeeded)
{
_logger.LogInformation($"Successfully added post through metaweblog {post.title}");
if (post.categories.Count() > 0)
{
var sc = new SetBlogPostCategoriesByStringArrayCommand
Expand All @@ -122,6 +130,7 @@ public string AddPost(string blogid, string username, string password, Post post

if (scResult.Succeeded)
{
_logger.LogInformation($"Successfully added categories for post {post.title} through metaweblog");
return result.Command.Id.ToString();
}
}
Expand All @@ -131,6 +140,7 @@ public string AddPost(string blogid, string username, string password, Post post
}
}
}
_logger.LogError($"Error adding post through metaweblog {post.title}");
return "-1";
}

Expand All @@ -144,10 +154,12 @@ public bool DeletePost(string key, string postid, string username, string passwo

if (result.Succeeded)
{
_logger.LogInformation($"Successfully deleted post via metaweblog with id {postid}");
return true;
}
}
}
_logger.LogError($"Failed to delete post via metaweblog with id {postid}");
return false;
}

Expand Down Expand Up @@ -177,7 +189,8 @@ public bool EditPost(string postid, string username, string password, Post post,
if (result.Succeeded)
{
if(post.categories.Count() > 0)
{
{
_logger.LogInformation($"Successfully edited post via metaweblog {post.title}");
var sc = new SetBlogPostCategoriesByStringArrayCommand
{
Categories = post.categories.ToList(),
Expand All @@ -188,10 +201,12 @@ public bool EditPost(string postid, string username, string password, Post post,

if (scResult.Succeeded)
{
_logger.LogInformation($"Successfully set categories for post {post.title}");
return true;
}
else
{
_logger.LogError($"Failed to set categories for post {post.title}");
return false;
}
}
Expand All @@ -202,6 +217,7 @@ public bool EditPost(string postid, string username, string password, Post post,
}
}
}
_logger.LogError($"Failed to edit post {post.title}");
return false;
}

Expand Down Expand Up @@ -320,6 +336,7 @@ public MediaObjectInfo NewMediaObject(string blogid, string username, string pas
byte[] bytes = Convert.FromBase64String(mediaObject.bits);
var path = _imageService.SaveImage(bytes, mediaObject.name).GetAwaiter().GetResult();

_logger.LogInformation($"Uploaded image via metaweblog {path}");
return new MediaObjectInfo { url = path };
}
return null;
Expand Down
1 change: 1 addition & 0 deletions src/Bagombo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private void InitializeContainer(IApplicationBuilder app)
_container.CrossWire<ILogger<AuthorController>>(app);
_container.CrossWire<ILogger<MetaController>>(app);
_container.CrossWire<ILogger<MetaWeblogService>>(app);
_container.CrossWire<ILogger<MetaWebLogProvider>>(app);
_container.CrossWire<IAuthorizationHandler>(app);
_container.CrossWire<IAuthorizationService>(app);

Expand Down
10 changes: 2 additions & 8 deletions src/Bagombo/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</p>
</div>
<div class="col-md-3">
<a class="btn btn-primary btn-lg" href="https://github.com/tylerlrhodes/bagombo/releases" role="button">Download 0.2.4a</a>
<a class="btn btn-primary btn-lg" href="https://github.com/tylerlrhodes/bagombo/releases" role="button">Download 0.2.5a</a>
</div>
</div>
</div>
Expand All @@ -70,13 +70,7 @@
<div class="card-body pl-0">
<div class="container">
<div class="row">
<div class="col-lg-1 col-12">
@{
var img = bp.Image ?? $"{host}/images/bagombo-logo.png";
}
<img height="100" width="100" src="@img" />
</div>
<div class="col-lg-11 col-12 pl-4">
<div class="col-12 pl-4">
@{
var content = bp.Content.Split('\n')
.Where(line => !line.Contains("<pre><code"))
Expand Down
8 changes: 1 addition & 7 deletions src/Bagombo/Views/Home/Search.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@
<div class="card-body pl-0">
<div class="container">
<div class="row">
<div class="col-lg-1 col-12">
@{
var img = bp.Image ?? $"{host}/images/bagombo-logo.png";
}
<img height="100" width="100" src="@img" />
</div>
<div class="col-lg-11 col-12 pl-4">
<div class="col-12 pl-4">
@{
var content = bp.Content.Split('\n').Take(_settings.Value.LinesPerPost);
var contentString = string.Join('\n', content);
Expand Down
8 changes: 1 addition & 7 deletions src/Bagombo/Views/Home/TopicPosts.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@
<div class="card-body pl-0">
<div class="container">
<div class="row">
<div class="col-lg-1 col-12">
@{
var img = bp.Image ?? $"{host}/images/bagombo-logo.png";
}
<img height="100" width="100" src="@img" />
</div>
<div class="col-lg-11 col-12 pl-4">
<div class="col-12 pl-4">
@{
var content = bp.Content.Split('\n').Take(_settings.Value.LinesPerPost);
var contentString = string.Join('\n', content);
Expand Down

0 comments on commit 99523b0

Please sign in to comment.