Skip to content

Commit

Permalink
Add support for tab containers
Browse files Browse the repository at this point in the history
Uses https://github.com/pskordilakis/vuepress-tabs.

Related to openhab/website#183.

Update dependencies.

Signed-off-by: Yannick Schaus <github@schaus.net>
  • Loading branch information
ghys committed Aug 3, 2019
1 parent 02448ef commit 25be8ea
Show file tree
Hide file tree
Showing 6 changed files with 2,587 additions and 1,702 deletions.
2 changes: 2 additions & 0 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const DocsSidebarNavigation = require('./docs-sidebar.js')
const fs = require ('fs-extra')
const path = require('path')
// const CopyWebpackPlugin = require('copy-webpack-plugin')
const vuepressTabs = require('vuepress-tabs')

const HighlightDsl = require('./highlight-dsl')
const HighlightRules = require('./highlight-rules')
Expand Down Expand Up @@ -30,6 +31,7 @@ module.exports = {
],
markdown: {
config: (md) => {
vuepressTabs(md)
md.options.linkify = true
const highlight = md.options.highlight
md.options.highlight = (str, lang) => {
Expand Down
10 changes: 10 additions & 0 deletions .vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Tabs from 'vue-tabs-component'

export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
siteData // site metadata
}) => {
Vue.use(Tabs)
}
2 changes: 2 additions & 0 deletions .vuepress/style.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@require '~vuepress-tabs/dist/themes/default.styl'

.navbar:not(.headroom--top):not(.transparent)
box-shadow rgba(10%,10%,10%,25%) 0 0 10px
background-color rgba(98%, 98%, 99%, 0.9) // linear-gradient(180deg,hsla(0,0%,100%,.3),hsla(0,0%,100%,.3) 95%,rgba(0,0,0,.05) 99%,rgba(0,0,0,.04))
Expand Down
104 changes: 104 additions & 0 deletions configuration/jsr223.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,110 @@ Currently, openHAB allows JSR223 scripting to access all packages, which may not
This provides great flexibility for the users of JSR223, but is also *use at your own risk*, since changes outside of the offical APIs occur frequently, and are not considered to be *breaking changes*.
New APIs are planned to be implemented in the future, which will provide standardized interfaces for interacting with openHAB through scripted automation.

## Just testing the tabs

:::: tabs

::: tab Python
```python
from org.slf4j import LoggerFactory

scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleSimple")

class GenericCronTriggerRawAPI(SimpleRule):
def __init__(self):
self.triggers = [
TriggerBuilder.create()
.withId("Hello_World_Cron_Trigger")
.withTypeUID("timer.GenericCronTrigger")
.withConfiguration(
Configuration({
"cronExpression": "0/10 * * * * ?"
})).build(),
TriggerBuilder.create()
.withId("Hello_World_Item_State_Trigger")
.withTypeUID("timer.GenericCronTrigger")
.withConfiguration(
Configuration({
"itemName": "Test_Switch_1"
})).build()
]
self.name = "Jython Hello World (GenericCronTrigger raw API)"
self.description = "This is an example Jython cron rule using the raw API"
self.tags = set("Example rule tag")
self.log = LoggerFactory.getLogger("jsr223.jython.Hello World (GenericCronTrigger raw API)")

def execute(self, module, inputs):
self.log.info("Hello World!")

automationManager.addRule(GenericCronTriggerRawAPI())
```
:::

::: tab JavaScript
```js
'use strict';

scriptExtension.importPreset("RuleSupport");
scriptExtension.importPreset("RuleSimple");

var sRule = new SimpleRule() {
log: Java.type("org.slf4j.LoggerFactory").getLogger("jsr223.javascript.example"),
execute: function( module, inputs) {
this.log.info("Hello World!");
}
};

sRule.setTriggers([
TriggerBuilder.create()
.withId("aTimerTrigger")
.withTypeUID("timer.GenericCronTrigger")
.withConfiguration(
new Configuration({
"cronExpression": "0/10 * * * * ?"
})).build()
]);

sRule.name = "JavaScript Hello World example (raw API)";
sRule.description = "This is an example Hello World rule using the raw API";
automationManager.addRule(sRule);
```
:::

::: tab Groovy
```groovy
import org.slf4j.LoggerFactory
def log = LoggerFactory.getLogger("jsr223.groovy")
import org.openhab.core.automation.Action
import org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRule
import org.eclipse.smarthome.config.core.Configuration
scriptExtension.importPreset("RuleSupport")
def rawAPIRule = new SimpleRule() {
String name = "Groovy Hello World (GenericCronTrigger raw API)"
Object execute(Action module, Map<String, ?> inputs) {
log.info("Hello World!")
}
}
rawAPIRule.setTriggers([
TriggerBuilder.create()
.withId("aTimerTrigger")
.withTypeUID("timer.GenericCronTrigger")
.withConfiguration(new Configuration([cronExpression: "0/10 * * * * ?"]))
.build()
])
automationManager.addRule(rawAPIRule)
```
:::

::::

### Language-Specific Documentation

- [Jython](jsr223-jython.html)
Expand Down
Loading

0 comments on commit 25be8ea

Please sign in to comment.