Skip to content

Commit

Permalink
Added Language
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Sep 28, 2020
1 parent d677feb commit b896802
Show file tree
Hide file tree
Showing 72 changed files with 1,720 additions and 19,629 deletions.
1 change: 1 addition & 0 deletions core/Piranha.AttributeBuilder/ContentTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ private ContentType GetContentType(Type type)
Group = group.Id,
UseExcerpt = attr.UseExcerpt,
UsePrimaryImage = attr.UsePrimaryImage,
UseBlocks = typeof(IBlockContent).IsAssignableFrom(type),
UseCategory = typeof(ICategorizedContent).IsAssignableFrom(type),
UseTags = typeof(ITaggedContent).IsAssignableFrom(type),
CustomEditors = GetEditors(type),
Expand Down
86 changes: 86 additions & 0 deletions core/Piranha.Manager/Models/ContentEditModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) .NET Foundation and Contributors
*
* 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;
using System.Collections.Generic;

namespace Piranha.Manager.Models
{
public class ContentEditModel
{
/// <summary>
/// Gets/sets the unique id.
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// Gets/sets the optional language id.
/// </summary>
public Guid? LanguageId { get; set; }

/// <summary>
/// Gets/sets the content type id.
/// </summary>
public string TypeId { get; set; }

/// <summary>
/// Gets/sets the mandatory title.
/// </summary>
public string Title { get; set; }

/// <summary>
/// Gets/sets if blocks should be used.
/// </summary>
public bool UseBlocks { get; set; } = true;

/// <summary>
/// Gets/sets if the content type should be
/// categorized.
/// </summary>
public bool UseCategory { get; set; }

/// <summary>
/// Gets/sets if excerpt should be used for the
/// content type. The default value is true.
/// </summary>
public bool UseExcerpt { get; set; } = true;

/// <summary>
/// Gets/sets if primary image should be used for the
/// content type. The default value is true.
/// </summary>
public bool UsePrimaryImage { get; set; } = true;

/// <summary>
/// Gets/sets if tags should be used for the content type.
/// </summary>
public bool UseTags { get; set; }

/// <summary>
/// Gets/sets if the content should be translatable.
/// </summary>
public bool UseTranslations { get; set; }

/// <summary>
/// Gets/sets the available blocks.
/// </summary>
public IList<Content.BlockModel> Blocks { get; set; } = new List<Content.BlockModel>();

/// <summary>
/// Gets/sets the available regions.
/// </summary>
public IList<Content.RegionModel> Regions { get; set; } = new List<Content.RegionModel>();

/// <summary>
/// Gets/sets the available custom editors.
/// </summary>
public IList<Content.EditorModel> Editors { get; set; } = new List<Content.EditorModel>();
}
}
9 changes: 8 additions & 1 deletion core/Piranha/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public sealed class Api : IApi, IDisposable
/// </summary>
public IContentTypeService ContentTypes { get; }

/// <summary>
/// Gets the language service.
/// </summary>
public ILanguageService Languages { get; }

/// <summary>
/// Gets the media service.
/// </summary>
Expand Down Expand Up @@ -100,6 +105,7 @@ public Api(
IArchiveRepository archiveRepository,
IContentGroupRepository contentGroupRepository,
IContentTypeRepository contentTypeRepository,
ILanguageRepository languageRepository,
IMediaRepository mediaRepository,
IPageRepository pageRepository,
IPageTypeRepository pageTypeRepository,
Expand All @@ -119,13 +125,14 @@ public Api(
// Create services without dependecies
ContentGroups = new ContentGroupService(contentGroupRepository, cache);
ContentTypes = new ContentTypeService(contentTypeRepository, cache);
Languages = new LanguageService(languageRepository, cache);
PageTypes = new PageTypeService(pageTypeRepository, cache);
Params = new ParamService(paramRepository, cache);
PostTypes = new PostTypeService(postTypeRepository, cache);
Sites = new SiteService(siteRepository, contentFactory, cache);
SiteTypes = new SiteTypeService(siteTypeRepository, cache);

// Create services with dependencies
Sites = new SiteService(siteRepository, contentFactory, Languages,cache);
Aliases = new AliasService(aliasRepository, Sites, cache);
Media = new MediaService(mediaRepository, Params, storage, processor, cache);
Pages = new PageService(pageRepository, contentFactory, Sites, Params, Media, cache, search);
Expand Down
5 changes: 5 additions & 0 deletions core/Piranha/IApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public interface IApi : IDisposable
/// </summary>
IContentTypeService ContentTypes { get; }

/// <summary>
/// Gets the language service.
/// </summary>
ILanguageService Languages { get; }

/// <summary>
/// Gets the media service.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions core/Piranha/Models/ContentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public sealed class ContentType : ContentTypeBase
[StringLength(64)]
public string Group { get; set; }

/// <summary>
/// Gets/sets if the content type should support blocks.
/// </summary>
public bool UseBlocks { get; set; }

/// <summary>
/// Gets/sets if the content type should be
/// categorized.
Expand Down
40 changes: 40 additions & 0 deletions core/Piranha/Models/Language.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) .NET Foundation and Contributors
*
* 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;
using System.ComponentModel.DataAnnotations;

namespace Piranha.Models
{
public class Language
{
/// <summary>
/// Gets/sets the unique id.
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// Gets/sets the display title.
/// </summary>
[Required]
[StringLength(64)]
public string Title { get; set; }

/// <summary>
/// Gets/sets the optional culture.
/// </summary>
public string Culture { get; set; }

/// <summary>
/// Gets/sets if this is the default language.
/// </summary>
public bool IsDefault { get; set; }
}
}
5 changes: 5 additions & 0 deletions core/Piranha/Models/Site.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public sealed class Site
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// Gets/sets the language id.
/// </summary>
public Guid LanguageId { get; set; }

/// <summary>
/// Gets/sets the optional site type id.
/// </summary>
Expand Down
52 changes: 52 additions & 0 deletions core/Piranha/Repositories/ILanguageRespository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) .NET Foundation and Contributors
*
* 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;
using System.Collections.Generic;
using System.Threading.Tasks;
using Piranha.Models;

namespace Piranha.Repositories
{
public interface ILanguageRepository
{
/// <summary>
/// Gets all available models.
/// </summary>
/// <returns>The available models</returns>
Task<IEnumerable<Language>> GetAll();

/// <summary>
/// Gets the model with the specified id.
/// </summary>
/// <param name="id">The unique id</param>
/// <returns>The model, or null if it doesn't exist</returns>
Task<Language> GetById(Guid id);

/// <summary>
/// Gets the default side.
/// </summary>
/// <returns>The modell</returns>
Task<Language> GetDefault();

/// <summary>
/// Adds or updates the given model in the database
/// depending on its state.
/// </summary>
/// <param name="model">The model</param>
Task Save(Language model);

/// <summary>
/// Deletes the model with the specified id.
/// </summary>
/// <param name="id">The unique id</param>
Task Delete(Guid id);
}
}
58 changes: 58 additions & 0 deletions core/Piranha/Services/ILanguageService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) .NET Foundation and Contributors
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
* http://github.com/piranhacms/piranha
*
*/

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Piranha.Models;

namespace Piranha.Services
{
public interface ILanguageService
{
/// <summary>
/// Gets all available models.
/// </summary>
/// <returns>The available models</returns>
Task<IEnumerable<Language>> GetAllAsync();

/// <summary>
/// Gets the model with the specified id.
/// </summary>
/// <param name="id">The unique id</param>
/// <returns>The model, or null if it doesn't exist</returns>
Task<Language> GetByIdAsync(Guid id);

/// <summary>
/// Gets the default side.
/// </summary>
/// <returns>The modell</returns>
Task<Language> GetDefaultAsync();

/// <summary>
/// Adds or updates the given model in the database
/// depending on its state.
/// </summary>
/// <param name="model">The model</param>
Task SaveAsync(Language model);

/// <summary>
/// Deletes the model with the specified id.
/// </summary>
/// <param name="id">The unique id</param>
Task DeleteAsync(Guid id);

/// <summary>
/// Deletes the given model.
/// </summary>
/// <param name="model">The model</param>
Task DeleteAsync(Language model);
}
}
Loading

0 comments on commit b896802

Please sign in to comment.