Skip to content

Instantly share code, notes, and snippets.

View biapar's full-sized avatar
🙂

Biagio Paruolo biapar

🙂
View GitHub Profile
@AaronSadlerUK
AaronSadlerUK / MemberAuthenticationSurfaceController.cs
Last active August 31, 2022 03:05
How to create member login and logout form in Umbraco V9 (RC)
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.Models;
@cleversolutions
cleversolutions / GoogleAuthenticationExtensions.cs
Last active November 4, 2021 10:58
Add Google Authentication to an Umbraco 9 website
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Extensions;
using Umbraco.Cms.Web.BackOffice.Security;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
namespace Umbraco.Cms.Web.UI.NetCore.Configuration
{
public static class GoogleAuthenticationExtensions
{
@biapar
biapar / ApiLessController.cs
Last active September 22, 2022 13:08
Piranha CMS: example of a simple controller to GET data in JSON format for headless use.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Piranha;
using Piranha.AspNetCore.Services;
using Piranha.Models;
using PiranhaCMS.Models;
using Microsoft.AspNetCore.Authorization;
@biapar
biapar / examples.md
Created September 9, 2020 13:54 — forked from ErisDS/examples.md
Ghost Filter Query examples

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

@icavalheiro
icavalheiro / JsonController.cs
Last active August 8, 2021 04:01
Umbraco Json controller based on the ContentType renderer. Use this to return the content as a json instead of a view (great for headless mode)
using Newtonsoft.Json;
using System;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
@biapar
biapar / gist:03f3c4b65c823cb47e8877ce9240b66a
Created November 23, 2018 16:54 — forked from warrenbuckley/gist:5685180
Login ActionResult in AuthSurfaceController
/// <summary>
/// Handles the login form when user posts the form/attempts to login
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult HandleLogin(LoginViewModel model)
{
if (!ModelState.IsValid)
{
@MSerj
MSerj / nFormatter.js
Last active November 16, 2023 09:40
nFormatter (number format with k and m)
function nFormatter(num, digits) {
const si = [
{ value: 1, symbol: "" },
{ value: 1E3, symbol: "k" },
{ value: 1E6, symbol: "M" },
{ value: 1E9, symbol: "G" },
{ value: 1E12, symbol: "T" },
{ value: 1E15, symbol: "P" },
{ value: 1E18, symbol: "E" }
];
public void Configuration(IAppBuilder app)
{
//Configure the Identity user manager for use with Umbraco Back office
// *** EXPERT: There are several overloads of this method that allow you to specify a custom UserStore or even a custom UserManager!
app.ConfigureUserManagerForUmbracoBackOffice(
ApplicationContext.Current,
//The Umbraco membership provider needs to be specified in order to maintain backwards compatibility with the
// user password formats. The membership provider is not used for authentication, if you require custom logic
// to validate the username/password against an external data source you can create create a custom UserManager
@biapar
biapar / umbraco-filebrowser.cshtml
Created April 11, 2017 10:31 — forked from alirobe/umbraco-filebrowser.cshtml
A simple recursive media folder/file viewer macro for directory browsing in #Umbraco 7+, using Bootstrap 3 for display. Not suitable for >100 files (use a surfacecontroller)
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{ var mediaId = Model.MacroParameters["mediaId"]; }
@helper DisplayFolder(dynamic folder, bool collapsed) {
var items = folder.Children().OrderBy("DocumentTypeAlias Desc,Name");
if (items.Any()) {
<a class="list-group-item" role="button" aria-expanded="false" data-toggle="collapse" href="#macro-mediaList-folder-@folder.Id">
<i class="glyphicon glyphicon-folder-open"></i> &nbsp; @folder.Name
</a>
<div class="list-group @(collapsed?"collapse":"collapse in") well well-sm" id="macro-mediaList-folder-@folder.Id">
@foreach(var item in items) {