Skip to content

Instantly share code, notes, and snippets.

View damsleth's full-sized avatar
🏡
Locally sourced, home-grown, artisanal automatrons

Carl Joakim Damsleth damsleth

🏡
Locally sourced, home-grown, artisanal automatrons
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Pzl.Skarstind.Core.SkarstindCSS" Location="ScriptLink"
ScriptBlock="document.write('&lt;link rel=&quot;stylesheet&quot; After=&quot;Corev15.css&quot; type=&quot;text/css&quot; href=&quot;~Site/SiteAssets/SkarstindBrandingContent/css/pzl-skarstind.css&quot;&gt;&lt;/' + 'link&gt;');"
Sequence="203">
</CustomAction>
<CustomAction
Id="Pzl.Skarstind.Core.GoogleFontsCSS" Location="ScriptLink"
ScriptBlock="document.write('&lt;link rel=&quot;stylesheet&quot; After=&quot;Corev15.css&quot; type=&quot;text/css&quot; href=&quot;//fonts.googleapis.com/css?family=Lato:300&quot;&gt;&lt;/' + 'link&gt;');"
//CustomAction.xml
<pnp:CustomAction
Name="PromotedActionButton"
Location="ScriptLink"
Sequence="110"
ScriptBlock="SP.SOD.registerSod('PromotedActionButton.js', '/PATH/TO/PromotedActionButton.js?rev'; LoadSodByKey('PromotedActionButton.js');"
Rights="" />
var ctx = SP.ClientContext.get_current();
var userCustomActionsSite = ctx.get_site().get_userCustomActions();
userCustomActionsSite.clear();
ctx.executeQueryAsync();
(function(){
if (typeof jQuery != 'undefined') { return; }
var script = document.createElement('script');
script.src = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function () {
jQuery(document).ready(function() {
init();
});
};
.thread-action-reply-message .ts-reply-message-footer,
body:not(.popover-left-rail) div.ts-left-rail-wrapper {
display: none;
}
.ts-message-list-item,
.ts-message,
thread,
.conversation-common.conversation-start,
.list-wrap.ts-message-list-container,
div#ts-bottom-compose-identifier {
@damsleth
damsleth / SP-REST-Fetch
Created April 21, 2017 13:11
SharePoint Get REST data with Fetch (with logging function)
const getRestData = endpoint =>
fetch(`${_spPageContextInfo.webAbsoluteUrl}/_api/web/${endpoint}`,
{ credentials: "include", headers: { "accept": "application/json;odata=verbose" } })
.then(res => res.json().then(data => {
return data.d.hasOwnProperty("results") ? data.d.results : data.d }))
.catch(err => console.log(err));
const getListItems = listTitle => { return getRestData(`lists/getbytitle('${listTitle}')/items`) };
const logProps = (endpoint, prop) =>
@damsleth
damsleth / brand-personalsites.ps1
Created January 18, 2018 14:31
Branding MySites using PnP Provisioning templates
Param(
[Parameter(Mandatory=$false)]
[string]$SiteUrl = "https://MYSITEHOSTWEBAPP",
[Parameter(Mandatory=$false)]
[string]$TemplateDir = "./template.xml",
[Parameter(Mandatory=$false)]
[string]$BlogTemplateDir = "./blogtemplate.xml"
)
#
# Brand MySites using PnP Provisioning templates
@damsleth
damsleth / New-DevSite.ps1
Last active March 28, 2018 09:25
Provisioning a new dev site with PnP
Param(
[Parameter(Mandatory=$false)]
[string]$RootSite = "https://ROOTSITE",
[Parameter(Mandatory=$false)]
[string]$AdminSite = "https://ADMINSITE",
[Parameter(Mandatory=$false)]
[string]$Owner = "i:0#.w|DOMAIN\OWNER",
[Parameter(Mandatory=$true)]
[string]$Name,
[Parameter(Mandatory=$false)]
@damsleth
damsleth / template.xml
Created January 19, 2018 08:54
semi-generic template.xml with xi:included artifacts
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2016/05/ProvisioningSchema">
<pnp:Preferences>
<pnp:Parameters>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../_Shared/Parameters/GenericContentTypesGroup.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../_Shared/Parameters/GenericFieldsGroup.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../_Shared/Parameters/GenericFieldsPrefix.xml" />
<pnp:Parameter Key="TemplateDisplayName">TEMPLATENAME</pnp:Parameter>
<!-- wipes some ootb stuff from STS#0 -->
<pnp:Parameter Key="PerformCleanup">True</pnp:Parameter>
@damsleth
damsleth / PdfViewer.js
Created March 28, 2018 08:59
SharePoint PDF preview for document library edit- and viewforms.
const PdfPreview = () => {
let _wopiDOM;
async function GetWopiDOM(docUrl = CurrentItemUrl()) {
if (_wopiDOM) { return _wopiDOM } else {
return fetch(`${_spPageContextInfo.siteAbsoluteUrl}/_layouts/15/WopiFrame.aspx?sourcedoc=${encodeURIComponent(docUrl)}`, { credentials: "include" })
.then(res => res.text().then(wopi => new DOMParser().parseFromString(wopi, "text/html")).then(dom => {
_wopiDOM = dom
return _wopiDOM
}))
}