diff --git a/luci2/luci2-p910nd/Makefile b/luci2/luci2-p910nd/Makefile new file mode 100644 index 000000000..50aeadceb --- /dev/null +++ b/luci2/luci2-p910nd/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci2-p910nd +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/luci2-p910nd + SECTION:=luci2 + CATEGORY:=LuCI2 + TITLE:=LuCI2 p910nd module + DEPENDS:=luci2 p910nd +endef + +define Package/luci2-p910nd/description + LuCI2 module for p910nd printer daemon management +endef + +define Build/Compile +endef + +define Package/luci2-p910nd/install + $(INSTALL_DIR) $(1)/usr/share/rpcd/menu.d + $(INSTALL_DATA) ./files/usr/share/rpcd/menu.d/services.p910nd.json $(1)/usr/share/rpcd/menu.d/ + + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(INSTALL_DATA) ./files/usr/share/rpcd/acl.d/services.p910nd.json $(1)/usr/share/rpcd/acl.d/ + + $(INSTALL_DIR) $(1)/www/luci2/template + $(INSTALL_DATA) ./files/www/luci2/template/services.p910nd.htm $(1)/www/luci2/template + + $(INSTALL_DIR) $(1)/www/luci2/view + $(INSTALL_DATA) ./files/www/luci2/view/services.p910nd.js $(1)/www/luci2/view +endef + +$(eval $(call BuildPackage,luci2-p910nd)) diff --git a/luci2/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json b/luci2/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json new file mode 100644 index 000000000..dac817843 --- /dev/null +++ b/luci2/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json @@ -0,0 +1,15 @@ +{ + "p910nd": { + "description": "P910ND management", + "read": { + "uci": [ + "p910nd" + ] + }, + "write": { + "uci": [ + "p910nd" + ] + } + } +} \ No newline at end of file diff --git a/luci2/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json b/luci2/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json new file mode 100644 index 000000000..1522e198f --- /dev/null +++ b/luci2/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json @@ -0,0 +1,11 @@ +{ + "services": { + "title": "Services", + "index": 40 + }, + "services/p910nd": { + "title": "p910nd", + "acls": [ "p910nd" ], + "view": "services/p910nd" + } +} \ No newline at end of file diff --git a/luci2/luci2-p910nd/files/www/luci2/template/services.p910nd.htm b/luci2/luci2-p910nd/files/www/luci2/template/services.p910nd.htm new file mode 100644 index 000000000..ad19e7dab --- /dev/null +++ b/luci2/luci2-p910nd/files/www/luci2/template/services.p910nd.htm @@ -0,0 +1 @@ +
diff --git a/luci2/luci2-p910nd/files/www/luci2/view/services.p910nd.js b/luci2/luci2-p910nd/files/www/luci2/view/services.p910nd.js new file mode 100644 index 000000000..d024b24b5 --- /dev/null +++ b/luci2/luci2-p910nd/files/www/luci2/view/services.p910nd.js @@ -0,0 +1,61 @@ +L.ui.view.extend({ + PortValue: L.cbi.InputValue.extend({ + ucivalue: function(sid) + { + var v = this.callSuper('ucivalue', sid); + if (typeof v == 'undefined') + return ''; + + return 9100 + parseInt(v); + }, + + formvalue: function(sid) + { + var v = $('#' + this.id(sid)).val(); + + return parseInt(v) - 9100; + } + }), + + execute: function() { + var self = this; + + var m = new L.cbi.Map('p910nd', { + caption: L.tr('p910nd printer daemon') + }); + + var s = m.section(L.cbi.TypedSection, 'p910nd', { + caption: L.tr('Printers'), + addremove: true, + add_caption: L.tr('Add shared printer …'), + }); + + s.option(L.cbi.CheckboxValue, 'enabled', { + caption: L.tr('Enabled'), + initial: 0, + enabled: '1', + disabled: '0' + }); + + s.option(self.PortValue, 'port', { + caption: L.tr('Port'), + description: L.tr('Specifies the listening port'), + datatype: 'range(9100, 65535)' + }); + + s.option(L.cbi.InputValue, 'device', { + caption: L.tr('Device'), + description: L.tr('Printer device path in the filesystem') + }); + + s.option(L.cbi.CheckboxValue, 'bidirectional', { + caption: L.tr('Bidirectional'), + description: L.tr('Bidirectional copying'), + initial: 1, + enabled: '1', + disabled: '0' + }); + + return m.insertInto('#map'); + } +}); diff --git a/luci2/luci2/Makefile b/luci2/luci2/Makefile new file mode 100644 index 000000000..014077435 --- /dev/null +++ b/luci2/luci2/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2013 Jo-Philipp Wich +# +# Licensed under the Apache License, Version 2.0. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci2 +PKG_VERSION:=$(shell git --git-dir=$(CURDIR)/../.git log -1 --pretty="%ci %h" | awk '{ print $$1 "-" $$4 }') +PKG_MAINTAINER:=Jo-Philipp Wich + +PKG_LICENSE:=Apache-2.0 +PKG_LICENSE_FILES:= + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Build/Prepare + $(INSTALL_DIR) $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +define Package/luci2 + SECTION:=luci2 + CATEGORY:=LuCI2 + TITLE:=LuCI2 UI + DEPENDS:=+rpcd +rpcd-mod-iwinfo +uhttpd +uhttpd-mod-ubus +libubox +libubus +endef + +define Package/luci2/description + Provides the LuCI2 web interface with standard functionality. +endef + +define Package/luci2/install + $(INSTALL_DIR) $(1)/www + $(CP) ./htdocs/* $(1)/www/ + $(INSTALL_DIR) $(1)/usr/share/rpcd + $(CP) ./share/* $(1)/usr/share/rpcd/ + $(INSTALL_DIR) $(1)/usr/lib/rpcd + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rpcd/luci2.so $(1)/usr/lib/rpcd/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rpcd/bwmon.so $(1)/usr/lib/rpcd/ + $(INSTALL_DIR) $(1)/usr/libexec $(1)/www/cgi-bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/io/luci2-io $(1)/usr/libexec/ + $(LN) /usr/libexec/luci2-io $(1)/www/cgi-bin/luci-upload + $(LN) /usr/libexec/luci2-io $(1)/www/cgi-bin/luci-backup +endef + +define Package/luci2/postinst +#!/bin/sh + +if [ "$$(uci -q get uhttpd.main.ubus_prefix)" != "/ubus" ]; then + uci set uhttpd.main.ubus_prefix="/ubus" + uci commit uhttpd +fi + +exit 0 +endef + +$(eval $(call BuildPackage,luci2)) diff --git a/luci2/luci2/htdocs/luci2.html b/luci2/luci2/htdocs/luci2.html new file mode 100644 index 000000000..47c74c7b8 --- /dev/null +++ b/luci2/luci2/htdocs/luci2.html @@ -0,0 +1,59 @@ + + + + LuCI2 + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + diff --git a/luci2/luci2/htdocs/luci2/bootstrap.js b/luci2/luci2/htdocs/luci2/bootstrap.js new file mode 100644 index 000000000..847ab8197 --- /dev/null +++ b/luci2/luci2/htdocs/luci2/bootstrap.js @@ -0,0 +1,1488 @@ +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $('