Skip to content

Instantly share code, notes, and snippets.

View jquintozamora's full-sized avatar

José Quinto jquintozamora

View GitHub Profile
var ctx = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var allprop = ctx.get_web().get_allProperties();
ctx.load(allprop);
ctx.executeQueryAsync(
function ()
{
// Extract the Pages Library GUID from __PagesListId property bag
var pagesListID = allprop.get_item("__PagesListId");
console.log("Pages Library GUID: " + pagesListID);
var ctx = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var web = ctx.get_web();
var webNavSettings = new SP.Publishing.Navigation.WebNavigationSettings(ctx, web);
webNavSettings.set_createFriendlyUrlsForNewPages(0);
webNavSettings.update();
ctx.executeQueryAsync(
function(){
console.log('Create Friendly Urls for New Pages disabled.');
}
// Open current SPWeb: _spPageContextInfo.webServerRelativeUrl
var ctx = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
// Get Documents library
var list = ctx.get_web().get_lists().getByTitle('Documents');
//get_fields() returns SP.FieldCollection object --- contains all SP.Field object properties > https://msdn.microsoft.com/en-us/library/office/jj246815.aspx
var fieldCollection = list.get_fields();
ctx.load(fieldCollection,'Include(InternalName,StaticName)');
//Auxiliary functions to build the icon URL
var pngs = ["doc", "docx", "dot", "dotx", "pdf", "ppt", "pptx", "pub", "xls", "xlsx"];
var gifs = ["asp", "aspx", "bmp", "css", "gif", "htm", "ini", "jpe", "jpeg", "jpg", "js", "log", "png", "tif", "tiff", "txt", "vsd", "vsdx", "xml", "xsl", "xslt"];
var getIconUrl = function (docIcon) {
var returnImageUrl = "/_layouts/15/images/icgen.gif";
var nExt = docIcon;
if (pngs.indexOf(docIcon) >= 0) {
returnImageUrl = "/_layouts/15/images/ic" + docIcon + ".png";
}
else if (gifs.indexOf(docIcon) >= 0) {
{
"name": "CompilerMinifySPSave",
"version": "1.0.0",
"private": true,
"devDependencies": {
"gulp": "3.9.1",
"gulp-autoprefixer": "3.1.0",
"gulp-babel": "6.1.2",
"gulp-concat": "2.6.0",
"gulp-csso": "2.0.0",
{
"name": "JQ.SharePoint.StarterTemplate",
"version": "1.0.0",
"private": true,
"devDependencies": {
"gulp": "3.9.1",
"gulp-autoprefixer": "3.1.0",
"gulp-csso": "2.0.0",
"gulp-less": "3.0.5",
"gulp-load-plugins": "1.2.2",
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MO_Assets" Url="Style Library" RootWebOnly="TRUE">
<!-- Non-themed CSS-->
<File ReplaceContent="TRUE"
Type="GhostableInLibrary"
IgnoreIfAlreadyExists="FALSE"
Level="Published"
Path="MO_Assets\Styles\Output\JQ.MasterPage.min.css"
<?xml version="1.0" encoding="utf-8" ?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema">
<pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.4.1605.0, Culture=neutral, PublicKeyToken=3751622786b357c2" />
<pnp:Templates>
<pnp:ProvisioningTemplate ID="Intranet.SiteCollection" Version="1">
<pnp:Files>
<pnp:File Src=".\DisplayTemplates\Item_QuickLinks.js" Folder="_catalogs/masterpage/Display Templates/Search" Overwrite="true">
<pnp:Properties>
<pnp:Property Key="Title" Value="Item Quick Links" />
<pnp:Property Key="ContentTypeId" Value="0x0101002039C03B61C64EC4A04F5361F38510660500152F27EE7731F042A01234BE4FE60E2E" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AppForSharePointOnlineWebToolkit" version="3.1.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net45" />
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
using OfficeDevPnP.Core.Framework.Provisioning.Connectors;
using OfficeDevPnP.Core.Framework.Provisioning.Model;
using OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers;
using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml;
using System;
using System.IO;
using System.Security;
using System.Threading;