Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from master #521

Merged
merged 14 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Welcome to Piranha.Core

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ba7cbafe380b4c2796b731562c5166e0)](https://www.codacy.com/app/tidyui/piranha.core?utm_source=github.com&utm_medium=referral&utm_content=PiranhaCMS/piranha.core&utm_campaign=Badge_Grade)
[![CodeFactor](https://www.codefactor.io/repository/github/piranhacms/piranha.core/badge)](https://www.codefactor.io/repository/github/piranhacms/piranha.core)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/PiranhaCMS/piranha.core.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/PiranhaCMS/piranha.core/alerts/)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/PiranhaCMS/piranha.core.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/PiranhaCMS/piranha.core/context:javascript)
[![Gitter chat](https://badges.gitter.im/PiranhaCMS/Piranha.png)](https://gitter.im/PiranhaCMS/Piranha)
Expand Down
2 changes: 1 addition & 1 deletion core/Piranha.AspNetCore.Identity/DefaultIdentitySeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DefaultIdentitySeed(IDb db, UserManager<User> userManager)
/// </summary>
public async Task CreateAsync()
{
if (_db.Users.Any())
if (!_db.Users.Any())
{
var user = new User
{
Expand Down
10 changes: 4 additions & 6 deletions core/Piranha.AspNetCore/HttpCaching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/

using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -37,9 +37,7 @@ public static bool IsCached(HttpContext context, HttpCacheInfo serverInfo)
if (clientInfo.LastModified.HasValue)
{
return clientInfo.LastModified.Value >= serverInfo.LastModified.Value;

}

return false;
}

Expand Down Expand Up @@ -76,8 +74,8 @@ public static HttpCacheInfo Get(HttpContext context)
{
info.LastModified = DateTime.Parse(lastMod);
}
catch
{
catch
{
info.LastModified = null;
}
}
Expand Down
31 changes: 20 additions & 11 deletions core/Piranha.Azure.BlobStorage/BlobStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/

using Microsoft.WindowsAzure.Storage;
Expand Down Expand Up @@ -34,27 +34,36 @@ public class BlobStorage : IStorage
private string _containerUrl;

/// <summary>
/// Default constructor.
/// Creates a new Blog Storage service from the given credentials.
/// </summary>
public BlobStorage(StorageCredentials credentials, string containerName = "uploads")
public BlobStorage(StorageCredentials credentials, string containerName = "uploads")
{
_storage = new CloudStorageAccount(credentials, true);
_containerName = containerName;
}

/// <summary>
/// Creates a new Blob Storage service from the given connection string.
/// </summary>
public BlobStorage(string connectionString, string containerName = "uploads")
{
_storage = CloudStorageAccount.Parse(connectionString);
_containerName = containerName;
}

/// <summary>
/// Opens a new storage session.
/// </summary>
/// <returns>A new open session</returns>
public async Task<IStorageSession> OpenAsync()
public async Task<IStorageSession> OpenAsync()
{
var session = _storage.CreateCloudBlobClient();
var container = session.GetContainerReference(_containerName);

if (!await container.ExistsAsync())
if (!await container.ExistsAsync())
{
await container.CreateAsync();
await container.SetPermissionsAsync(new BlobContainerPermissions()
await container.SetPermissionsAsync(new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
Expand All @@ -69,16 +78,16 @@ await container.SetPermissionsAsync(new BlobContainerPermissions()
/// </summary>
/// <param name="id">The media resource id</param>
/// <returns>The public url</returns>
public string GetPublicUrl(string id)
public string GetPublicUrl(string id)
{
if (!string.IsNullOrWhiteSpace(id))
if (!string.IsNullOrWhiteSpace(id))
{
if (string.IsNullOrEmpty(_containerUrl))
if (string.IsNullOrEmpty(_containerUrl))
{
var session = _storage.CreateCloudBlobClient();
var container = session.GetContainerReference(_containerName);

_containerUrl = container.Uri.AbsoluteUri;
_containerUrl = container.Uri.AbsoluteUri;
}
return _containerUrl + "/" + id;
}
Expand Down
20 changes: 18 additions & 2 deletions core/Piranha.Azure.BlobStorage/BlobStorageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/

using Microsoft.Extensions.DependencyInjection;
Expand All @@ -30,4 +30,20 @@ public static IServiceCollection AddPiranhaBlobStorage(this IServiceCollection s

return services;
}

/// <summary>
/// Adds the services for the Azure BlobStorage service.
/// </summary>
/// <param name="services">The current service collection</param>
/// <param name="connectionString">The connection string</param>
/// <param name="containerName">The optional container name</param>
/// <param name="scope">The optional service scope. Default is singleton</param>
/// <returns>The service collection</returns>
public static IServiceCollection AddPiranhaBlobStorage(this IServiceCollection services,
string connectionString, string containerName = "uploads", ServiceLifetime scope = ServiceLifetime.Singleton)
{
services.Add(new ServiceDescriptor(typeof(IStorage), sp => new BlobStorage(connectionString, containerName), scope));

return services;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>5.3.0</Version>
<Version>5.3.1</Version>
<Company>Piranha CMS</Company>
<AssemblyTitle>Piranha.Azure.BlogStorage</AssemblyTitle>
<RootNamespace>Piranha.Azure</RootNamespace>
Expand All @@ -10,6 +10,7 @@
<ProjectReference Include="..\Piranha\Piranha.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" Version="9.3.2" />
<PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="9.4.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion core/Piranha.ImageSharp/Piranha.ImageSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyTitle>Piranha.ImageSharp</AssemblyTitle>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0006" />
<ProjectReference Include="..\Piranha\Piranha.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/

using System;
Expand Down Expand Up @@ -240,7 +240,6 @@ public IActionResult AddRegion([FromBody]Models.PageRegionModel model)
return new NotFoundResult();
}


[HttpPost]
[Route("manager/post/alias")]
[Authorize(Policy = Permission.PostsEdit)]
Expand Down
23 changes: 11 additions & 12 deletions core/Piranha.Manager/Areas/Manager/Models/PageListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/

using System;
Expand All @@ -16,7 +16,7 @@ namespace Piranha.Areas.Manager.Models
{
public class PageListModel
{
public class SiteInfo
public class SiteInfo
{
public string Id { get; set; }
public string Title { get; set; }
Expand Down Expand Up @@ -44,14 +44,13 @@ public class SiteInfo
/// </summary>
public string SiteId { get; set; }


/// <summary>
/// Gets/sets the current site title.
/// </summary>
public string SiteTitle { get; set; }

/// <summary>
/// Gets/sets if the user should be able
/// Gets/sets if the user should be able
/// to edit the site content.
/// </summary>
public bool HasSiteContent { get; set; }
Expand All @@ -75,18 +74,18 @@ public class SiteInfo
/// <param name="siteId">The optional site id</param>
/// <param name="pageId">The optional page id</param>
/// <returns>The model</returns>
public static PageListModel Get(IApi api, Guid? siteId, string pageId = null)
public static PageListModel Get(IApi api, Guid? siteId, string pageId = null)
{
var model = new PageListModel();

var site = siteId.HasValue ?
api.Sites.GetById(siteId.Value) : api.Sites.GetDefault();
var defaultSite = api.Sites.GetDefault();

if (site == null)
{
site = defaultSite;
}
if (site == null)
{
site = defaultSite;
}

model.SiteId = site.Id == defaultSite.Id ? "" : site.Id.ToString();
model.SiteTitle = site.Title;
Expand All @@ -95,14 +94,14 @@ public static PageListModel Get(IApi api, Guid? siteId, string pageId = null)
model.PageId = pageId;
model.PageTypes = api.PageTypes.GetAll().ToList();
model.Sitemap = api.Sites.GetSitemap(site.Id, onlyPublished: false);
model.Sites = api.Sites.GetAll().Select(s => new SiteInfo
model.Sites = api.Sites.GetAll().Select(s => new SiteInfo
{
Id = s.Id.ToString(),
Title = s.Title,
IsDefault = s.IsDefault
}).ToList();

using (var config = new Config(api))
using (var config = new Config(api))
{
model.ExpandedLevels = config.ManagerExpandedSitemapLevels;
}
Expand Down
13 changes: 6 additions & 7 deletions core/Piranha.Manager/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12040,9 +12040,9 @@ span.CodeMirror-selectedtext {
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*
* https://github.com/piranhacms/piranha.core
*
*
*/
.dd {
position: relative;
Expand Down Expand Up @@ -12091,7 +12091,6 @@ span.CodeMirror-selectedtext {
padding: 4px 0;
}
.dd-item > button {
_display: block;
display: none;
position: relative;
cursor: pointer;
Expand Down Expand Up @@ -12340,7 +12339,7 @@ body.collapsed .navmenu-inverse span.title {
}
.navmenu-inverse {
width: 220px;
border: none 0px;
border: none 0;
}
.navmenu-inverse .navmenu-brand {
text-align: center;
Expand Down Expand Up @@ -13228,7 +13227,7 @@ li.sitemap-item .actions.one {
margin: 0;
}
.custom-editor {
padding: 0px 15px;
padding: 0 15px;
}
.custom-editor .custom-editor-list {
background: #f8f8f8;
Expand Down Expand Up @@ -13375,7 +13374,7 @@ li.sitemap-item .actions.one {
font-weight: 300;
}
#page-blocks [contenteditable]:focus {
outline: 0px solid transparent;
outline: 0 solid transparent;
}
#page-blocks .sortable-placeholder {
padding: 0;
Expand Down Expand Up @@ -13970,7 +13969,7 @@ li.sitemap-item .actions.one {
z-index: 1000000;
position: fixed;
left: 15px;
bottom: 0px;
bottom: 0;
max-width: 500px;
}
.notification-alert {
Expand Down
4 changes: 2 additions & 2 deletions core/Piranha.Manager/assets/css/style.min.css

Large diffs are not rendered by default.

Loading