Create content to automate SSA icons
Look at automating the addition of Icons to content for display within the Self Service Application using REST API or Dashboard or other methods.
Can get an Icon from the content's prefetch statement on windows using: https://github.com/jgstew/tools/blob/master/CSharp/ExtractAssociatedIcon.bat
ToDo:
- [x] Test if SSA will display a .ico format image natively:
data:image/x-icon;base64, - [x] ~~Test if SSA will display an SVG format image~~ (it doesn't, need to file RFE)
- [x] Create Powershell script to convert file to Base64
- [x] Test Relevance to convert file to Base64
- [ ] ~~Figure out easiest way to convert .ico format to PNG~~ (if above doesn't work)
- [x] Get PNG file for SSA from MacOS ICNS file
- [ ] See if the mimefield image can be added from a fixlet description to the fixlet itself
- [ ] See if the mimefield image can be added on action taken to the action itself
- [ ] Create Console Dashboard to:
- [x] display current Icons
- [ ] Add Icons
- [ ] Replace Icons
Examples:
Console Dashboard for SSA Icons:
- https://github.com/jgstew/bigfix-content/blob/master/dashboards/IconsForSSA.ojo
PNG Image MIMEField:
<MIMEField>
<Name>action-ui-metadata</Name>
<Value>{"version":"66.208.49227","size":46641152,"icon":"data:image/png;base64,iVB....CC"}</Value>
</MIMEField>
Fixlet with SSA Icon:
https://github.com/jgstew/bigfix-content/blob/master/fixlet/Open%20Monitor%20Manual%20-%20PG279Q%20-%20Windows.bes
Client Relevance:
-
base64 encode file:
(base64 encodes it) of concatenations of lines of files "setup.exe.ico" - fixlet name & icon:
(values of headers "Subject" of it, ("<img alt='icon' height='64' src='" & it as string & "'>") of values of keys "icon" of jsons of values of headers "action-ui-metadata" of it) of fixlets of sites whose("Custom Site" = type of it) - get Mac App Icon filename:
(it & ".icns") of (preceding text of last ".icns" of it | it) of strings "CFBundleIconFile" of dictionaries of files "Contents/Info.plist" of folders whose(name of it as lowercase ends with ".app") of folders "/Applications" - Get Mac App Icon pathname:
(pathname of folders "Resources" of folders "Contents" of items 0 of it & "/" & item 1 of it) of (it, (it & ".icns") of (preceding text of last ".icns" of it | it) of strings "CFBundleIconFile" of dictionaries of files "Contents/Info.plist" of it) of folders whose(name of it as lowercase ends with ".app") of folders "/Applications" - Get Mac App Name & Icon pathname:
( preceding texts of lasts ".app" of names of it, (pathname of folders "Resources" of folders "Contents" of items 0 of it & "/" & item 1 of it) of (it, (it & ".icns") of (preceding text of last ".icns" of it | it) of strings "CFBundleIconFile" of dictionaries of files "Contents/Info.plist" of it) of it) of folders whose(name of it as lowercase ends with ".app") of folders "/Applications" -
(preceding texts of lasts ".png" of names of it, sizes of it) of files ending in ".png" of folders "/tmp/_BigFix/Icons" -
number of (concatenations of lines of it) of files ending in ".png" of folders "/tmp/_BigFix/Icons" of encodings "ISO-8859-1" - get icon files in Mac .app bundle:
files whose(name of it as lowercase ends with ".icns") of folders "Contents/Resources" of folders whose(name of it as lowercase ends with ".app") of folders "/Applications"
Session Relevance:
- number of fixlets with icons:
number of mime fields "action-ui-metadata" of custom bes fixlets - icon data from fixlets:
values of keys "icon" of jsons of mime fields "action-ui-metadata" of custom bes fixlets - icon HTML from fixlets:
(links of it, ("<img alt='icon' height='64' src='" & it as string & "'>") of values of keys "icon" of jsons of mime fields "action-ui-metadata" of it) of custom bes fixlets - get icons from analysis results:
("<img src='data:image/png;base64," & it & "'>") of unique values of (substrings separated by ";;" of concatenations of values of it) of results of bes properties "base64 of Icons" - fixlets and tasks missing SSA Icons: (consider baselines too?)
number of custom bes fixlets whose( (task flag of it OR fixlet flag of it) AND visible flag of it AND NOT exists mime fields "action-ui-metadata" of it AND exists default action of it)- there isn't session relevance to detect which are offers... need to file RFE for this
- ID Name of fixlets/tasks:
(id of it as string & " " & name of it) of custom bes fixlets whose( (task flag of it OR fixlet flag of it) AND visible flag of it AND NOT exists mime fields "action-ui-metadata" of it AND exists default action of it)
Mac Icon File Info:
Get Magic Literal:
Q: concatenations of (characters it) of (bytes 0 of it; bytes 1 of it; bytes 2 of it; bytes 3 of it) of files "/Applications/App Store.app/Contents/Resources/AppIcon.icns"
A: icns
- https://en.wikipedia.org/wiki/Apple_Icon_Image_format
- Primarily PNG or JPEG 2000 within the file
- "MacOS offers the built-in
iconutilcommand line tool to pack and unpack *.icns files."
- https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/app-icon/
- https://github.com/sveinbjornt/osxiconutils
- https://github.com/jgstew/bigfix-content/blob/master/fixlet/Get%20PNG%20From%20ICNS%20File%20-%20MacOS.bes
- https://www.macworld.com/article/1060156/sipsicns.html
Related:
- https://forum.bigfix.com/t/self-service-app-manually-adding-meta-data/22538
- https://github.com/jgstew/tools/blob/master/CSharp/ExtractAssociatedIcon.bat
- https://css-tricks.com/lodge/svg/09-svg-data-uris/
- https://stackoverflow.com/questions/19369334/is-there-a-way-to-show-bitmap-data-in-html-image-tag
- https://www.aconvert.com/image/ico-to-png/
- https://stackoverflow.com/a/5679084/861745
- http://fa2png.io/r/icomoon-free/file-pdf/?color=007dff&margin=2&size=256
- Take ScreenShot - Windows: https://www.bigfix.me/fixlet/details/21898
- ScreenShot Analysis: https://www.bigfix.me/analysis/details/2998452
- View ScreenShot Dashboard: https://github.com/jgstew/bigfix-content/blob/master/dashboards/Screenshots.ojo
- Escape spaces in pathname: https://bigfix.me/relevance/details/3016285
- https://github.com/sveinbjornt/osxiconutils/issues/5
To get Mac App Icons in BigFix Console:
- Only run this on a few machines: https://github.com/jgstew/bigfix-content/blob/master/fixlet/Get%20PNG%20From%20All%20Applications%20ICNS%20Files%20-%20MacOS.bes
- Import and activate: https://github.com/jgstew/bigfix-content/blob/master/analyses/App%20Icons%20for%20SSA%20-%20Mac.bes
- Load Wizard/add to site: https://github.com/jgstew/bigfix-content/blob/master/dashboards/MacAppIconsForSSA.ojo
ToDo:
- improve the icon harvesting fixlet to get the default icon better, seems to not get the actual default icon within the ICNS file as there can be more than one.
- try the GetIcon binary on the .app bundle itself rather than converting the ICNS file to a PNG.
- Improve the dashboard so an operator to click on an Icon, then pick a fixlet/task to add it to.
- need session relevance to figure out candidate actions that could get Icons
-
names of fixlets whose( ( baseline flag of it OR task flag of it OR fixlet flag of it) AND visible flag of it) of bes custom sites whose(current console user whose(custom content flag of it) is contained by writer set of it)
-
- need session relevance to figure out candidate actions that could get Icons
wow, this built-in command seems to do EXACTLY what I need to get the default icon out of an icns file into PNG format: https://www.macworld.com/article/1060156/sipsicns.html
sips -s format png --resampleHeightWidthMax 128 Calendar.icns --out /tmp/Calendar.icns128.png
I thought I had to use https://github.com/sveinbjornt/osxiconutils but it doesn't get the correct default icon: https://github.com/sveinbjornt/osxiconutils/issues/5
Interesting PDF icon:
https://www.iconpacks.net/free-icon/pdf-download-2617.html
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAH0lEQVQ4T2NkoBAwUqifYdQAhtEwYBgNA1A+Gvi8AAAmmAARf9qcXAAAAABJRU5ErkJggg=="/>