Skip to content

Instantly share code, notes, and snippets.

@biapar
biapar / ApiLessController.cs
Last active Jan 24, 2021
Piranha CMS: example of a simple controller to GET data in JSON format for headless use.
View ApiLessController.cs
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 Sep 9, 2020 — forked from ErisDS/examples.md
Ghost Filter Query examples
View examples.md

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 Sep 15, 2020
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)
View JsonController.cs
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 Nov 23, 2018 — forked from warrenbuckley/gist:5685180
Login ActionResult in AuthSurfaceController
View gist:03f3c4b65c823cb47e8877ce9240b66a
/// <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)
{
@biapar
biapar / umbraco-filebrowser.cshtml
Created Apr 11, 2017 — 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)
View umbraco-filebrowser.cshtml
@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) {
@biapar
biapar / gist:2902f4ee8790af18dcd875a0040d8a32
Created Dec 14, 2016
An Umbraco partial view that list the last six post from Articulate blog
View gist:2902f4ee8790af18dcd875a0040d8a32
@inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
@using Articulate;
@using Articulate.Models;
@using Umbraco;
@using Umbraco.Web;
@using Umbraco.Core;
@using Umbraco.Core.Models;
@using System.Linq;
@using System;
@{
@mbdavid
mbdavid / Transaction.cs
Last active May 3, 2020
LiteDB v3 Transaction Syntax Options
View Transaction.cs
// 1
db.BeginTrans();
// ... do stuffs
db.Commit(); // or db.Rollback();
// 2
using(var t = db.BeginTrans()) // where t is LiteTransaction
{
// ... do stuffs
@biapar
biapar / uninstall_vmware.sh
Created Sep 3, 2016 — forked from boneskull/uninstall_vmware.sh
completely uninstall vmware on mac
View uninstall_vmware.sh
#!/usr/bin/env bash
# Usage: bash uninstall_vmware.bash
remove() {
entry="$1"
echo -ne "Removing \e[1;34m$entry\e[0m... "
sudo rm -rf "$entry" &> /tmp/uninstall-vmware.log
if [[ ! -e "$entry" ]]; then
echo -e "\e[1;32mOK\e[0m"
@DavidVeksler
DavidVeksler / ImportController.cs
Created Aug 22, 2016
How FEE digitized and shared 70 years of archives on the Web: an Umbraco case study
View ImportController.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Archive.FEE.Web.Helper.PDFParser;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
@alirobe
alirobe / umbraco-filebrowser.cshtml
Last active Nov 20, 2019
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)
View umbraco-filebrowser.cshtml
@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) {