Monday, June 27, 2016

SharePoint Calculated Columns


SharePoint Calculated Columns are powerful tools when creating out-of-the-box solutions. With these columns, we can manipulate other columns in the list item. Below are a few basic functions complete with details on how to utilize them...

Here is my lookup values, for an corporate environment sample, with some conditional formatting, HTML and CSS:

=IF([Owner]="Press Review",CONCATENATE("<DIV style='color: #ffffff; background-color: #ff0000; padding: 2px 4px !important;'>"," ",Owner," ","</DIV>"),IF([Owner]="Decisions",CONCATENATE("<DIV style='color: #ffffff; background-color: #2C5700; padding: 2px 4px !important;'>"," ",Owner," ","</DIV>"),IF([Owner]="Staff Notices",CONCATENATE("<DIV style='color: #ffffff; background-color: #FF9E00; padding: 2px 4px !important;'>"," ",Owner," ","</DIV>"),IF([Owner]="Job Vacancies",CONCATENATE("<DIV style='color: #ffffff; background-color: #009ECE; padding: 2px 4px !important;'>"," ",Owner," ","</DIV>"),IF([Owner]="Training",CONCATENATE("<DIV style='color: #ffffff; background-color: #CE0000; padding: 2px 4px !important;'>"," ",Owner," ","</DIV>")

Tuesday, June 7, 2016

Dominate creating and manipulating HTML documents


Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. It allows you to write HTML pages in pure Python very concisely, which eliminate the need to learn another template language, and to take advantage of the more powerful features of Python.

Simple Image Gallery

import glob
from dominate import document
from dominate.tags import *

photos = glob.glob('photos/*.jpg')

with document(title='Photos') as doc:
    h1('Photos')
    for path in photos:
        div(img(src=path), _class='photo')

with open('gallery.html', 'w') as f:
    f.write(doc.render())


Result:

<!DOCTYPE html>
<html>
  <head>
    <title>Photos</title>
  </head>
  <body>
    <h1>Photos</h1>
    <div class="photo">
      <img src="photos/IMG_5115.jpg">
    </div>
    <div class="photo">
      <img src="photos/IMG_5117.jpg">
    </div>
  </body>
</html>

in stackoverflow creating html in python