From 51ff84fa656ed2b149838f7f9cd6b2a3ab45d973 Mon Sep 17 00:00:00 2001 From: ag Date: Sun, 14 Apr 2024 20:30:09 +0000 Subject: [PATCH] First --- __pycache__/rfeed.cpython-310.pyc | Bin 0 -> 27041 bytes gifsicle.html | 48 ++ gifsicle.min.js | 7 + pixelWidget.html | 148 ++++++ rfeed.py | 775 ++++++++++++++++++++++++++++++ rssgen.html | 81 ++++ rtest.py | 28 ++ 7 files changed, 1087 insertions(+) create mode 100644 __pycache__/rfeed.cpython-310.pyc create mode 100644 gifsicle.html create mode 100644 gifsicle.min.js create mode 100644 pixelWidget.html create mode 100644 rfeed.py create mode 100644 rssgen.html create mode 100644 rtest.py diff --git a/__pycache__/rfeed.cpython-310.pyc b/__pycache__/rfeed.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7f378e5a64c6da3e1e045a203e1268a989a9f604 GIT binary patch literal 27041 zcmchATW}m#dfwbIGZadORclQ zE8q8@K7APsK;1S&^+BI&pUZ##^Zoz%&rxS=teU~^*E^N9mda%QD?Q0y8J=@^yg$ii zGEU}3#>w8uI=LG;H{;}wW}L#kyjyUKZuV~Oe)eeQM#(AO7;#F@NUMCKEPpFED)?J& zRkucOjAk=#WwYj#j%A$6+d1`uTf8xb*lKHhYvRU4Hq(Bn$6VFcr1rm&X-^a~?$qvL zHp71sH=*O+%(SyRnM)aG)TzCbacXySH>TkmbH?Etcc<^>ZybVu!kL7BQv5UUPdU@@ zPmBLB{D+(w_-Dj_1pdR$5%`aY|0w)NormCmNc<1Mf6O@!|8emjga2XY1pFt&e;oct zoJZk*RQwOa|CnRJZ;Af|{Es^);Xf(+!@55g#WZN2mhS-pMZbfIRpP0_esP*<%}$6W}gp= zYRz?>+5Go0sG0BM$*4S>-kD{)?Kkc9j&*s?`jXvpY^Cfi+d6G+`2Mzcc7A@f)mfkO zZf!T)ow-J5tCzEG1=+dY51aV)roYi$Wz@V*H7}oHzSa3H+w)yDfBoY53s)}AZ8`GM zrP*vy_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KyKiQi)iTyLZ)dNEa?2tL{XHVid zz0_Y?GQ?6Zz}?_Dq*Jfw(ck*+TaX3j(TRQ9BZ+m_6$fpggc|+?4N7!ZOamOEKWCqD zK`Z0t<61$6ZT4v?Cm5~Q!+D`EGuImzcrR??IAxIEvbU9NvHpF2;UCiZH*kWyx9bHX z;r|08T;WYYa*T;wEXXxG0s(;gmc#!uOfb5*#VZo^?W|=M_!=EiaSI@OlV0B4BsZ(b zO%ifUUycRKu|qk7CC5#~7)?yLWFJ+ObVAv@`n=)F=AE>6Smy-gm-XH4uaG!AR-*vh zumZ+HE?+00$`!y1b2#Bv!)fi@2jlt4i<9NasmUXg*5osjPfQ-izhje!;Xj7A#mNhk KS2I67Q~ZCY$w^QE literal 0 HcmV?d00001 diff --git a/gifsicle.html b/gifsicle.html new file mode 100644 index 0000000..02abb22 --- /dev/null +++ b/gifsicle.html @@ -0,0 +1,48 @@ + + + + uw.gifsicle + + + + + +
+
+ + + \ No newline at end of file diff --git a/gifsicle.min.js b/gifsicle.min.js new file mode 100644 index 0000000..17a3289 --- /dev/null +++ b/gifsicle.min.js @@ -0,0 +1,7 @@ +/* + gifsicle-wasm-browser + version: v1.5.16 + authors: https://github.com/renzhezhilu/gifsicle-wasm-browser + license: MIT +*/ +let gifsicle={tool:{workerLocalUrl:'var gifsicle=function(){Me="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(Me=Me||__filename);var Me,c=function(e){var j,r,h=void 0!==(e=e||{})?e:{},t=(h.ready=new Promise(function(e,r){j=e}),h.preRun=h.preRun||[],h.preRun.push(function(){if(h.folder&&h.folder.length)for(let e=0;e>10,56320|1023&s)))):i+=String.fromCharCode(u)}return i}function W(e,r){return e?g(E,e,r):""}function X(e,r,t,n){if(!(0>6,r[t++]=128|63&s}else if(s<=65535){if(i<=t+2)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(i<=t+3)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s}}return r[t]=0,t-o}function G(e){for(var r=0,t=0;t>2]=e}var x={splitPath:function(e){return/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,r){for(var t=0,n=e.length-1;0<=n;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:function(e){var r="/"===e.charAt(0),t="/"===e.substr(-1);return(e=(e=x.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||r?e:".")&&t&&(e+="/"),(r?"/":"")+e},dirname:function(e){var e=x.splitPath(e),r=e[0],e=e[1];return r||e?r+(e=e&&e.substr(0,e.length-1)):"."},basename:function(e){if("/"===e)return"/";var r=e.lastIndexOf("/");return-1===r?e:e.substr(r+1)},extname:function(e){return x.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return x.normalize(e.join("/"))},join2:function(e,r){return x.normalize(e+"/"+r)}},R={resolve:function(){for(var e="",r=!1,t=arguments.length-1;-1<=t&&!r;t--){var n=0<=t?arguments[t]:T.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r="/"===n.charAt(0)}return(r?"/":"")+(e=x.normalizeArray(e.split("/").filter(function(e){return!!e}),!r).join("/"))||"."},relative:function(e,r){function t(e){for(var r=0;r>>0),0!=t&&(r=Math.max(r,256)),t=e.contents,e.contents=new Uint8Array(r),0r)e.contents.length=r;else for(;e.contents.length=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,n);if(8>>0)%T.nameTable.length},hashAddNode:function(e){var r=T.hashName(e.parent.id,e.name);e.name_next=T.nameTable[r],T.nameTable[r]=e},hashRemoveNode:function(e){var r=T.hashName(e.parent.id,e.name);if(T.nameTable[r]===e)T.nameTable[r]=e.name_next;else for(var t=T.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:function(e,r){var t=T.mayLookup(e);if(t)throw new T.ErrnoError(t,e);for(var t=T.hashName(e.id,r),n=T.nameTable[t];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===r)return n}return T.lookup(e,r)},createNode:function(e,r,t,n){e=new T.FSNode(e,r,t,n);return T.hashAddNode(e),e},destroyNode:function(e){T.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(e){var r=T.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:function(e){var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:function(e,r){return T.ignorePermissions||(-1===r.indexOf("r")||292&e.mode)&&(-1===r.indexOf("w")||146&e.mode)&&(-1===r.indexOf("x")||73&e.mode)?0:2},mayLookup:function(e){var r=T.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate:function(e,r){try{T.lookupNode(e,r);return 20}catch(e){}return T.nodePermissions(e,"wx")},mayDelete:function(e,r,t){var n;try{n=T.lookupNode(e,r)}catch(e){return e.errno}r=T.nodePermissions(e,"wx");if(r)return r;if(t){if(!T.isDir(n.mode))return 54;if(T.isRoot(n)||T.getPath(n)===T.cwd())return 10}else if(T.isDir(n.mode))return 31;return 0},mayOpen:function(e,r){return e?T.isLink(e.mode)?32:T.isDir(e.mode)&&("r"!==T.flagsToPermissionString(r)||512&r)?31:T.nodePermissions(e,T.flagsToPermissionString(r)):44},MAX_OPEN_FDS:4096,nextfd:function(e,r){r=r||T.MAX_OPEN_FDS;for(var t=e=e||0;t<=r;t++)if(!T.streams[t])return t;throw new T.ErrnoError(33)},getStream:function(e){return T.streams[e]},createStream:function(e,r,t){T.FSStream||(T.FSStream=function(){},T.FSStream.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var n,o=new T.FSStream;for(n in e)o[n]=e[n];e=o;r=T.nextfd(r,t);return e.fd=r,T.streams[r]=e},closeStream:function(e){T.streams[e]=null},chrdev_stream_ops:{open:function(e){var r=T.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new T.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,r){return e<<8|r},registerDevice:function(e,r){T.devices[e]={stream_ops:r}},getDevice:function(e){return T.devices[e]},getMounts:function(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:function(r,t){"function"==typeof r&&(t=r,r=!1),T.syncFSRequests++,1=n.length&&i(null)}n.forEach(function(e){if(!e.type.syncfs)return a(null);e.type.syncfs(e,r,a)})},mount:function(e,r,t){var n,o="/"===t,i=!t;if(o&&T.root)throw new T.ErrnoError(10);if(!o&&!i){i=T.lookupPath(t,{follow_mount:!1});if(t=i.path,n=i.node,T.isMountpoint(n))throw new T.ErrnoError(10);if(!T.isDir(n.mode))throw new T.ErrnoError(54)}i={type:e,opts:r,mountpoint:t,mounts:[]},r=e.mount(i);return(r.mount=i).root=r,o?T.root=r:n&&(n.mounted=i,n.mount&&n.mount.mounts.push(i)),r},unmount:function(e){e=T.lookupPath(e,{follow_mount:!1});if(!T.isMountpoint(e.node))throw new T.ErrnoError(28);var e=e.node,r=e.mounted,n=T.getMounts(r),r=(Object.keys(T.nameTable).forEach(function(e){for(var r=T.nameTable[e];r;){var t=r.name_next;-1!==n.indexOf(r.mount)&&T.destroyNode(r),r=t}}),e.mounted=null,e.mount.mounts.indexOf(r));e.mount.mounts.splice(r,1)},lookup:function(e,r){return e.node_ops.lookup(e,r)},mknod:function(e,r,t){var n=T.lookupPath(e,{parent:!0}).node,e=x.basename(e);if(!e||"."===e||".."===e)throw new T.ErrnoError(28);var o=T.mayCreate(n,e);if(o)throw new T.ErrnoError(o);if(n.node_ops.mknod)return n.node_ops.mknod(n,e,r,t);throw new T.ErrnoError(63)},create:function(e,r){return T.mknod(e,r=(r=void 0!==r?r:438)&4095|32768,0)},mkdir:function(e,r){return T.mknod(e,r=(r=void 0!==r?r:511)&1023|16384,0)},mkdirTree:function(e,r){for(var t=e.split("/"),n="",o=0;othis.length-1||e<0))return r=e%this.chunkSize,e=e/this.chunkSize|0,this.getter(e)[r]},o.prototype.setDataGetter=function(e){this.getter=e},o.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",a,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw new Error("Couldn\'t load "+a+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),t=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,e=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,o=1048576,i=(t||(o=n),this);i.setDataGetter(function(e){var r=e*o,t=(e+1)*o-1,t=Math.min(t,n-1);if(void 0===i.chunks[e]&&(i.chunks[e]=function(e,r){if(r=i.length)return 0;var a=Math.min(i.length-o,n);if(i.slice)for(var s=0;s>2]=n.dev,k[t+4>>2]=0,k[t+8>>2]=n.ino,k[t+12>>2]=n.mode,k[t+16>>2]=n.nlink,k[t+20>>2]=n.uid,k[t+24>>2]=n.gid,k[t+28>>2]=n.rdev,k[t+32>>2]=0,F=[n.size>>>0,(S=n.size,1<=+ne(S)?0>>0:~~+oe((S-(~~S>>>0))/4294967296)>>>0:0)],k[t+40>>2]=F[0],k[t+44>>2]=F[1],k[t+48>>2]=4096,k[t+52>>2]=n.blocks,k[t+56>>2]=n.atime.getTime()/1e3|0,k[t+60>>2]=0,k[t+64>>2]=n.mtime.getTime()/1e3|0,k[t+68>>2]=0,k[t+72>>2]=n.ctime.getTime()/1e3|0,k[t+76>>2]=0,F=[n.ino>>>0,(S=n.ino,1<=+ne(S)?0>>0:~~+oe((S-(~~S>>>0))/4294967296)>>>0:0)],k[t+80>>2]=F[0],k[t+84>>2]=F[1],0},doMsync:function(e,r,t,n,o){e=E.slice(e,e+t);T.msync(r,e,o,t,n)},doMkdir:function(e,r){return"/"===(e=x.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),T.mkdir(e,r,0),0},doMknod:function(e,r,t){switch(61440&r){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return T.mknod(e,r,t),0},doReadlink:function(e,r,t){if(t<=0)return-28;var e=T.readlink(e),n=Math.min(t,G(e)),o=y[r+n];return X(e,E,r,t+1),y[r+n]=o,n},doAccess:function(e,r){if(-8&r)return-28;e=T.lookupPath(e,{follow:!0}).node;if(!e)return-44;var t="";return 4&r&&(t+="r"),2&r&&(t+="w"),1&r&&(t+="x"),t&&T.nodePermissions(e,t)?-2:0},doDup:function(e,r,t){var n=T.getStream(t);return n&&T.close(n),T.open(e,r,0,t,t).fd},doReadv:function(e,r,t,n){for(var o=0,i=0;i>2],s=k[r+(8*i+4)>>2],a=T.read(e,y,a,s,n);if(a<0)return-1;if(o+=a,a>2],s=k[r+(8*i+4)>>2],a=T.write(e,y,a,s,n);if(a<0)return-1;o+=a}return o},varargs:void 0,get:function(){return N.varargs+=4,k[N.varargs-4>>2]},getStr:function(e){return W(e)},getStreamFromFD:function(e){e=T.getStream(e);if(e)return e;throw new T.ErrnoError(8)},get64:function(e,r){return e}};var ge={};function z(){if(!z.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:C||"./this.program"};for(r in ge)e[r]=ge[r];var r,t=[];for(r in e)t.push(r+"="+e[r]);z.strings=t}return z.strings}function ve(e,r,t,n){this.parent=e=e||this,this.mount=e.mount,this.mounted=null,this.id=T.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n}function ye(e,r,t){t=0>2]=t/1e3|0,k[r+4>>2]=t%1e3*1e3*1e3|0,0},d:function(e,r,t){N.varargs=t;try{var n=N.getStreamFromFD(e);switch(r){case 0:return(o=N.get())<0?-28:T.open(n.path,n.flags,0,o).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:var o=N.get();return n.flags|=o,0;case 12:o=N.get();return K[o+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return A(28),-1;default:return-28}}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},i:function(e,r,t){N.varargs=t;try{var n=N.getStreamFromFD(e);switch(r){case 21509:case 21505:return n.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return n.tty?0:-59;case 21519:if(!n.tty)return-59;var o=N.get();return k[o>>2]=0;case 21520:return n.tty?-28:-59;case 21531:o=N.get();return T.ioctl(n,r,o);case 21523:case 21524:return n.tty?0:-59;default:D("bad ioctl syscall "+r)}}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},e:function(e,r,t){N.varargs=t;try{var n=N.getStr(e),o=N.get();return T.open(n,r,o).fd}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},t:function(e){try{return e=N.getStr(e),T.rmdir(e),0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},j:function(e){try{var r=N.umask;return N.umask=e,r}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},u:function(e){try{return e=N.getStr(e),T.unlink(e),0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},v:function(e,r,t,n){try{D("cannot wait on child processes")}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),-e.errno}},n:function(e,r,t){E.copyWithin(e,r,r+t)},b:function(e){var r=E.length,t=2147483648;if(t<(e>>>=0))return!1;for(var n,o=1;o<=4;o*=2){var i=r*(1+.2/o),i=Math.min(i,e+100663296);if(function(e){try{return p.grow(e-v.byteLength+65535>>>16),Y(p.buffer),1}catch(e){}}(Math.min(t,(0<(i=Math.max(16777216,e,i))%(n=65536)&&(i+=n-i%n),i))))return!0}return!1},p:function(a,s){var u=0;return z().forEach(function(e,r){for(var t=s+u,n=(k[a+4*r>>2]=t,e),o=t,r=void 0,i=0;i>0]=n.charCodeAt(i);r||(y[o>>0]=0),u+=e.length+1}),0},q:function(e,r){var t=z(),n=(k[e>>2]=t.length,0);return t.forEach(function(e){n+=e.length+1}),k[r>>2]=n,0},c:function(e){xe(e)},f:function(e){try{var r=N.getStreamFromFD(e);return T.close(r),0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),e.errno}},r:function(e,r){try{var t=N.getStreamFromFD(e),n=t.tty?2:T.isDir(t.mode)?3:T.isLink(t.mode)?7:4;return y[r>>0]=n,0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),e.errno}},h:function(e,r,t,n){try{var o=N.getStreamFromFD(e),i=N.doReadv(o,r,t);return k[n>>2]=i,0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),e.errno}},m:function(e,r,t,n,o){try{var i=N.getStreamFromFD(e),a=4294967296*t+(r>>>0),s=9007199254740992;return a<=-s||s<=a?-61:(T.llseek(i,a,n),F=[i.position>>>0,(S=i.position,1<=+ne(S)?0>>0:~~+oe((S-(~~S>>>0))/4294967296)>>>0:0)],k[o>>2]=F[0],k[o+4>>2]=F[1],i.getdents&&0==a&&0===n&&(i.getdents=null),0)}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),e.errno}},g:function(e,r,t,n){try{var o=N.getStreamFromFD(e),i=N.doWritev(o,r,t);return k[n>>2]=i,0}catch(e){return void 0!==T&&e instanceof T.ErrnoError||D(e),e.errno}},memory:p,o:function(){w("missing function: popen"),D(-1)},l:function(){return 6},k:function(){},table:I},_e=(!function(){var r={a:ke};function t(e,r){e=e.exports;h.asm=e,ue()}function n(e){t(e.instance)}function o(e){return(l||!L&&!c||"function"!=typeof fetch||de(P)?new Promise(function(e,r){e(pe())}):fetch(P,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at \'"+P+"\'"}).catch(pe)).then(function(e){return WebAssembly.instantiate(e,r)}).then(e,function(e){w("failed to asynchronously prepare wasm: "+e),D(e)})}if(se(),h.instantiateWasm)try{h.instantiateWasm(r,t);return}catch(e){return w("Module.instantiateWasm callback failed with error: "+e)}l||"function"!=typeof WebAssembly.instantiateStreaming||ce(P,fe)||de(P)||"function"!=typeof fetch?o(n):fetch(P,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,r).then(n,function(e){return w("wasm streaming compile failed: "+e),w("falling back to ArrayBuffer instantiation"),o(n)})})}(),h.___wasm_call_ctors=function(){return(_e=h.___wasm_call_ctors=h.asm.w).apply(null,arguments)}),be=h._malloc=function(){return(be=h._malloc=h.asm.x).apply(null,arguments)},De=h.___errno_location=function(){return(De=h.___errno_location=h.asm.y).apply(null,arguments)},Se=(h._main=function(){return(h._main=h.asm.z).apply(null,arguments)},h.stackAlloc=function(){return(Se=h.stackAlloc=h.asm.A).apply(null,arguments)});function Fe(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Pe(r){var t=h._main;r=r||[];try{for(let e=0;e>2]=V(C);for(var n=1;n>2)+n]=V(e[n-1]);return k[(t>>2)+r]=0,{argc:r,argv:t}}(s.split(" ").filter(e=>Boolean(e)));if(0!==(n=t(o,i)))break}xe(n,!0)}catch(e){if(e instanceof Fe)return;if("unwind"==e)return void(d=!0);var a=e;e&&"object"==typeof e&&e.stack&&(a=[e,e.stack]),w("exception thrown: "+a),u(1,e)}}function Ae(e){function r(){Ee||(Ee=!0,h.calledRun=!0,U||(h.noFSInit||T.init.initialized||T.init(),Z(J),T.ignorePermissions=!1,Z(Q),j(h),h.onRuntimeInitialized&&h.onRuntimeInitialized(),Re&&Pe(e),te()))}e=e||a,0<_||(re(),0<_||(h.setStatus?(h.setStatus("Running..."),setTimeout(function(){setTimeout(function(){h.setStatus("")},1),r()},1)):r()))}function xe(e,r){r&&d&&0===e||(d||(U=!0,h.onExit&&h.onExit(e)),u(e,new Fe(e)))}if(h.dynCall_vi=function(){return(h.dynCall_vi=h.asm.B).apply(null,arguments)},b=function e(){Ee||Ae(),Ee||(b=e)},h.run=Ae,h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0{0{t+=String.fromCharCode(e),10===e&&(console.error(t),t="")},stdout:e=>{r+=String.fromCharCode(e),10===e&&(console.log(r),r="")}};const l=[];return async(e={})=>{let{data:i=null,command:a=[],folder:s=[],isStrict:u=!1}=e;return await new Promise(e=>{l.push(e),1===l.length&&l[0]()}),new Promise((r,t)=>{let n=!1,o="";c({stdout:f.stdout,stderr:e=>{o+=String.fromCharCode(e),10===e&&(console.error(o),u&&t(o))},arguments:a,input:i,folder:s,output:e=>{r(e),n=!0}}).then(()=>{(0,f.flush)(),n||t(),0{var e=await gifsicle(r.data).catch(e=>{postMessage(e)});postMessage(e)})().catch(e=>{postMessage(null)})};',workerBlobUrl:"",worker(){return this.workerBlobUrl||(this.workerLocalUrl?this.workerBlobUrl=URL.createObjectURL(new Blob([this.workerLocalUrl])):this.workerBlobUrl="../src/worker.js",this.workerBlobUrl)},errorLink(){return" \n Check: https://github.com/renzhezhilu/gifsicle-wasm-browser"},testType(A){return A instanceof Element?"element":Object.prototype.toString.call(A).replace(/\[object\s(.+)\]/,"$1").toLowerCase()},async textToUrl(A){return this.worker()},loadCommand(A){var I=this.testType(A);if(0===A.length)throw" the content can not be blank"+this.errorLink();if("array"===I)return A.map(A=>A.replace(/\n/gi," "));throw" types:"+I+", must be an array"+this.errorLink()},loadOne(B){return new Promise(async(I,A)=>{var g=this.testType(B);if(["string"].includes(g))fetch(B).then(A=>{if(200!==A.status)throw"<"+B+"> Url error!!!"+this.errorLink();return A.arrayBuffer()}).then(A=>I(A));else if(["blob","file"].includes(g))new Response(B).arrayBuffer().then(A=>I(A));else{if(!["arraybuffer"].includes(g))throw" types:"+g+", only supports Url, blob, file, arraybuffer"+this.errorLink();I(B)}})},loadFile(B){return new Promise(async(I,A)=>{var g=this.testType(B);if("array"!==g)throw" types:"+g+", only supports Array"+this.errorLink();if(0===B.length)throw" the content can not be blank"+this.errorLink();g=B.map(A=>this.loadOne(A.file));Promise.all(g).then(function(g){var A=B.map((A,I)=>(A.file=g[I],A));I(A)}).catch(function(A){})})},loadFolder(B){return new Promise(async(A,I)=>{var g=this.testType(B);if(!["array"].includes(g))throw" types:"+g+", only supports Array"+this.errorLink();A(B)})}},run(t={}){return new Promise(async(Q,A)=>{let{input:I=[],command:g="",folder:B=[],isStrict:C=!1,start:E=A=>{}}=t;var i=await this.tool.textToUrl();let o=new Worker(i);var D=this.tool.loadCommand(g),w=await this.tool.loadFile(I),e=(E(w),await this.tool.loadFolder(B));console.log(D),console.log(w),console.log(i),o.postMessage({data:w,command:D,folder:e,isStrict:C}),o.onmessage=async function(I){if(!I.data||"string"==typeof I.data)return o.terminate(),void A(I.data);let g=[];for(let A=0;A + + + + + + + + + +Background color: +
+
+
+Color picker: +Hex input: +
+
+
+X +Y + + +
+
+
+
+ + \ No newline at end of file diff --git a/rfeed.py b/rfeed.py new file mode 100644 index 0000000..2762708 --- /dev/null +++ b/rfeed.py @@ -0,0 +1,775 @@ +__name__ = "rfeed" +__version__ = (1, 0, 0) +__author__ = "Santiago L. Valdarrama - https://blog.svpino.com" +_generator = __name__ + " v" + ".".join(map(str, __version__)) +_docs = "https://github.com/svpino/rfeed/blob/master/README.md" + +import itertools +import sys +from xml.sax import saxutils + +if sys.version_info[0] == 3: + basestring = str + from io import StringIO +else: + try: + from cStringIO import StringIO + except ImportError: + from StringIO import StringIO + +class Serializable: + """ Represents an object that can be serialized as part of the feed. + """ + def __init__(self): + """ Initializes the extension. In your implementation, make sure you always call this base class method + before adding your own code. + """ + self.handler = None + + def publish(self, handler): + """ This method produces the XML representation of the object to be included in the feed. In your implementation, + make sure you always call this base class method before adding your own code. + Keyword arguments: + handler -- An xml.sax.saxutils.XMLGenerator instance that you can use to create the XML representation of the object. + """ + self.handler = handler + + def _date(self, date): + """ Converts a datetime into an RFC 2822 formatted date. + Returns None if None is provided as an argument. + Keyword arguments: + date -- A datetime object in GMT format. + """ + + # Alright, I admit it: this method looks hideous. The thing is that RFC 822 requires a specific format for dates, and strftime is + # locale dependent, so I can't use it to create the final date unless I force change the system locale. + # + # I looked into that (locale.setlocale, then restore), but I got the feeling that I was doing things that I was going to regret later. + # Maybe it's just me, but it doesn't feel right to force change the locale just to create a simple date. + # + # So, not having a better solution, I went ahead and used the original method from the PyRSS2Gen library. + + if date is None: + return None + + return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][date.weekday()], date.day, + ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.month-1], date.year, date.hour, date.minute, date.second) + + def _write_element(self, name, value, attributes = {}): + def parse_cdata(string): + cdata_begin = string.find("") + if cdata_end != -1: + return {"begin": cdata_begin, + "end": cdata_begin + cdata_end + 3} + else: + return None + else: + return None + + if value is not None or attributes != {}: + self.handler.startElement(name, attributes) + + if value is not None: + str_value = value if isinstance(value, basestring) else str(value) + while len(str_value): + cdata_section = parse_cdata(str_value) + if cdata_section is not None: + self.handler.characters(str_value[:cdata_section["begin"]]) + self.handler.ignorableWhitespace( + str_value[cdata_section["begin"]:cdata_section["end"]]) + str_value = str_value[cdata_section["end"]:] + else: + self.handler.characters(str_value) + break + + self.handler.endElement(name) + +class Extension(Serializable): + def get_namespace(self): + """ Returns the namespace (if any) for this extension. The namespace information is added as an attribute in + the element of the feed. The return value should be a dictionary. + For example, here is the code for this method on the iTunes extension: return {"xmlns:itunes": "http://www.itunes.com/dtds/podcast-1.0.dtd"} + """ + pass + +class Host(Serializable): + """ Represents an object that can be host to other extensions. + """ + def __init__(self, extensions = None): + Serializable.__init__(self) + + self.extensions = [] if extensions is None else extensions + + def add_extension(self, extension): + """ You can use this method to add new extensions to the feed. + To create new extensions, make sure you inherit from the Serializable or Extension class. + """ + if not isinstance(extension, Serializable): + raise TypeError("The provided extension should be a subclass of the Serializable class") + + self.extensions.append(extension) + +class Category(Serializable): + """ A Category object specifies one or more categories that the channel or item belongs to. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltcategorygtSubelementOfLtitemgt + """ + def __init__(self, category, domain = None): + """ Keyword arguments: + category -- The name of the category + domain -- Optional. A string that identifies a categorization taxonomy. + """ + + Serializable.__init__(self) + + if category is None: raise ElementRequiredError("category") + + self.category = category + self.domain = domain + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("category", self.category, { "domain": self.domain } if self.domain is not None else {}) + +class Cloud(Serializable): + """ A Cloud object specifies a web service that supports the rssCloud interface which can be implemented in HTTP-POST, XML-RPC or SOAP 1.1. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltcloudgtSubelementOfLtchannelgt + """ + def __init__(self, domain, port, path, registerProcedure, protocol): + """ Keyword arguments: + domain -- The domain name or IP address of the cloud. + port -- TCP port that the cloud is running on. + path -- The location of its responder. + registerProcedure -- The name of the procedure to call to request notification. + protocol -- Indication of which protocol is to be used. + """ + + Serializable.__init__(self) + + if domain is None: raise ElementRequiredError("domain") + if port is None: raise ElementRequiredError("port") + if path is None: raise ElementRequiredError("path") + if registerProcedure is None: raise ElementRequiredError("registerProcedure") + if protocol is None: raise ElementRequiredError("protocol") + + self.domain = domain + self.port = port + self.path = path + self.registerProcedure = registerProcedure + self.protocol = protocol + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("cloud", None, { "domain": self.domain, "port": str(self.port), "path": self.path, "registerProcedure": self.registerProcedure, "protocol": self.protocol }) + +class Image(Serializable): + """ An Image object specifies a GIF, JPEG or PNG image that can be displayed with the channel. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltimagegtSubelementOfLtchannelgt + """ + def __init__(self, url, title, link, width = None, height = None, description = None): + """ Keyword arguments: + url -- The URL of the image that represents the channel. + title -- Describes the image. It's used in the ALT attribute of the HTML tag when the channel is rendered in HTML. + link -- The URL of the site. When the channel is rendered the image is a link to the site. + width -- Optional. The width of the image in pixels. + height -- Optional. The height of the image in pixels. + description -- Optional. Contains text that is included in the TITLE attribute of the link formed around the image in the HTML rendering. + """ + + Serializable.__init__(self) + + if url is None: raise ElementRequiredError("url") + if title is None: raise ElementRequiredError("title") + if link is None: raise ElementRequiredError("link") + + self.url = url + self.title = title + self.link = link + self.width = width + self.height = height + self.description = description + + def publish(self, handler): + Serializable.publish(self, handler) + self.handler.startElement("image", {}) + + self._write_element("url", self.url) + self._write_element("title", self.title) + self._write_element("link", self.link) + self._write_element("width", self.width) + self._write_element("height", self.height) + self._write_element("description", self.description) + + self.handler.endElement("image") + +class TextInput(Serializable): + """ A TextInput object specifies a text input box that can be displayed with the channel. + More information at http://cyber.law.harvard.edu/rss/rss.html#lttextinputgtSubelementOfLtchannelgt + """ + def __init__(self, title, description, name, link): + """ Keyword arguments: + title -- The label of the submit button in the text input area. + description -- Explains the text input area. + name -- The name of the text object in the text input area. + link -- The URL of the CGI script that processes text input requests. + """ + + Serializable.__init__(self) + + if title is None: raise ElementRequiredError("title") + if description is None: raise ElementRequiredError("description") + if name is None: raise ElementRequiredError("name") + if link is None: raise ElementRequiredError("link") + + self.title = title + self.description = description + self.name = name + self.link = link + + def publish(self, handler): + Serializable.publish(self, handler) + self.handler.startElement("textInput", {}) + + self._write_element("title", self.title) + self._write_element("description", self.description) + self._write_element("name", self.name) + self._write_element("link", self.link) + + self.handler.endElement("textInput") + +class SkipHours(Serializable): + """ A SkipHours object is a hint for aggregators telling them which hours they can skip. + More information at http://cyber.law.harvard.edu/rss/skipHoursDays.html#skiphours + """ + def __init__(self, hours): + """ Keyword arguments: + hours -- A list containing up to 24 values between 0 and 23, representing a time in GMT. + """ + + Serializable.__init__(self) + + if hours is None: raise ElementRequiredError("hours") + + self.hours = hours + + def publish(self, handler): + Serializable.publish(self, handler) + + if self.hours: + self.handler.startElement("skipHours", {}) + + for hour in self.hours: + self._write_element("hour", hour) + + self.handler.endElement("skipHours") + +class SkipDays(Serializable): + """ A SkipDays object is a hint for aggregators telling them which days they can skip. + More information at http://cyber.law.harvard.edu/rss/skipHoursDays.html#skipdays + """ + def __init__(self, days): + """ Keyword arguments: + days -- A list containing up to 7 values. Possible values are Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday. + """ + + Serializable.__init__(self) + + if days is None: raise ElementRequiredError("days") + + self.days = days + + def publish(self, handler): + Serializable.publish(self, handler) + + if self.days: + self.handler.startElement("skipDays", {}) + + for day in self.days: + self._write_element("day", day) + + self.handler.endElement("skipDays") + +class Enclosure(Serializable): + """ An Enclosure object describes a media object that is attached to the item. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltenclosuregtSubelementOfLtitemgt + """ + def __init__(self, url, length, type): + """ Keyword arguments: + url -- Indicates where the enclosure is located. + length -- Specifies how big the enclosure is in bytes. + type -- Specifies the standard MIME type of the enclosure. + """ + Serializable.__init__(self) + + if url is None: raise ElementRequiredError("url") + if length is None: raise ElementRequiredError("length") + if type is None: raise ElementRequiredError("type") + + self.url = url + self.length = length + self.type = type + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("enclosure", None, { "url": self.url, "length": str(self.length), "type": self.type }) + +class Guid(Serializable): + """ A Guid object represents a string that uniquely identifies the item. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltguidgtSubelementOfLtitemgt + """ + def __init__(self, guid, isPermaLink = True): + """ Keyword arguments: + guid -- This is a string that uniquely identifies the item. When present, an aggregator may choose to use this string to determine if an item is new. + isPermaLink -- Indicates whether the guid is a url that points to the item. + """ + Serializable.__init__(self) + + if guid is None: raise ElementRequiredError("guid") + + self.guid = guid + self.isPermaLink = True if isPermaLink is None else isPermaLink + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("guid", self.guid, { "isPermaLink": "true" if self.isPermaLink else "false" }) + +class Source(Serializable): + """ A Source object represents the RSS channel that the item came from. + More information at http://cyber.law.harvard.edu/rss/rss.html#ltsourcegtSubelementOfLtitemgt + """ + def __init__(self, name, url): + """ Keyword arguments: + name -- The name of the RSS channel that the item came from. + url -- Links to the XMLization of the source. + """ + Serializable.__init__(self) + + if name is None: raise ElementRequiredError("name") + if url is None: raise ElementRequiredError("url") + + self.name = name + self.url = url + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("source", self.name, { "url": self.url }) + +class iTunesOwner(Serializable): + """ An iTunesOwner object contains contact information for the owner of the podcast intended to be used for administrative communication. + More information at https://www.apple.com/itunes/podcasts/specs.html#owner + """ + def __init__(self, name, email): + """ Keyword arguments + name -- The name of the owner. + email -- The email address of the owner. + """ + Serializable.__init__(self) + + if name is None: raise ElementRequiredError("name") + if email is None: raise ElementRequiredError("email") + + self.name = name + self.email = email + + def publish(self, handler): + Serializable.publish(self, handler) + + self.handler.startElement("itunes:owner", {}) + self._write_element("itunes:name", self.name) + self._write_element("itunes:email", self.email) + self.handler.endElement("itunes:owner") + +class iTunesCategory(Serializable): + """ An iTunesCategory object specified the browsing category of the feed. + More information at https://www.apple.com/itunes/podcasts/specs.html#category + """ + def __init__(self, name, subcategory = None): + """ Keyword arguments + name -- The name of the category + subcategory -- Optional. The name of the subcategory. + """ + Serializable.__init__(self) + + if name is None: raise ElementRequiredError("name") + + self.name = name + self.subcategory = subcategory + + def publish(self, handler): + Serializable.publish(self, handler) + + self.handler.startElement("itunes:category", { "text": self.name }) + + if self.subcategory is not None: + self._write_element("itunes:category", None, { "text": self.subcategory }) + + self.handler.endElement("itunes:category") + +class iTunes(Extension): + """ Extension for iTunes metatags. + More information at https://www.apple.com/itunes/podcasts/specs.html + """ + def __init__(self, author = None, block = None, categories = None, image = None, explicit = None, complete = None, owner = None, subtitle = None, + summary = None, new_feed_url = None, type=None): + """ Keyword arguments: + author -- The author of the podcast. Visible under podcast title and in iTunes Store Browse. + block -- Whether the podcast should appear in the iTunes Store podcast directory. + categories -- The browsing categories for this podcast. + image -- The URL of the artwork of your podcast. + explicit -- Whether your podcast contains explicit material. + complete -- Whether your podcast has been completed and no further episodes will be posted in the future. + owner -- Contains contact information for the owner of the podcast. + subtitle -- A few words that represent the description of the podcast. + summary -- An extended summary of the podcast. + new_feed_url -- When changing the podcast RSS URL, this is the new URL where the podcast is located. + type -- The type of podcast. + """ + Extension.__init__(self) + + self.author = author + self.block = True if (isinstance(block, basestring) and block.lower() == 'yes') else block + self.image = image + self.explicit = True if (isinstance(explicit, basestring) and explicit.lower() == 'yes') else explicit + self.complete = True if (isinstance(complete, basestring) and complete.lower() == 'yes') else complete + self.owner = owner + self.subtitle = subtitle + self.summary = summary + self.new_feed_url = new_feed_url + self.type = type + + self.categories = [] if categories is None else categories + + if isinstance(self.categories, iTunesCategory): + self.categories = [self.categories] + elif isinstance(self.categories, basestring): + self.categories = [iTunesCategory(self.categories)] + + def get_namespace(self): + return {"xmlns:itunes": "http://www.itunes.com/dtds/podcast-1.0.dtd"} + + def publish(self, handler): + Extension.publish(self, handler) + + self._write_element("itunes:author", self.author) + + if self.block is not None: + self._write_element("itunes:block", "yes" if self.block is True else "no") + + if self.image is not None: + self._write_element("itunes:image", None, {"href" : self.image }) + + if self.explicit is not None: + self._write_element("itunes:explicit", "yes" if self.explicit is True else "clean") + + if self.complete is not None: + self._write_element("itunes:complete", "yes" if self.complete is True else "no") + + if self.owner is not None: + self.owner.publish(self.handler) + + self._write_element("itunes:subtitle", self.subtitle) + self._write_element("itunes:summary", self.summary) + self._write_element("itunes:new-feed-url", self.new_feed_url) + + self._write_element("itunes:type", self.type) + + for category in self.categories: + if isinstance(category, basestring): + category = iTunesCategory(category) + category.publish(self.handler) + +class iTunesItem(Serializable): + """ Extension for iTunes Item metatags. + More information at https://www.apple.com/itunes/podcasts/specs.html + """ + def __init__(self, author = None, block = None, image = None, duration = None, explicit = None, is_closed_captioned = None, order = None, subtitle = None, summary = None, + title=None, episode=None, episodeType=None, season=None): + """ Keyword arguments: + author -- The author of the episode. + block -- Whether the episode should appear in the iTunes Store podcast directory. + image -- The URL of the artwork of your podcast. + duration -- Specifies the duration of the podcast episode. + explicit -- Whether your episode contains explicit material. + is_closed_captioned -- Whether your episode has embedded closed captioning. + order -- Used to override the default ordering of episodes in the iTunes Store. + subtitle -- A few words that represent the description of the episode. + summary -- An extended summary of the episode. + title -- An episode title. + episode -- An episode number. + episodeType -- The episode type. + season -- The episode season number. + """ + Serializable.__init__(self) + + self.author = author + self.block = True if (isinstance(block, basestring) and block.lower() == 'yes') else block + self.image = image + self.duration = duration + self.explicit = True if (isinstance(explicit, basestring) and explicit.lower() == 'yes') else explicit + self.is_closed_captioned = True if (isinstance(is_closed_captioned, basestring) and is_closed_captioned.lower() == 'yes') else is_closed_captioned + self.order = order + self.subtitle = subtitle + self.summary = summary + self.title = title + self.episode = episode + self.episodeType = episodeType + self.season = season + + def publish(self, handler): + Serializable.publish(self, handler) + + self._write_element("itunes:author", self.author) + + if self.block is not None: + self._write_element("itunes:block", "yes" if self.block is True else "no") + + if self.image is not None: + self._write_element("itunes:image", None, {"href" : self.image }) + + self._write_element("itunes:duration", self.duration) + + if self.explicit is not None: + self._write_element("itunes:explicit", "yes" if self.explicit is True else "clean") + + if self.is_closed_captioned is not None: + self._write_element("itunes:is_closed_captioned", "yes" if self.is_closed_captioned is True else "no") + + if self.order is not None: + self._write_element("itunes:order", str(self.order)) + + self._write_element("itunes:subtitle", self.subtitle) + self._write_element("itunes:summary", self.summary) + + self._write_element("itunes:title", self.title) + self._write_element("itunes:episode", self.episode) + self._write_element("itunes:episodeType", self.episodeType) + self._write_element("itunes:season", self.season) + + +class Item(Host): + """ An Item object may represent a "story" - much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. + An item may also be complete in itself, if so, the description contains the text, and the link and title may be omitted. All elements of an item are optional, however at least one + of title or description must be present. + More information at http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt + """ + def __init__(self, title = None, link = None, description = None, author = None, + creator = None, categories = None, comments = None, enclosure = None, + guid = None, pubDate = None, source = None, extensions = None): + """ Keyword arguments: + title -- Optional. The title of the item. + link -- Optional. The URL of the item. + description -- Optional. The item synopsis. + author -- Optional. Email address of the author of the item. + creator -- Optional. Identifies the person or entity who wrote an item. + categories -- Optional. Includes the item in one or more categories. + comments -- Optional. URL of a page for comments relating to the item. + enclosure -- Optional. Describes a media object that is attached to the item. + guid -- Optional. A string that uniquely identifies the item. + pubDate -- Optional. Indicates when the item was published. + source -- Optional. The RSS channel that the item came from. + extensions -- Optional. The list of extensions added to the item. + """ + + Host.__init__(self, extensions) + + if title is None and description is None: + raise ElementRequiredError("title", "description") + + self.title = title + self.link = link + self.description = description + self.author = author + self.creator = creator + self.comments = comments + self.enclosure = enclosure + self.guid = guid + self.pubDate = pubDate + self.source = source + + self.categories = [] if categories is None else categories + + if isinstance(self.categories, Category): + self.categories = [self.categories] + elif isinstance(self.categories, basestring): + self.categories = [Category(self.categories)] + + def publish(self, handler): + Serializable.publish(self, handler) + + self.handler.startElement("item", {}) + + self._write_element("title", self.title) + self._write_element("link", self.link) + self._write_element("description", self.description) + self._write_element("author", self.author) + self._write_element("dc:creator", self.creator) + self._write_element("comments", self.comments) + self._write_element("pubDate", self._date(self.pubDate)) + + for category in self.categories: + if isinstance(category, basestring): + category = Category(category) + category.publish(self.handler) + + if self.enclosure is not None: + self.enclosure.publish(self.handler) + + if self.guid is not None: + self.guid.publish(self.handler) + + if self.source is not None: + self.source.publish(self.handler) + + for extension in self.extensions: + extension.publish(self.handler) + + self.handler.endElement("item") + +class Feed(Host): + def __init__(self, title, link, description, language = None, copyright = None, managingEditor = None, webMaster = None, pubDate = None, + lastBuildDate = None, categories = None, generator = None, docs = None, cloud = None, ttl = None, image = None, rating = None, + textInput = None, skipHours = None, skipDays = None, items = None, extensions = None): + """ Keyword arguments: + title -- The name of the channel. + link -- The URL to the HTML website corresponding to the channel. + description -- Phrase or sentence describing the channel. + language -- Optional. The language the channel is written in. + copyright -- Optional. Copyright notice for content in the channel. + managingEditor -- Optional. Email address for person responsible for editorial content. + webMaster -- Optional. Email address for person responsible for technical issues relating to channel. + pubDate -- Optional. The publication date for the content in the channel. This should be a datetime in GMT format. + lastBuildDate -- Optional. The last time the content of the channel changed. This should be a datetime in GMT format. + categories -- Optional. Specify one or more categories that the channel belongs to. + generator -- Optional. A string indicating the program used to generate the channel. + docs -- Optional. A URL that points to the documentation for the format used in the RSS file. + cloud -- Optional. Allows processes to register with a cloud to be notified of updates to the channel. This is a Cloud object. + ttl -- Optional. The number of minutes that indicates how long a channel can be cached before refreshing from the source. This should be an integer value. + image -- Optional. Specifies an image that can be displayed with the channel. This is an Image object. + rating -- Optional. The PICS rating for the channel. See http://www.w3.org/PICS/. + textInput -- Optional. Specifies a text input box that can be displayed with the channel. + skipHours -- Optional. A hint for aggregators telling them which hours they can skip. + skipDays -- Optional. A hint for aggregators telling them which days they can skip. + items -- Optional. The list of items included in this channel. + extensions -- Optional. The list of extensions added to the feed. + """ + + Host.__init__(self, extensions) + + if title is None: raise ElementRequiredError("title") + if link is None: raise ElementRequiredError("link") + if description is None: raise ElementRequiredError("description") + + self.title = title + self.link = link + self.description = description + self.language = language + self.copyright = copyright + self.managingEditor = managingEditor + self.webMaster = webMaster + self.pubDate = pubDate + self.lastBuildDate = lastBuildDate + self.generator = _generator if generator is None else generator + self.docs = _docs if docs is None else docs + self.cloud = cloud + self.ttl = ttl + self.image = image + self.rating = rating + self.textInput = textInput + self.skipHours = skipHours + self.skipDays = skipDays + + self.categories = [] if categories is None else categories + + if isinstance(self.categories, Category): + self.categories = [self.categories] + elif isinstance(self.categories, basestring): + self.categories = [Category(self.categories)] + + self.items = [] if items is None else items + + def rss(self): + output = StringIO() + handler = saxutils.XMLGenerator(output, 'UTF-8') + handler.startDocument() + + handler.startElement("rss", self._get_attributes()) + self.publish(handler) + handler.endElement("rss") + + handler.endDocument() + return output.getvalue() + + def publish(self, handler): + Serializable.publish(self, handler) + + handler.startElement("channel", {}) + + self._write_element("title", self.title) + self._write_element("link", self.link) + self._write_element("description", self.description) + self._write_element("language", self.language) + self._write_element("copyright", self.copyright) + self._write_element("managingEditor", self.managingEditor) + self._write_element("webMaster", self.webMaster) + self._write_element("pubDate", self._date(self.pubDate)) + self._write_element("lastBuildDate", self._date(self.lastBuildDate)) + self._write_element("generator", self.generator) + self._write_element("docs", self.docs) + self._write_element("ttl", self.ttl) + self._write_element("rating", self.rating) + + for category in self.categories: + if isinstance(category, basestring): + category = Category(category) + category.publish(self.handler) + + if self.cloud is not None: + self.cloud.publish(self.handler) + + if self.image is not None: + self.image.publish(self.handler) + + if self.textInput is not None: + self.textInput.publish(self.handler) + + if self.skipHours is not None: + self.skipHours.publish(self.handler) + + if self.skipDays is not None: + self.skipDays.publish(self.handler) + + for extension in self.extensions: + extension.publish(self.handler) + + for item in self.items: + item.publish(self.handler) + + handler.endElement("channel") + + def _get_attributes(self): + attributes = {"version": "2.0", "xmlns:dc" : "http://purl.org/dc/elements/1.1/"} + + for extension in self.extensions: + if isinstance(extension, Extension): + namespace = extension.get_namespace() + if namespace is not None: + attributes = dict(itertools.chain(attributes.items(), namespace.items())) + + return attributes + +class ElementRequiredError(Exception): + def __init__(self, element1, element2 = None): + self.element1 = element1 + self.element2 = element2 + + def __str__(self): + if self.element2 is not None: + return 'Either "' + self.element1 + '" or "' + self.element2 + '" must be defined' + + return '"' + self.element1 + '" must be defined' diff --git a/rssgen.html b/rssgen.html new file mode 100644 index 0000000..a68b6a5 --- /dev/null +++ b/rssgen.html @@ -0,0 +1,81 @@ + + + + + + + + + Pyodide rss feed gen test, rss code is rfeed from: https://github.com/svpino/rfeed, please wait while we generate some xml
+ + + + \ No newline at end of file diff --git a/rtest.py b/rtest.py new file mode 100644 index 0000000..aa0d5e8 --- /dev/null +++ b/rtest.py @@ -0,0 +1,28 @@ +import datetime +from rfeed import * + +item1 = Item( + title = "First article", + link = "http://www.example.com/articles/1", + description = "This is the description of the first article", + author = "Santiago L. Valdarrama", + guid = Guid("http://www.example.com/articles/1"), + pubDate = datetime.datetime(2014, 12, 29, 10, 00)) + +item2 = Item( + title = "Second article", + link = "http://www.example.com/articles/2", + description = "This is the description of the second article", + author = "Santiago L. Valdarrama", + guid = Guid("http://www.example.com/articles/2"), + pubDate = datetime.datetime(2014, 12, 30, 14, 15)) + +feed = Feed( + title = "Sample RSS Feed", + link = "http://www.example.com/rss", + description = "This is an example of how to use rfeed to generate an RSS 2.0 feed", + language = "en-US", + lastBuildDate = datetime.datetime.now(), + items = [item1, item2]) + +print(feed.rss()) \ No newline at end of file