|
From: <j-...@us...> - 2012-02-16 20:13:12
|
Revision: 707
http://openautomation.svn.sourceforge.net/openautomation/?rev=707&view=rev
Author: j-n-k
Date: 2012-02-16 20:13:02 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
Added support for multiple filters: separate filter-tags by commas
Added additional <span> around content in cv-plugin, tag-classes are added to this
(supports coloring of content-only)
Added separation line after each day, grays out older days (thanks netsrac)
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/rsslog/rsslog.css
CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
tools/rsslog/rsslog.php
Modified: CometVisu/trunk/visu/plugins/rsslog/rsslog.css
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/rsslog.css 2012-02-15 18:11:56 UTC (rev 706)
+++ CometVisu/trunk/visu/plugins/rsslog/rsslog.css 2012-02-16 20:13:02 UTC (rev 707)
@@ -38,4 +38,14 @@
.rsslog_ack {
text-decoration: line-through;
+}
+
+.rsslog_separator {
+ border-top-style: dotted;
+ border-color: #DDDDDD;
+}
+
+.rsslog_prevday {
+ opacity: .5;
+ filter: alpha(opacity=50);
}
\ No newline at end of file
Modified: CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js 2012-02-15 18:11:56 UTC (rev 706)
+++ CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js 2012-02-16 20:13:02 UTC (rev 707)
@@ -46,6 +46,7 @@
rss.data("id", id);
rss.data("src", $p.attr("src"));
+ rss.data("filter", $p.attr("filter"));
rss.data("refresh", $p.attr("refresh"));
rss.data("content", $p.attr("content")) || true;
rss.data("datetime", $p.attr("datetime")) || true;
@@ -77,6 +78,7 @@
},
attributes: {
src: {type: "string", required: true},
+ filter: {type: "string", required: false},
width: {type: "string", required: false},
height: {type: "string", required: false},
refresh: {type: "numeric", required: false},
@@ -92,6 +94,14 @@
var rss = $(rss);
var src = rss.data("src");
+ var filter = rss.data("filter");
+ if (filter) {
+ if (src.match(/\?/)) {
+ src += '&f=' + filter;
+ } else {
+ src += '?f=' + filter;
+ }
+ }
var refresh = rss.data("refresh");
var limit = rss.data("limit");
@@ -123,7 +133,7 @@
var defaults = {
src: '',
- html: '{text}',
+ html: '<span>{text}</span>',
wrapper: 'li',
dataType: 'xml',
datetime: true
@@ -183,6 +193,10 @@
var last = itemoffset+displayrows;
last = (last>itemnum) ? itemnum : last;
+ var separatordate = new Date().strftime('%d');
+ var separatoradd = false;
+ var separatorprevday = false;
+
for (var i=itemoffset; i<last; i++) {
var idx = i;
idx = (i>=itemnum) ? (idx = idx - itemnum) : idx;
@@ -196,19 +210,29 @@
itemHtml = (o.timeformat) ?
(itemHtml.replace(/{date}/, entryDate.strftime(o.timeformat) + ' ')) :
(itemHtml.replace(/{date}/, entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString() + ' '));
+ var thisday = entryDate.strftime('%d');
+ separatoradd = ((separatordate > 0) && (separatordate != thisday));
+ separatordate = thisday;
} else {
itemHtml = itemHtml.replace(/{date}/, '');
}
var $row = $('<' + o.wrapper + ' class="rsslogRow ' + row + '">').append(itemHtml);
-
+ if (separatoradd) {
+ $row.addClass('rsslog_separator'); separatorprevday = true;
+ }
+ if (separatorprevday == true) {
+ $row.addClass(' rsslog_prevday');
+ }
+
var title = item.find('title').text();
var itemClasses = title.substring(title.search(/\[/)+1,title.search(/\]/)).replace(/\,/g, ' ');
if (itemClasses) {
- $row.addClass(itemClasses);
+ $('span', $row).addClass(itemClasses);
var id = itemClasses.match(/id=[0-9]*/)[0].split('=')[1];
$row.data('id', id);
}
+
if (o.itemack) {
$row.bind("click", function() {
var item = $(this);
Modified: tools/rsslog/rsslog.php
===================================================================
--- tools/rsslog/rsslog.php 2012-02-15 18:11:56 UTC (rev 706)
+++ tools/rsslog/rsslog.php 2012-02-16 20:13:02 UTC (rev 707)
@@ -216,9 +216,13 @@
// return a handle to all the data
function retrieve( $db, $filter, $state )
{
-// $q = "SELECT content, strftime('%s', t, 'localtime') AS t FROM Logs";
- $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs " .
- "WHERE tags LIKE '%" . sqlite_escape_string($filter) . "%' ";
+ $filters = explode(',', $filter); // accept filters by separated by ,
+ foreach ($filters as $i => $val) {
+ $filters[$i] = " (tags LIKE '%" . sqlite_escape_string($val) . "%') ";
+ }
+
+ $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs WHERE" . implode('OR', $filters);;
+
if (isset($state))
$q .= " AND state=" . $state . " ";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-04 21:45:47
|
Revision: 721
http://openautomation.svn.sourceforge.net/openautomation/?rev=721&view=rev
Author: mayerch
Date: 2012-03-04 21:45:41 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
New feature: 3d pages!!!
This is still more of a quick hack for a proof of concept than a solid integration - but it'll be the base for it.
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/index.html
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Property Changed:
----------------
CometVisu/trunk/visu/
Property changes on: CometVisu/trunk/visu
___________________________________________________________________
Added: svn:externals
+ lib/jsfloorplan.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/src/jsfloorplan.js
lib/Three.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/lib/Three.js
lib/poly2tri.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/lib/poly2tri.js
media/demo_texture_512x512.png https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/media/demo_texture_512x512.png
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-04 21:45:41 UTC (rev 721)
@@ -171,6 +171,19 @@
if( '2d' == type )
{
container.append( '<embed src="' + backdrop + '" style="position: absolute; top: 0px; left: 0px;z-index:-1;width:100%;height:100%;"/>' );
+ } else if( '3d' == type )
+ {
+ container.data( 'JSFloorPlan3D', JSFloorPlan3D( container, backdrop ) );
+ if ($p.attr('azimut')) {
+ ga_list.push($p.attr('azimut'));
+ address[ '_' + $p.attr('azimut') ] = [ 'DPT:5.001', 0, 'azimut' ];
+ container.bind( '_' + $p.attr('azimut'), this.update );
+ }
+ if ($p.attr('elevation')) {
+ ga_list.push($p.attr('elevation'));
+ address[ '_' + $p.attr('elevation') ] = [ 'DPT:5.001', 0, 'elevation' ];
+ container.bind( '_' + $p.attr('elevation'), this.update );
+ }; container.data( 'address', address );
}
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
@@ -190,14 +203,31 @@
type: { type: 'string', required: false },
colspan: { type: 'numeric', required: false },
rowspan: { type: 'numeric', required: false },
- backdrop: { type: 'string', required: false }
+ backdrop: { type: 'string', required: false },
+ azimut: { type: 'addr', required: false },
+ elevation:{ type: 'addr', required: false }
},
elements: {
},
update: function(e, data) {
- if (data==01) {
- scrollToPage(this.attributes.path.nodeValue);
- visu.write(e.type.substr(1), transformEncode("DPT:1.001", 0));
+ var element = $(this);
+ var value = defaultUpdate( e, data, element );
+ var type = element.data().address[ e.type ][2];
+ switch( type )
+ {
+ case 'azimut':
+ element.data().JSFloorPlan3D.setState('currentAzimut', value, true);
+ break;
+
+ case 'elevation':
+ element.data().JSFloorPlan3D.setState('currentElevation', value, true);
+ break;
+
+ default:
+ if (data==01) {
+ scrollToPage(this.attributes.path.nodeValue);
+ visu.write(e.type.substr(1), transformEncode("DPT:1.001", 0));
+ }
}
},
content: true
Modified: CometVisu/trunk/visu/index.html
===================================================================
--- CometVisu/trunk/visu/index.html 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/index.html 2012-03-04 21:45:41 UTC (rev 721)
@@ -22,6 +22,9 @@
<script src="lib/templateengine.js" type="text/javascript"></script>
<script src="transforms/transform_default.js" type="text/javascript"></script>
<script src="transforms/transform_knx.js" type="text/javascript"></script>
+ <script src="lib/Three.js" type="text/javascript"></script>
+ <script src="lib/poly2tri.js" type="text/javascript"></script>
+ <script src="lib/jsfloorplan.js" type="text/javascript"></script>
<style type="text/css">
.loading { display: none; }
</style>
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-04 21:45:41 UTC (rev 721)
@@ -78,8 +78,17 @@
<address transform="DPT:5.001" type="">12/7/52</address>
</info>
</page>
- <page name="3D Demo" >
- <text>not avialable at the moment...</text>
+ <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54">
+ <slide min="0" max="6.283185307179586">
+ <layout x="0px" y="570px" width="600px" />
+ <label>Azimut</label>
+ <address transform="DPT:5.001" type="">12/7/53</address>
+ </slide>
+ <slide min="0" max="1.5707963267948966">
+ <layout x="400px" y="570px" width="600px" />
+ <label>Elevation</label>
+ <address transform="DPT:5.001" type="">12/7/54</address>
+ </slide>
</page>
<line/>
</page>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 19:55:57 UTC (rev 720)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 21:45:41 UTC (rev 721)
@@ -165,10 +165,12 @@
var self = this;
+ /*
if (typeof floorPlan === "string")
{
this.loadFloorPlan( floorPlan );
}
+ */
// public variables of this object instance
this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
@@ -205,7 +207,7 @@
lightStrength: 80,
lightDistance: 50,
fillOpacity: 1, // solid
- fillColor: new THREE.Color(0x000000), // black
+ fillColor: new THREE.Color(0xffffff), // white
showNodes: false, // only for debug purposes
showWallLines: false, // only for debug purposes
showWireframe: false, //
@@ -1135,8 +1137,8 @@
var sx = Math.sin(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
var sy = Math.cos(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
var sz = Math.sin(showStates.lightElevation);
- sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + target.z );
+ sunLight.target.position = showStates.currentTarget;
+ sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + showStates.currentTarget.z );
sunLight.intensity = showStates.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
@@ -1397,6 +1399,10 @@
if( event.data.callback ) event.data.callback( event );
}
+ if (typeof floorPlan === "string")
+ {
+ this.loadFloorPlan( floorPlan );
+ }
};
// library local variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-11 16:34:40
|
Revision: 725
http://openautomation.svn.sourceforge.net/openautomation/?rev=725&view=rev
Author: mayerch
Date: 2012-03-11 16:34:34 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
CometVisu:
- Added <layout> to trigger
- made 3D use full space
- added GA to switch floors (also temporary as well as azimut and elevation)
- removed a few timeouts that seemed unnecessary
JSFloorPlan3D:
- added ability to resize canvas
- improved moveToRoom
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,11 @@
container.append( '<embed src="' + backdrop + '" style="position: absolute; top: 0px; left: 0px;z-index:-1;width:100%;height:100%;"/>' );
} else if( '3d' == type )
{
- container.data( 'JSFloorPlan3D', JSFloorPlan3D( container, backdrop ) );
+ var floorplan = JSFloorPlan3D( container, backdrop );
+ floorplan.moveToRoom( 'Underground', false, true, false );
+ container.data( 'JSFloorPlan3D', floorplan );
+ container.find('canvas').css({position: 'absolute', top: '0px', left: '0px', 'z-index':'-1', width:'100%',height:'100%'});
+ $(window).bind( 'resize', function(){ floorplan.resize($('.page').width(), $('.page').height(), true);} );
if ($p.attr('azimut')) {
ga_list.push($p.attr('azimut'));
address[ '_' + $p.attr('azimut') ] = [ 'DPT:5.001', 0, 'azimut' ];
@@ -183,7 +187,13 @@
ga_list.push($p.attr('elevation'));
address[ '_' + $p.attr('elevation') ] = [ 'DPT:5.001', 0, 'elevation' ];
container.bind( '_' + $p.attr('elevation'), this.update );
- }; container.data( 'address', address );
+ };
+ if ($p.attr('floor')) {
+ ga_list.push($p.attr('floor'));
+ address[ '_' + $p.attr('floor') ] = [ 'DPT:5.004', 0, 'floor' ];
+ container.bind( '_' + $p.attr('floor'), this.update );
+ };
+ container.data( 'address', address );
}
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
@@ -205,13 +215,14 @@
rowspan: { type: 'numeric', required: false },
backdrop: { type: 'string', required: false },
azimut: { type: 'addr', required: false },
- elevation:{ type: 'addr', required: false }
+ elevation:{ type: 'addr', required: false },
+ floor: { type: 'addr', required: false }
},
elements: {
},
update: function(e, data) {
var element = $(this);
- var value = defaultUpdate( e, data, element );
+ var value = defaultValueHandling( e, data, element );
var type = element.data().address[ e.type ][2];
switch( type )
{
@@ -223,6 +234,10 @@
element.data().JSFloorPlan3D.setState('currentElevation', value, true);
break;
+ case 'floor':
+ element.data().JSFloorPlan3D.moveToRoom( value, false, true, true );
+ break;
+
default:
if (data==01) {
scrollToPage(this.attributes.path.nodeValue);
@@ -745,8 +760,10 @@
this.addCreator('trigger', {
create: function( page, path ) {
var $p = $(page);
+ var layout = $p.find('layout')[0];
+ var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
var value = $p.attr('value') ? $p.attr('value') : 0;
- var ret_val = $('<div class="widget clearfix switch" />');
+ var ret_val = $('<div class="widget clearfix switch" ' + style + ' />');
ret_val.setWidgetLayout($p);
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
@@ -794,7 +811,8 @@
},
elements: {
label: { type: 'string', required: true, multi: false },
- address: { type: 'address', required: true, multi: true }
+ address: { type: 'address', required: true, multi: true },
+ layout: { type: 'layout', required: false, multi: false }
},
content: false
});
@@ -1237,17 +1255,12 @@
return { x: 0, y: 0 }; // sanity return
}
-function defaultUpdate( e, data, passedElement )
+function defaultValueHandling( e, data, passedElement )
{
var element = passedElement || $(this);
var thisTransform = element.data().address[ e.type ][0];
var value = transformDecode( element.data().address[ e.type ][0], data );
-
- element.setWidgetStyling(value);
- if( element.data( 'align' ) )
- element.addClass(element.data( 'align' ) );
-
element.data( 'basicvalue', value );
if( element.data( 'precision' ) )
value = Number( value ).toPrecision( element.data( 'precision' ) );
@@ -1267,6 +1280,20 @@
break;
}
}
+ return value;
+}
+
+function defaultUpdate( e, data, passedElement )
+{
+// var value = defaultValueHandling( e, data, passedElement )
+ var element = passedElement || $(this);
+ var value = defaultValueHandling( e, data, element );
+
+ element.setWidgetStyling( element.data( 'basicvalue' ) );
+
+ if( element.data( 'align' ) )
+ element.addClass(element.data( 'align' ) );
+
element.find('.value').text( value );
return value;
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -74,7 +74,7 @@
$(document).ready(function() {
// get the data once the page was loaded
$.ajaxSetup({cache: !forceReload});
- window.setTimeout("$.get( 'visu_config" + configSuffix + ".xml', parseXML );", 200);
+ $.get( 'visu_config' + configSuffix + '.xml', parseXML );
} );
$(window).unload(function() {
@@ -276,13 +276,9 @@
$('.footer').html( $('.footer').html() + text );
});
- // adapt width for pages to show
- handleResize();
-
if (pluginsToLoad <= 0) {
setup_page(xml);
}
-
}
function setup_page( xml )
@@ -291,7 +287,6 @@
var page = $( 'pages > page', xml )[0]; // only one page element allowed...
$('head').append(($('<div class="colspandefault" id="colspandefault">')));
- setTimeout(function() {
$('head').data('colspanDefault', parseInt($('#colspandefault').css('width')));
$('#colspandefault').remove();
@@ -342,8 +337,8 @@
}
visu.subscribe( ga_list );
+ $(window).trigger('resize');
$("#pages").triggerHandler("done");
- }, 1);
}
function create_pages( page, path, flavour ) {
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-11 16:34:34 UTC (rev 725)
@@ -78,7 +78,7 @@
<address transform="DPT:5.001" type="">12/7/52</address>
</info>
</page>
- <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54">
+ <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54" floor="12/7/51">
<slide min="0" max="6.283185307179586">
<layout x="0px" y="570px" width="600px" />
<label>Azimut</label>
@@ -89,6 +89,16 @@
<label>Elevation</label>
<address transform="DPT:5.001" type="">12/7/54</address>
</slide>
+ <trigger value="0">
+ <layout x="0px" y="150px" width="600px" />
+ <label>Underground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
+ <trigger value="1">
+ <layout x="0px" y="100px" width="600px" />
+ <label>Ground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
</page>
<line/>
</page>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-07 22:55:34 UTC (rev 724)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,7 @@
*/
// public variables of this object instance
- this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+ this.buildingProperties = { floor: [], Object3D: new THREE.Object3D(), floorNames:{} };
// private variables of this object instance will follow
@@ -384,6 +384,7 @@
var floorName = floor.getAttribute('name');
self.buildingProperties.floor[floorCount].name = floorName;
+ self.buildingProperties.floorNames[floorName] = floorCount;
var floorheight = Number( floor.getAttribute('height') );
self.buildingProperties.floor[floorCount].height = floorheight;
@@ -1098,6 +1099,31 @@
return showStates[ property ];
}
+ /**
+ * Resize the canvas. This might be done explicit by passing a width and
+ * height. Or implicit by passing no parameter or just the redraw parameter.
+ */
+ this.resize = function( width, height, redraw )
+ {
+ if( arguments.length === 2 || arguments.length === 3 )
+ {
+ WIDTH = width;
+ HEIGHT = height;
+ } else {
+ WIDTH = container.find('canvas').width();
+ HEIGHT = container.find('canvas').height();
+ redraw = width; // the first and only parameter is now the "redraw"
+ }
+ ASPECT = WIDTH / HEIGHT;
+ renderer.setSize(WIDTH, HEIGHT);
+ camera.aspect = ASPECT;
+
+ if( redraw ) // is set and true
+ {
+ update3D();
+ }
+ }
+
this.hideFloor = function( floorNr, doShow )
{
THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
@@ -1178,13 +1204,14 @@
* is taken from the parameter <code>floor</code>
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
+ * @param {Bool} animate Animate unless set to false
*/
- this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn, animate )
{
if( noSetup ) setup3D( this.buildingProperties.Object3D );
// speed of the changing
- var steps = 100;
+ var steps = (animate == undefined || !animate) ? 1 : 100;
var rate = { azimut: 0.0, elevation: 0.0, distance: 0.0, target: new THREE.Vector3 };
function calcRate()
@@ -1271,10 +1298,14 @@
/**
* @method moveToRoom
*/
- this.moveToRoom = function( floor, room )
+ this.moveToRoom = function( floor, room, hideOtherFloors, animate )
{
var target = new THREE.Vector3();
var dist;
+ if( typeof floor === 'string' )
+ {
+ floor = this.buildingProperties.floorNames[floor];
+ }
if( room ) // use room if defined
{
target.x = room.center.x;
@@ -1287,7 +1318,25 @@
}
target.z = this.buildingProperties.floor[ floor ].heightOfGround +
this.buildingProperties.floor[ floor ].height / 2;
- this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target );
+ if( hideOtherFloors )
+ {
+ // show relevant floors
+ var minFloor = floor < showStates.showFloor ? floor : showStates.showFloor;
+ var maxFloor = floor < showStates.showFloor ? showStates.showFloor : floor;
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, minFloor <= f && f <= maxFloor );
+ }
+ this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target,
+ function(){
+ if( hideOtherFloors )
+ {
+ // hide all except target floors
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, f == floor );
+ }
+ self.render();
+ }, animate );
+ showStates.showFloor = floor;
return target;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-17 23:39:03
|
Revision: 729
http://openautomation.svn.sourceforge.net/openautomation/?rev=729&view=rev
Author: mayerch
Date: 2012-03-17 23:38:56 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
Add initial support for widgets in 3d space (currently: only the info widget)
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -196,7 +196,7 @@
container.data( 'address', address );
}
$( childs ).each( function(i){
- container.append( create_pages( childs[i], path + '_' + i, flavour ) );
+ container.append( create_pages( childs[i], path + '_' + i, flavour, type ) );
} );
var subpage = $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' );
subpage.append(container);
@@ -228,14 +228,18 @@
{
case 'azimut':
element.data().JSFloorPlan3D.setState('currentAzimut', value, true);
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
break;
case 'elevation':
element.data().JSFloorPlan3D.setState('currentElevation', value, true);
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
break;
case 'floor':
- element.data().JSFloorPlan3D.moveToRoom( value, false, true, true );
+ element.data().JSFloorPlan3D.moveToRoom( value, false, true, true, function(){
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
+ });
break;
default:
@@ -346,26 +350,30 @@
});
this.addCreator('info', {
- create: function( page, path ) {
- var $p = $(page);
- var layout = $p.find('layout')[0];
+ create: function( element, path, flavour, type ) {
+ var $e = $(element);
+ var layout = $e.find('layout')[0];
var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
var ret_val = $('<div class="widget clearfix info" ' + style + ' />');
- ret_val.setWidgetLayout($p).makeWidgetLabel($p);
- var address = makeAddressList($p);
+ //type == '3d' && ret_val.data( extractLayout3d( layout ) ).bind( 'update3d', this.update3d );
+ type == '3d' && $(document).bind( 'update3d', {element: ret_val, layout: extractLayout3d( layout )}, this.update3d );
+ ret_val.setWidgetLayout($e).makeWidgetLabel($e);
+ var address = makeAddressList($e);
+
var actor = '<div class="actor"><div class="value">-</div></div>';
var $actor = $(actor).data({
'address' : address,
- 'format' : $p.attr('format'),
- 'mapping' : $p.attr('mapping'),
- 'styling' : $p.attr('styling')
+ 'format' : $e.attr('format'),
+ 'mapping' : $e.attr('mapping'),
+ 'styling' : $e.attr('styling')
});
for( var addr in address ) $actor.bind( addr, this.update );
ret_val.append( $actor );
return ret_val;
},
update: defaultUpdate,
+ update3d: defaultUpdate3d,
attributes: {
format: { type: 'format', required: false },
mapping: { type: 'mapping', required: false },
@@ -1400,6 +1408,16 @@
return value;
}
+function defaultUpdate3d( e, data, passedElement )
+{
+ //var element = passedElement || $(this);
+ var l = e.data.layout;
+ var pos = data.building2screen( new THREE.Vector3( l.x, l.y, l.z ) );
+ e.data.element.css( 'left', pos.x + 'px' );
+ e.data.element.css( 'top' , pos.y + 'px' );
+ //console.log( e, data, e.data, pos.x, pos.y );
+}
+
function extractLayout( layout )
{
var ret_val = 'position:absolute;';
@@ -1409,3 +1427,12 @@
return ret_val;
}
+function extractLayout3d( layout )
+{
+ var ret_val = {};
+ if( layout.getAttribute('x' ) ) ret_val.x = layout.getAttribute('x' );
+ if( layout.getAttribute('y' ) ) ret_val.y = layout.getAttribute('y' );
+ if( layout.getAttribute('z' ) ) ret_val.z = layout.getAttribute('z' );
+ if( layout.getAttribute('floor') ) ret_val.floor = layout.getAttribute('floor');
+ return ret_val;
+}
\ No newline at end of file
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -341,10 +341,10 @@
$("#pages").triggerHandler("done");
}
-function create_pages( page, path, flavour ) {
+function create_pages( page, path, flavour, type ) {
var creator = design.getCreator(page.nodeName);
- var retval = creator.create(page, path, flavour);
+ var retval = creator.create(page, path, flavour, type);
node = $(page).get(0);
var attributes = {};
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-17 23:38:56 UTC (rev 729)
@@ -79,6 +79,10 @@
</info>
</page>
<page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54" floor="12/7/51">
+ <info format="%.2f">
+ <layout x="3.5" y="3.7" z="1.0"/>
+ <address transform="DPT:5.001" type="">12/7/53</address>
+ </info>
<slide min="0" max="6.283185307179586">
<layout x="0px" y="570px" width="600px" />
<label>Azimut</label>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 21:52:15 UTC (rev 728)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -1351,7 +1351,7 @@
* @param {Room} room
* @return {THREE.Vector3} Target
*/
- this.moveToRoom = function( floor, room, hideOtherFloors, animate )
+ this.moveToRoom = function( floor, room, hideOtherFloors, animate, callback )
{
var target = new THREE.Vector3();
var dist;
@@ -1391,6 +1391,7 @@
for( ; f >= 0; f-- ) self.hideFloor( f, f == floor );
}
self.render();
+ if( callback !== undefined ) callback();
}, animate );
showStates.showFloor = floor;
return target;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-12-08 16:28:49
|
Revision: 1191
http://openautomation.svn.sourceforge.net/openautomation/?rev=1191&view=rev
Author: makki1
Date: 2012-12-08 16:28:41 +0000 (Sat, 08 Dec 2012)
Log Message:
-----------
Move rsslog from tools to CometVisu-Plugin - preparation for other changes to rsslog
Added Paths:
-----------
CometVisu/trunk/visu/plugins/rsslog/rsslog.php
CometVisu/trunk/visu/plugins/rsslog/rsslog_correct.pl
Removed Paths:
-------------
tools/rsslog/rsslog.php
tools/rsslog/rsslog_correct.pl
Copied: CometVisu/trunk/visu/plugins/rsslog/rsslog.php (from rev 1190, tools/rsslog/rsslog.php)
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/rsslog.php (rev 0)
+++ CometVisu/trunk/visu/plugins/rsslog/rsslog.php 2012-12-08 16:28:41 UTC (rev 1191)
@@ -0,0 +1,252 @@
+<?php
+/*****************************************************************************/
+/* rsslog.php - A simple log message reciever and sender via RSS */
+/* */
+/* (c) 2011 by Christian Mayer */
+/* Licenced under the GPLv3 */
+/*****************************************************************************/
+
+// There are diffentent modes of operation
+// 1. Creating a new log line:
+// URL parameter "c": the content of the log
+// URL parameter "t[]": a tag for later filtering. Multiple might be given
+// URL parameter "h": a header(title) for the entry; maybe empty
+// 2. Receive the log as RSS:
+// URL parameter "f": The (optional) filter, only log lines with a tag
+// that fit this string are sent
+// URL parameter "state": get only rows with state=value
+// 3. Dump all the content in a HTML page:
+// URL parameter "dump" - no value needed
+// 4. Remove old content:
+// URL parameter "r": the timestamp (seconds since 1970) of the oldest log
+// line to keep
+// 5. Get content as JSON:
+// URL parameter "j"
+// 6. Update state:
+// URL parameter "u" id of row
+// URL parameter "state": new state
+
+
+// look where to store DB
+if (is_dir('/etc/wiregate/rss'))
+ $dbfile = '/etc/wiregate/rss/rsslog.db';
+else
+ $dbfile = 'rsslog.db';
+
+//check if the DIRECTORY is writeable by the webserver
+$dbfile_dir = dirname($dbfile);
+if (! is_writable($dbfile_dir))
+ die ("Database $dbfile not writeable! make sure the file AND " .
+ "the directory are writeable by the webserver!");
+
+// create database connection
+$db = sqlite_open($dbfile, 0666, $error);
+if (!$db) die ($error);
+
+// create table if it doesn't exists
+create( $db );
+
+if( isset($_GET['c']) )
+{
+ // store a new log
+ $store = true;
+ $log_content = $_GET['c'] ? $_GET['c'] : '<no content>';
+ $log_title = $_GET['h'] ? $_GET['h'] : '';
+ if( mb_detect_encoding($log_content, 'UTF-8', true) != 'UTF-8' )
+ $log_content = utf8_encode($log_content);
+ if( mb_detect_encoding($log_title, 'UTF-8', true) != 'UTF-8' )
+ $log_title = utf8_encode($log_title);
+ $log_tags = $_GET['t'] ? $_GET['t'] : array();
+ if(! is_array($log_tags))
+ die("wrong format - use one or more t[]= for tags");
+ insert( $db, $log_content, $log_title, $log_tags );
+} else if( isset($_GET['dump']) )
+{
+ $result = retrieve( $db, $log_filter, '' );
+ ?>
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head><body>
+<table border="1">
+ <?php
+ while( sqlite_has_more($result) )
+ {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC );
+ echo '<tr>';
+ echo '<td>' . $row['id'] . '</td>';
+ echo '<td>' . date( DATE_ATOM, $row['t'] ) . '</td>';
+ echo '<td>' . $row['t'] . '</td>';
+ echo '<td>' . $row['title'] . '</td>';
+ echo '<td>' . $row['content'] . '</td>';
+ echo '<td>' . $row['tags'] . '</td>';
+ echo '<td>' . $row['state'] . '</td>';
+ echo "</tr>\n";
+ }
+ ?>
+</table>
+</body></html>
+ <?php
+} else if( isset($_GET['r']) )
+{
+ $timestamp = $_GET['r'] ? $_GET['r'] : '';
+ delete( $db, $timestamp );
+} else if( isset($_GET['j']) )
+{
+ ?>
+{
+ "responseData" : {
+ "feed" : {
+ "feedUrl": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
+ "title": "RSS supplied logs",
+ "link": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
+ "author": "",
+ "description": "RSS supplied logs",
+ "type": "rss20",
+ "entries": [
+<?php
+ $result = retrieve( $db, $log_filter, '' );
+ $first = true;
+ while( sqlite_has_more($result) )
+ {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC );
+ if( !$first ) echo ",\n";
+ echo '{';
+ echo '"title": "' . $row['title'] . '",';
+ echo '"content": "' . $row['content'] . '",';
+ echo '"publishedDate": "' . date( DATE_ATOM, $row['t'] ) . '"';
+ echo '}';
+ $first = false;
+ }
+?>
+ ]
+ }
+ },
+ "responseDetails" : null,
+ "responseStatus" : 200
+}
+<?php
+} else if ( isset($_GET['u']) ) {
+ $id = $_GET['u'];
+ if (!is_numeric($id))
+ die("wrong format - id has to be numeric");
+ $newstate = $_GET['state'];
+ if (!is_numeric($newstate))
+ die("wrong format - state is required and has to be numeric");
+ updatestate( $db, $id, $newstate );
+?>
+Successfully updated ID=<?php echo $id; ?>.
+<?php
+} else {
+ // send logs
+ $log_filter = $_GET['f'] ? $_GET['f'] : '';
+ $state = $_GET['state']; // ? $_GET['state'] : '';
+
+ // retrieve data
+ $result = retrieve( $db, $log_filter, $state );
+ echo '<?xml version="1.0"?>';
+ ?>
+<rss version="2.0">
+ <channel>
+ <title>RSS supplied logs <?php echo $state; echo $log_filter; ?></title>
+ <link><?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?></link>
+ <description>RSS supplied logs</description>
+ <?php
+ // echo '<description>foo</description>';
+ while( sqlite_has_more($result) )
+ {
+ $row = sqlite_fetch_array($result, SQLITE_ASSOC );
+ $tags = ' [ id=' . $row['id']. ',state=' . $row['state'];
+ if ($row['tags'])
+ $tags .= ',' . $row['tags'];
+ $tags .= ' ]';
+ echo '<item>';
+ echo '<title>' . $row['title'] . $tags . '</title>';
+ echo '<description>' . $row['content'] . '</description>';
+ echo '<pubDate>' . date( DATE_ATOM, $row['t'] ) . '</pubDate>';
+ echo '</item>' . "\n";
+ }
+ ?>
+ </channel>
+</rss>
+ <?php
+}
+
+sqlite_close($db);
+
+///////////////////////////////////////////////////////////////////////////////
+// create tables if they don't exist
+function create( $db )
+{
+ $q = "SELECT name FROM sqlite_master WHERE type='table' AND name='Logs';";
+ $result = sqlite_query( $db, $q, SQLITE_NUM );
+ if (!$result) die("Cannot execute query. $q");
+ if( !sqlite_has_more($result) )
+ {
+ // no table found - create it
+ $q = 'CREATE TABLE Logs(' .
+ ' id INTEGER PRIMARY KEY,' .
+ ' title TEXT,' .
+ ' content TEXT NOT NULL,' .
+ ' tags TEXT,' .
+ ' t TIMESTAMP' .
+ ' state INT' .
+ ');';
+ $ok = sqlite_exec($db, $q, $error);
+
+ if (!$ok)
+ die("Cannot execute query $q. $error");
+ }
+}
+
+// insert a new log line
+function insert( $db, $content, $title, $tags )
+{
+ // store a new log line
+ $q = 'INSERT INTO Logs(content, title, tags, t) VALUES( ' .
+ " '" . sqlite_escape_string( $content ) . "'," .
+ " '" . sqlite_escape_string( $title ) . "'," .
+ " '" . sqlite_escape_string( implode(",",$tags) ) . "'," .
+ " datetime('now')" .
+ ')';
+
+ $ok = sqlite_exec($db, $q, $error);
+
+ if (!$ok)
+ die("Cannot execute query. $error (Content: $content Tags: $tags");
+}
+
+// return a handle to all the data
+function retrieve( $db, $filter, $state )
+{
+ $filters = explode(',', $filter); // accept filters by separated by ,
+ foreach ($filters as $i => $val) {
+ $filters[$i] = " (tags LIKE '%" . sqlite_escape_string($val) . "%') ";
+ }
+
+ $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs WHERE" . implode('OR', $filters);;
+
+ if (isset($state))
+ $q .= " AND state=" . $state . " ";
+
+ $q .= "ORDER by t DESC";
+ return sqlite_query( $db, $q, SQLITE_ASSOC );
+}
+
+// delete all log lines older than the timestamp
+function delete( $db, $timestamp )
+{
+ //$q = "DELETE from Logs WHERE t < datetime($timestamp, 'unixepoch', 'localtime')";
+ $q = "DELETE from Logs WHERE t < datetime($timestamp, 'unixepoch')";
+ $ok = sqlite_exec($db, $q, $error);
+
+ if (!$ok)
+ die("Cannot execute query. $error");
+}
+
+function updatestate( $db, $id, $newstate)
+{
+ $q = 'UPDATE Logs SET state=' . $newstate . ' WHERE id=' . $id . ';';
+ $ok = sqlite_exec($db, $q, $error);
+
+ if (!$ok)
+ die("Cannot execute query. $error");
+}
+?>
Copied: CometVisu/trunk/visu/plugins/rsslog/rsslog_correct.pl (from rev 1190, tools/rsslog/rsslog_correct.pl)
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/rsslog_correct.pl (rev 0)
+++ CometVisu/trunk/visu/plugins/rsslog/rsslog_correct.pl 2012-12-08 16:28:41 UTC (rev 1191)
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+#
+# (c) 2011 by Jan N. Klug
+# Licenced under the GPLv3
+#
+# add state-column to rsslog-database
+# use ONLY if your databse is created with rsslog.php before Rev. 703!
+#
+# usage: ./rsslog_correct.pl
+# change path to database !
+
+# config
+my $logdb = '/etc/wiregate/rss/rsslog.db';
+
+# ab hier nichts aendern
+
+#allgemeine Deklarationen
+use strict;
+use DBI;
+
+# Datenbank \xF6fnnen
+if (! -e $logdb) {
+ die "$logdb existiert nicht! Bitte mit rsslog.php anlegen"; # FIXME: create sqlite-db
+}
+
+my $dbargs = {AutoCommit => 0, PrintError => 1};
+my $dbh = DBI->connect("dbi:SQLite2:dbname=$logdb", "", "", $dbargs)
+ or die "Couldn't open database: " . DBI->errstr;
+
+# temp db erzeugen
+my $sqlquery = 'CREATE TEMPORARY TABLE LTemp(title TEXT, content TEXT NOT NULL, tags TEXT, t TIMESTAMP);';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# copy to temp database
+$sqlquery = 'INSERT INTO LTemp SELECT title, content, tags, t FROM Logs;';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# alte db loeschen
+$sqlquery = 'DROP TABLE Logs;';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# neue db erzeugen
+my $sqlquery = 'CREATE TABLE Logs(id INTEGER PRIMARY KEY, title TEXT, content TEXT NOT NULL, tags TEXT, t TIMESTAMP, state INTEGER DEFAULT 0);';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# zurueckkopieren
+$sqlquery = 'INSERT INTO Logs (title, content, tags, t) SELECT title, content, tags, t FROM LTemp;';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# temp database loeschen
+$sqlquery = 'DROP TABLE LTemp;';
+$dbh->do($sqlquery)
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+# erst schreiben, wenn alles funktioniert hat
+$dbh->commit()
+ or die "Couldn't execute command: " . $dbh->errstr;
+
+$dbh->disconnect();
Deleted: tools/rsslog/rsslog.php
===================================================================
--- tools/rsslog/rsslog.php 2012-12-08 14:35:42 UTC (rev 1190)
+++ tools/rsslog/rsslog.php 2012-12-08 16:28:41 UTC (rev 1191)
@@ -1,252 +0,0 @@
-<?php
-/*****************************************************************************/
-/* rsslog.php - A simple log message reciever and sender via RSS */
-/* */
-/* (c) 2011 by Christian Mayer */
-/* Licenced under the GPLv3 */
-/*****************************************************************************/
-
-// There are diffentent modes of operation
-// 1. Creating a new log line:
-// URL parameter "c": the content of the log
-// URL parameter "t[]": a tag for later filtering. Multiple might be given
-// URL parameter "h": a header(title) for the entry; maybe empty
-// 2. Receive the log as RSS:
-// URL parameter "f": The (optional) filter, only log lines with a tag
-// that fit this string are sent
-// URL parameter "state": get only rows with state=value
-// 3. Dump all the content in a HTML page:
-// URL parameter "dump" - no value needed
-// 4. Remove old content:
-// URL parameter "r": the timestamp (seconds since 1970) of the oldest log
-// line to keep
-// 5. Get content as JSON:
-// URL parameter "j"
-// 6. Update state:
-// URL parameter "u" id of row
-// URL parameter "state": new state
-
-
-// look where to store DB
-if (is_dir('/etc/wiregate/rss'))
- $dbfile = '/etc/wiregate/rss/rsslog.db';
-else
- $dbfile = 'rsslog.db';
-
-//check if the DIRECTORY is writeable by the webserver
-$dbfile_dir = dirname($dbfile);
-if (! is_writable($dbfile_dir))
- die ("Database $dbfile not writeable! make sure the file AND " .
- "the directory are writeable by the webserver!");
-
-// create database connection
-$db = sqlite_open($dbfile, 0666, $error);
-if (!$db) die ($error);
-
-// create table if it doesn't exists
-create( $db );
-
-if( isset($_GET['c']) )
-{
- // store a new log
- $store = true;
- $log_content = $_GET['c'] ? $_GET['c'] : '<no content>';
- $log_title = $_GET['h'] ? $_GET['h'] : '';
- if( mb_detect_encoding($log_content, 'UTF-8', true) != 'UTF-8' )
- $log_content = utf8_encode($log_content);
- if( mb_detect_encoding($log_title, 'UTF-8', true) != 'UTF-8' )
- $log_title = utf8_encode($log_title);
- $log_tags = $_GET['t'] ? $_GET['t'] : array();
- if(! is_array($log_tags))
- die("wrong format - use one or more t[]= for tags");
- insert( $db, $log_content, $log_title, $log_tags );
-} else if( isset($_GET['dump']) )
-{
- $result = retrieve( $db, $log_filter, '' );
- ?>
-<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head><body>
-<table border="1">
- <?php
- while( sqlite_has_more($result) )
- {
- $row = sqlite_fetch_array($result, SQLITE_ASSOC );
- echo '<tr>';
- echo '<td>' . $row['id'] . '</td>';
- echo '<td>' . date( DATE_ATOM, $row['t'] ) . '</td>';
- echo '<td>' . $row['t'] . '</td>';
- echo '<td>' . $row['title'] . '</td>';
- echo '<td>' . $row['content'] . '</td>';
- echo '<td>' . $row['tags'] . '</td>';
- echo '<td>' . $row['state'] . '</td>';
- echo "</tr>\n";
- }
- ?>
-</table>
-</body></html>
- <?php
-} else if( isset($_GET['r']) )
-{
- $timestamp = $_GET['r'] ? $_GET['r'] : '';
- delete( $db, $timestamp );
-} else if( isset($_GET['j']) )
-{
- ?>
-{
- "responseData" : {
- "feed" : {
- "feedUrl": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
- "title": "RSS supplied logs",
- "link": "<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?>",
- "author": "",
- "description": "RSS supplied logs",
- "type": "rss20",
- "entries": [
-<?php
- $result = retrieve( $db, $log_filter, '' );
- $first = true;
- while( sqlite_has_more($result) )
- {
- $row = sqlite_fetch_array($result, SQLITE_ASSOC );
- if( !$first ) echo ",\n";
- echo '{';
- echo '"title": "' . $row['title'] . '",';
- echo '"content": "' . $row['content'] . '",';
- echo '"publishedDate": "' . date( DATE_ATOM, $row['t'] ) . '"';
- echo '}';
- $first = false;
- }
-?>
- ]
- }
- },
- "responseDetails" : null,
- "responseStatus" : 200
-}
-<?php
-} else if ( isset($_GET['u']) ) {
- $id = $_GET['u'];
- if (!is_numeric($id))
- die("wrong format - id has to be numeric");
- $newstate = $_GET['state'];
- if (!is_numeric($newstate))
- die("wrong format - state is required and has to be numeric");
- updatestate( $db, $id, $newstate );
-?>
-Successfully updated ID=<?php echo $id; ?>.
-<?php
-} else {
- // send logs
- $log_filter = $_GET['f'] ? $_GET['f'] : '';
- $state = $_GET['state']; // ? $_GET['state'] : '';
-
- // retrieve data
- $result = retrieve( $db, $log_filter, $state );
- echo '<?xml version="1.0"?>';
- ?>
-<rss version="2.0">
- <channel>
- <title>RSS supplied logs <?php echo $state; echo $log_filter; ?></title>
- <link><?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; ?></link>
- <description>RSS supplied logs</description>
- <?php
- // echo '<description>foo</description>';
- while( sqlite_has_more($result) )
- {
- $row = sqlite_fetch_array($result, SQLITE_ASSOC );
- $tags = ' [ id=' . $row['id']. ',state=' . $row['state'];
- if ($row['tags'])
- $tags .= ',' . $row['tags'];
- $tags .= ' ]';
- echo '<item>';
- echo '<title>' . $row['title'] . $tags . '</title>';
- echo '<description>' . $row['content'] . '</description>';
- echo '<pubDate>' . date( DATE_ATOM, $row['t'] ) . '</pubDate>';
- echo '</item>' . "\n";
- }
- ?>
- </channel>
-</rss>
- <?php
-}
-
-sqlite_close($db);
-
-///////////////////////////////////////////////////////////////////////////////
-// create tables if they don't exist
-function create( $db )
-{
- $q = "SELECT name FROM sqlite_master WHERE type='table' AND name='Logs';";
- $result = sqlite_query( $db, $q, SQLITE_NUM );
- if (!$result) die("Cannot execute query. $q");
- if( !sqlite_has_more($result) )
- {
- // no table found - create it
- $q = 'CREATE TABLE Logs(' .
- ' id INTEGER PRIMARY KEY,' .
- ' title TEXT,' .
- ' content TEXT NOT NULL,' .
- ' tags TEXT,' .
- ' t TIMESTAMP' .
- ' state INT' .
- ');';
- $ok = sqlite_exec($db, $q, $error);
-
- if (!$ok)
- die("Cannot execute query $q. $error");
- }
-}
-
-// insert a new log line
-function insert( $db, $content, $title, $tags )
-{
- // store a new log line
- $q = 'INSERT INTO Logs(content, title, tags, t) VALUES( ' .
- " '" . sqlite_escape_string( $content ) . "'," .
- " '" . sqlite_escape_string( $title ) . "'," .
- " '" . sqlite_escape_string( implode(",",$tags) ) . "'," .
- " datetime('now')" .
- ')';
-
- $ok = sqlite_exec($db, $q, $error);
-
- if (!$ok)
- die("Cannot execute query. $error (Content: $content Tags: $tags");
-}
-
-// return a handle to all the data
-function retrieve( $db, $filter, $state )
-{
- $filters = explode(',', $filter); // accept filters by separated by ,
- foreach ($filters as $i => $val) {
- $filters[$i] = " (tags LIKE '%" . sqlite_escape_string($val) . "%') ";
- }
-
- $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs WHERE" . implode('OR', $filters);;
-
- if (isset($state))
- $q .= " AND state=" . $state . " ";
-
- $q .= "ORDER by t DESC";
- return sqlite_query( $db, $q, SQLITE_ASSOC );
-}
-
-// delete all log lines older than the timestamp
-function delete( $db, $timestamp )
-{
- //$q = "DELETE from Logs WHERE t < datetime($timestamp, 'unixepoch', 'localtime')";
- $q = "DELETE from Logs WHERE t < datetime($timestamp, 'unixepoch')";
- $ok = sqlite_exec($db, $q, $error);
-
- if (!$ok)
- die("Cannot execute query. $error");
-}
-
-function updatestate( $db, $id, $newstate)
-{
- $q = 'UPDATE Logs SET state=' . $newstate . ' WHERE id=' . $id . ';';
- $ok = sqlite_exec($db, $q, $error);
-
- if (!$ok)
- die("Cannot execute query. $error");
-}
-?>
Deleted: tools/rsslog/rsslog_correct.pl
===================================================================
--- tools/rsslog/rsslog_correct.pl 2012-12-08 14:35:42 UTC (rev 1190)
+++ tools/rsslog/rsslog_correct.pl 2012-12-08 16:28:41 UTC (rev 1191)
@@ -1,64 +0,0 @@
-#!/usr/bin/perl
-#
-# (c) 2011 by Jan N. Klug
-# Licenced under the GPLv3
-#
-# add state-column to rsslog-database
-# use ONLY if your databse is created with rsslog.php before Rev. 703!
-#
-# usage: ./rsslog_correct.pl
-# change path to database !
-
-# config
-my $logdb = '/etc/wiregate/rss/rsslog.db';
-
-# ab hier nichts aendern
-
-#allgemeine Deklarationen
-use strict;
-use DBI;
-
-# Datenbank \xF6fnnen
-if (! -e $logdb) {
- die "$logdb existiert nicht! Bitte mit rsslog.php anlegen"; # FIXME: create sqlite-db
-}
-
-my $dbargs = {AutoCommit => 0, PrintError => 1};
-my $dbh = DBI->connect("dbi:SQLite2:dbname=$logdb", "", "", $dbargs)
- or die "Couldn't open database: " . DBI->errstr;
-
-# temp db erzeugen
-my $sqlquery = 'CREATE TEMPORARY TABLE LTemp(title TEXT, content TEXT NOT NULL, tags TEXT, t TIMESTAMP);';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# copy to temp database
-$sqlquery = 'INSERT INTO LTemp SELECT title, content, tags, t FROM Logs;';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# alte db loeschen
-$sqlquery = 'DROP TABLE Logs;';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# neue db erzeugen
-my $sqlquery = 'CREATE TABLE Logs(id INTEGER PRIMARY KEY, title TEXT, content TEXT NOT NULL, tags TEXT, t TIMESTAMP, state INTEGER DEFAULT 0);';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# zurueckkopieren
-$sqlquery = 'INSERT INTO Logs (title, content, tags, t) SELECT title, content, tags, t FROM LTemp;';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# temp database loeschen
-$sqlquery = 'DROP TABLE LTemp;';
-$dbh->do($sqlquery)
- or die "Couldn't execute command: " . $dbh->errstr;
-
-# erst schreiben, wenn alles funktioniert hat
-$dbh->commit()
- or die "Couldn't execute command: " . $dbh->errstr;
-
-$dbh->disconnect();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|