Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add widget builder #399

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/site/
/marketplace/widgets/*.wgt
/marketplace/texts
/marketplace/temp

25 changes: 25 additions & 0 deletions marketplace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Widget Builder and Listing Generator

Usage:

To create the Docker image:

```console
./widget-builder.sh build
```

```console
./widget-builder.sh fiware
```

```console
./widget-builder.sh fiware
```

```console
./widget-builder.sh fiware
```

```console
./marketplace-listing.sh > widgets.md
```
22 changes: 22 additions & 0 deletions marketplace/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG NODE_VERSION=8.15.0-slim
FROM node:${NODE_VERSION}

ENV DOWNLOAD="latest" \
SOURCE_BRANCH="develop" \
GITHUB_ACCOUNT="wirecloud-fiware" \
GITHUB_REPOSITORY="ngsi-source-operator"

COPY build.sh /opt/widget-builder/build.sh

RUN apt-get update && \
apt-get install -y git unzip python2.7 make build-essential g++ && \
ln -s /usr/bin/python2.7 /usr/bin/python && \
npm install -g bower --silent && \
npm install -g grunt-cli --silent && \
apt-get clean && \
chmod +x /opt/widget-builder/build.sh

VOLUME /opt/widget-builder/output
WORKDIR /opt/widget-builder

CMD ["/opt/widget-builder/build.sh"]
56 changes: 56 additions & 0 deletions marketplace/builder/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash


buildWidget () {
if [ -e package.json ]
then
npm install --silent ;
(npm install [email protected] --save-dev --silent && grunt build) || (npm install grunt --save-dev --silent && node_modules/grunt/bin/grunt build);
if [ -d dist ]; then
cp -r dist/* /opt/widget-builder/output;
elif [ -d build ]; then
cp -r build/* /opt/widget-builder/output;
else
echo "Unknown build dir"
fi
if
}


if [ "${DOWNLOAD}" = "latest" ] ;
then
RELEASE="${SOURCE_BRANCH}";
echo "INFO: Building Latest Development from ${SOURCE_BRANCH} branch.";
elif [ "${DOWNLOAD}" = "stable" ];
then
RELEASE=$(curl -s https://api.github.com/repos/"${GITHUB_ACCOUNT}"/"${GITHUB_REPOSITORY}"/releases/latest | grep 'tag_name' | cut -d\" -f4);
echo "INFO: Building Latest Stable Release: ${RELEASE}";
else
RELEASE="${DOWNLOAD}";
echo "INFO: Building Release: ${RELEASE}";
fi;
RELEASE_CONCAT=$(echo "${RELEASE}" | tr / -);


wget --no-check-certificate -O source.zip https://github.com/"${GITHUB_ACCOUNT}"/"${GITHUB_REPOSITORY}"/archive/"${RELEASE}".zip;
unzip -qq source.zip;
rm source.zip;
cd "${GITHUB_REPOSITORY}-${RELEASE_CONCAT}";

if [ -e package.json ]
then
buildWidget
else
for D in *; do
if [ -d "${D}" ]; then
echo
echo "${D}"
echo
cd "${D}"
buildWidget
cd ..
fi
done
fi


86 changes: 86 additions & 0 deletions marketplace/builder/marketplace.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="no" method="text"/>

<xsl:param name="WIDGET" select="'widget'"/>
<xsl:param name="AGILE_DASHBOARDS_VERSION" select="'v0.3'"/>

<xsl:template match="/*">
<xsl:text>
</xsl:text>
<xsl:text>### </xsl:text>
<xsl:value-of select="details/title"/>
<xsl:text>

</xsl:text>
<xsl:value-of select="details/description"/>

* Vendor: <xsl:value-of select="@vendor"/>
* Version: <xsl:value-of select="@version"/>
* License: <xsl:value-of select="details/license"/>

<xsl:if test="details/homepage != ''" >
<xsl:text>

Homepage: [</xsl:text>
<xsl:value-of select="details/homepage"/>
<xsl:text>](</xsl:text><xsl:value-of select="details/homepage"/>
<xsl:text>)</xsl:text>
<xsl:text>

**[Download </xsl:text>
<xsl:call-template name="replace">
<xsl:with-param name="text" select="substring-after($WIDGET, 'widgets/')"/>
<xsl:with-param name="search" select="'_'"/>
<xsl:with-param name="replace" select="'\_'"/>
</xsl:call-template>](<xsl:value-of select="details/homepage"/>
<xsl:text>/releases/download/</xsl:text>
<xsl:choose>
<xsl:when test="contains(details/homepage, 'agile-dashboards')">
<xsl:value-of select="$AGILE_DASHBOARDS_VERSION"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@version"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring-after($WIDGET, 'widgets/')"/>
<xsl:text>)**</xsl:text>
</xsl:if>


<xsl:text>
</xsl:text>
</xsl:template>


<xsl:template name="replace">
<xsl:param name="text"/>
<xsl:param name="search"/>
<xsl:param name="replace"/>
<xsl:choose>
<xsl:when test="contains($text, $search)">
<xsl:variable name="replace-next">
<xsl:call-template name="replace">
<xsl:with-param name="text" select="substring-after($text, $search)"/>
<xsl:with-param name="search" select="$search"/>
<xsl:with-param name="replace" select="$replace"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of
select="
concat(
substring-before($text, $search)
, $replace
, $replace-next
)
"
/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

27 changes: 27 additions & 0 deletions marketplace/marketplace-listing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
#
# Command Line Interface to start all services associated with the Wirecloud Tutorial
#
# For this tutorial the commands are merely a convenience script to run docker
#

set -e

mkdir -p texts
mkdir -p temp

for D in widgets/*.wgt; do
if [ -f "${D}" ]; then

#echo "${D}"

unzip -qq -o -j "${D}" "config.xml" -d "temp"


sed 's/xmlns=/xxxx=/g' temp/config.xml > temp/config2.xml
xsltproc --stringparam WIDGET "${D}" builder/marketplace.xsl temp/config2.xml

fi
done

# rm -rf temp
137 changes: 137 additions & 0 deletions marketplace/widget-builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/bin/bash
#
# Command Line Interface to start all services associated with the Wirecloud Tutorial
#
# For this tutorial the commands are merely a convenience script to run docker
#

#set -e


buildWidget () {
echo ""
echo "Building" $2 "-" $3
echo ""
# docker run --rm -v "$(pwd)"/widgets:/opt/widget-builder/output -e GITHUB_ACCOUNT=$1 -e GITHUB_REPOSITORY=$2 widget-builder
}

pullWidget () {
echo ""
echo "Pulling" $2 "-" $3
echo ""
# OUTPUT=`curl --silent "https://api.github.com/repos/${1}/${2}/releases/latest?client_id=xxxx&client_secret=yyyy" | grep browser_download_url`

OUTPUT=`curl --silent "https://api.github.com/repos/${1}/${2}/releases/latest" | grep browser_download_url`

X="${OUTPUT:31: $((${#OUTPUT} - 31 - 1))}"

echo $X

curl -LO $X
mv *.wgt widgets
}

agileDashboardWidgets(){
# Wirecloud Widgets
buildWidget Wirecloud agile-dashboards \
"Agile Dashboard Components for WireCloud"
}

wirecloudWidgets(){


pullWidget Wirecloud bae-details-widget \
"Business API Ecosystem details widget for WireCloud"
pullWidget Wirecloud echarts-widget \
"WireCloud widget for ECharts graphs"
pullWidget Wirecloud googlecharts-widget \
"Generic Graph widget for WireCloud using Google Charts"
pullWidget Wirecloud highcharts-widget \
"Generic Graph widget for WireCloud using HighCharts"

pullWidget Wirecloud json-editor-widget \
"JSON editor widget for WireCloud"
pullWidget Wirecloud map-viewer-widget \
"Basic map viewer widget for WireCloud using the Google Maps API"
pullWidget Wirecloud markdown-editor-widget \
"Markdown editor widget for WireCloud"
pullWidget Wirecloud markdown-viewer-widget \
"Markdown viewer widget for WireCloud"
pullWidget Wirecloud ol3-map-widget \
"Map Viewer for WireCloud made using OpenLayers 3"
pullWidget Wirecloud panel-widget \
"WireCloud widget for displaying simple text messages, like sensor measures"
pullWidget Wirecloud spy-wiring-widget \
"WireCloud widget for capturing, editing and replaying wiring events"
pullWidget Wirecloud value-list-filter-operator \
"WireCloud operator to transform lists of objects into lists of values"
pullWidget Wirecloud value-filter-operator \
"Operator that filters a JSON input and outputs part of its data, as addressed in an object-oriented syntax property"
pullWidget Wirecloud workspace-browser-widget \
""
pullWidget wirecloud-fiware ckan2poi-operator \
"A WireCloud operator to process data from CKAN source and convert it to Point of Interest"
pullWidget wirecloud-fiware ckan-source-operator \
"A WireCloud operator to retrieve data from CKAN datasets"
pullWidget wirecloud-fiware context-broker-admin-mashup \
"FIWARE Context Broker Administration panel for WireCloud"
}

fiwareWidgets(){
# Wirecloud FIWARE Widgets
pullWidget wirecloud-fiware ngsi-source-operator \
"WireCloud operator for using Orion Context Broker as data source"
pullWidget wirecloud-fiware ngsi-browser-widget \
"WireCloud widget for browsing the entities of a orion context broker"
pullWidget wirecloud-fiware ngsi-datamodel2poi-operator \
"WireCloud operator for displaying data in a map using the FIWARE data models"
pullWidget wirecloud-fiware ngsi-entity2poi-operator \
"Generic WireCloud operator for converting entities to Points of Interest"
pullWidget wirecloud-fiware ngsi-target-operator \
"WireCloud operator for using Orion Context Broker as data target"
pullWidget wirecloud-fiware ngsi-type-browser-widget \
"WireCloud widget for browsing currently in use entities types inside an orion context broker"
pullWidget wirecloud-fiware ngsi-subscription-browser-widget \
"WireCloud widget for browsing the available subscriptions inside an orion context broker"
}



if (( $# != 1 )); then
echo "Illegal number of parameters";
echo "usage: services [docker|build]";
exit 1;
fi

command="$1"
case "${command}" in
"docker")
docker build -t widget-builder ./builder
;;
"agileDashboard")
# Wirecloud Widgets
agileDashboardWidgets;
;;
"wirecloud")
# Wirecloud Widgets
wirecloudWidgets;
;;
"fiware")
# Wirecloud-FIWARE Widgets
fiwareWidgets;
;;
"build")
echo ""
echo "Building" $3 "-" $4
echo ""
docker run --rm -v "$(pwd)"/widgets:/opt/widget-builder/output -e GITHUB_ACCOUNT=$2 -e GITHUB_REPOSITORY=$3 widget-builder
;;
*)
echo "Command not Found."
echo "usage: services [docker|build]"
exit 127;
;;
esac



Empty file added marketplace/widgets/.gitkeep
Empty file.