Last active
November 22, 2019 06:44
-
-
Save wpo365/70aefa3202d1f79513446876cd66cb1d to your computer and use it in GitHub Desktop.
Default Handlebars template that can be used (and customized) when surfacing SharePoint Online search results in WordPress using the WPO365 (WordPress + Office 365) plugin (see https://www.wpo365.com/working-with-handlebars-templates/ for details).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<content> | |
<script id="jshelpers"> | |
if (!!window.wpo365 | |
&& 'registerHandlebarsHelper' in window.wpo365 | |
&& 'handlebarsSafeString' in window.wpo365 | |
&& 'moment' in window.wpo365) { | |
window.wpo365.registerHandlebarsHelper('formatSummary', | |
function (summary) { | |
return window.wpo365.handlebarsSafeString( | |
summary | |
.replace(/<c0\>/g, '<strong>') | |
.replace(/<\/c0\>/g, '<strong>') | |
.replace(/<ddd\/>/g, '…')); | |
}); | |
window.wpo365.registerHandlebarsHelper('formatDateTime', function (dateString, formatString) { | |
if (!!dateString && !!formatString) { | |
return window.wpo365.moment(dateString).format(formatString); | |
} | |
return dateString; | |
}); | |
} | |
</script> | |
<header id="header" type="x-handlebars-template"> | |
<style> | |
.pintraItemCell { | |
position: relative; | |
outline: transparent; | |
min-height: 54px; | |
padding: 10px; | |
box-sizing: border-box; | |
display: flex; | |
} | |
.pintraItemCell:hover { | |
background: #eee; | |
} | |
.pintraItemCell::selection { | |
background-color: #bfdcea; | |
} | |
.pintraItemIconWrapper { | |
width: 50px; | |
height: 50px; | |
flex-shrink: 0; | |
} | |
.pintraItemIcon { | |
display: block; | |
width: inherit; | |
height: inherit; | |
text-align: center; | |
} | |
.pintraItemIcon>img { | |
display: inline-block; | |
width: inherit; | |
height: auto; | |
} | |
.pintraItemContent { | |
margin-left: 10px; | |
overflow: hidden; | |
flex-grow: 1; | |
} | |
.pintraItemPrimaryText { | |
font-size: 21px; | |
font-weight: 100; | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} | |
.pintraItemSecondaryText { | |
width: 95%; | |
font-size: 80%; | |
font-weight: 200; | |
} | |
.pintraTertiaryText { | |
font-size: 60%; | |
} | |
.pintraItemMeta { | |
font-size: 50%; | |
font-weight: 100; | |
color: #d3d3d3; | |
box-sizing: border-box; | |
width: calc(100% - 50px); | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} | |
.pintraItemLink, | |
.pintraItemLink:hover, | |
.pintraItemLink:visited { | |
font-size: inherit; | |
color: inherit; | |
text-decoration: underline; | |
} | |
.pintraItemPath { | |
font-size: 60%; | |
font-weight: 200; | |
box-sizing: border-box; | |
width: calc(100% - 50px); | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} | |
.pintraActionButtonGroup { | |
display: flex; | |
display: -webkit-flex; | |
/* Safari */ | |
flex-direction: column; | |
-webkit-flex-direction: column; | |
/* Safari 6.1+ */ | |
} | |
.pintraActionButtonWrapper { | |
-webkit-flex-wrap: wrap; | |
/* Safari 6.1+ */ | |
flex-wrap: wrap; | |
-webkit-flex-grow: 1; | |
flex-grow: 1; | |
-webkit-flex-shrink: 0; | |
flex-shrink: 0; | |
font-size: 12px; | |
line-height: 24px; | |
height: 24px; | |
display: -webkit-flex; | |
/* Safari */ | |
display: flex; | |
cursor: pointer; | |
} | |
.pintraActionButtonIcon { | |
font-size: 12px; | |
line-height: 24px; | |
height: 24px; | |
width: 24px; | |
margin: 0; | |
padding: 0; | |
} | |
.pintraActionButtonLabel { | |
font-size: 12px; | |
line-height: 24px; | |
height: 24px; | |
} | |
</style> | |
</header> | |
<main id="item" type="x-handlebars-template"> | |
<div id="pintraItemCell" class="pintraItemCell"> | |
{{#ifCond typeInfo.type '!=' 'user'}} | |
<div class="pintraItemIconWrapper"> | |
<div class="pintraItemIcon"> | |
{{msIcon ../typeInfo.type}} | |
</div> | |
</div> | |
<div class="pintraItemContent"> | |
<div class="pintraItemPrimaryText"> | |
<a class="pintraItemLink" target="{'_blank'}" href="{{Path}}" target="_blank">{{Title}}</a> | |
</div> | |
<div class="pintraItemPath"> | |
{{#uriSegments ../Path}} | |
<a class="pintraItemLink" target="_blank" href="{{baseUrl}}">[...]</a> | |
{{#each path}} | |
/ <a href="{{../baseUrl}}/{{combineUrl ../path @index ../queryString}}"" target=" _blank">{{this}}</a> | |
{{/each}} | |
{{/uriSegments}} | |
</div> | |
<div class="pintraItemSecondaryText"> | |
{{formatSummary ../HitHighlightedSummary}} | |
</div> | |
<div class="pintraTertiaryText"> | |
</div> | |
<div class="pintraItemMeta"> | |
{{formatDateTime ../LastModifiedTime 'DD/MM/YYYY HH:mm'}} | |
</div> | |
</div> | |
{{/ifCond}} | |
{{#ifCond typeInfo.type '==' 'user'}} | |
<div class="pintraItemIconWrapper"> | |
<div class="pintraItemIcon"> | |
{{avatar ../dataUrl}} | |
</div> | |
</div> | |
<div class="pintraItemContent"> | |
<div class="pintraItemPrimaryText"> | |
<a class="pintraItemLink" target="{'_blank'}" href="{{Path}}" target="_blank">{{../Title}}</a> | |
</div> | |
<div class="pintraItemSecondaryText"> | |
{{../JobTitle}} | |
</div> | |
<div class="pintraTertiaryText"> | |
{{../Department}} | |
</div> | |
<div class="pintraItemMeta"> | |
</div> | |
<div class="pintraActionButtonGroup"> | |
<div class="pintraActionButtonWrapper" onclick="window.open('mailto:{{../WorkEmail}}', '_blank')"> | |
<div class="pintraActionButtonIcon"> | |
{{fabricIcon 'Mail'}} | |
</div> | |
<div class="pintraActionButtonLabel"> | |
{{../WorkEmail}} | |
</div> | |
</div> | |
<div class="pintraActionButtonWrapper" onclick="window.open('sip:{{../UserName}}', '_blank')"> | |
<div class="pintraActionButtonIcon"> | |
{{fabricIcon 'SkypeForBusinessLogo'}} | |
</div> | |
<div class="pintraActionButtonLabel"> | |
{{../UserName}} | |
</div> | |
</div> | |
<div class="pintraActionButtonWrapper" onclick="window.open('tel:{{../MobilePhone}}', '_blank')"> | |
<div class="pintraActionButtonIcon"> | |
{{fabricIcon 'CellPhone'}} | |
</div> | |
<div class="pintraActionButtonLabel"> | |
{{../MobilePhone}} | |
</div> | |
</div> | |
<div class="pintraActionButtonWrapper" onclick="window.open('tel:{{../WorkPhone}}', '_blank')"> | |
<div class="pintraActionButtonIcon"> | |
{{fabricIcon 'Phone'}} | |
</div> | |
<div class="pintraActionButtonLabel"> | |
{{../WorkPhone}} | |
</div> | |
</div> | |
</div> | |
</div> | |
{{/ifCond}} | |
</div> | |
</main> | |
<footer id="footer" type="x-handlebars-template"> | |
<div></div> | |
</footer> | |
</content> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment