Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
AGrillenberger committed Nov 1, 2021
2 parents be0866f + bf9e931 commit a2b6989
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 71 deletions.
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,24 @@ app.get('/twitter/get/complete', async (req, res) => {
}
})

app.get('/twitter/get/multiple/:num', async (req, res) => {
tweet = await getTweet();
if(tweet === null) {
res.status(444);
res.send("<a href=\"/twitter/auth\">Twitter authentication required</a>");
} else if (req.params.num > 50) {
res.status(406);
res.send("Only up to 50 tweets may be transferred at a time");
} else {
arr = [tweet];
num = req.params.num - 1;
while(num-- > 0) {
arr.push(await getTweet());
}
res.json(arr);
}
})

app.get('/twitter/get/attrib/:attrib', async (req, res) => {
tweet = await getTweet();
if(tweet === null) {
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 12 additions & 68 deletions snap/SnapTwitter/st2-blocks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -747,52 +747,10 @@
</script>
</block-definition>
<block-definition s="🐦 attribute %&apos;attrib&apos; from tweet %&apos;tw&apos;" type="reporter" category="twitter">
<header></header>
<code></code>
<translations>de:🐦Attribut _ von Tweet _&#xD;</translations>
<inputs>
<input type="%s"></input>
<input type="%obj"></input>
</inputs>
<script>
<block s="doReport">
<block s="evaluate">
<block s="reportJSFunction">
<list>
<l>text</l>
</list>
<l>// remove quotation marks&#xD;return text.replace(/^"(.*)"$/,"$1");</l>
</block>
<list>
<custom-block s="SnapTwitter POST %s data %s">
<block s="reportJoinWords">
<list>
<l>json/get/attrib/</l>
<block var="attrib"/>
</list>
</block>
<block var="tw"/>
</custom-block>
</list>
</block>
</block>
</script>
<header></header><code></code><translations>de:🐦Attribut _ von Tweet _&#xD;</translations><inputs><input type="%s"></input><input type="%obj"></input></inputs><script><block s="doDeclareVariables"><list><l>attribs</l><l>res</l></list></block><block s="doSetVar"><l>attribs</l><block s="reportTextSplit"><block var="attrib"/><l>.</l></block></block><block s="doSetVar"><l>res</l><custom-block s="🐦 tweet %obj as table"><block var="tw"/></custom-block></block><block s="doUntil"><block s="reportEquals"><block s="reportListLength"><block var="attribs"/></block><l>0</l></block><script><block s="doSetVar"><l>res</l><block s="reportListItem"><l>2</l><block s="reportFindFirst"><block s="reifyPredicate"><autolambda><block s="reportEquals"><block s="reportListItem"><l>1</l><l/></block><block s="reportListItem"><l>1</l><block var="attribs"/></block></block></autolambda><list></list></block><block var="res"/></block></block></block><block s="doDeleteFromList"><l>1</l><block var="attribs"/></block></script></block><block s="doReport"><block var="res"/></block></script>
</block-definition>
<block-definition s="🐦 geo of tweet %&apos;tweet&apos;" type="reporter" category="twitter">
<header></header>
<code></code>
<translations>de:🐦Geodaten von Tweet _&#xD;</translations>
<inputs>
<input type="%obj"></input>
</inputs>
<script>
<block s="doReport">
<custom-block s="SnapTwitter POST %s data %s">
<l>json/get/geo</l>
<block var="tweet"/>
</custom-block>
</block>
</script>
<header></header><code></code><translations>de:🐦Geodaten von Tweet _&#xD;</translations><inputs><input type="%obj"></input></inputs><script><block s="doIf"><block s="reportNot"><block s="reportEquals"><custom-block s="🐦 attribute %s from tweet %obj"><l>geo</l><block var="tweet"/></custom-block><l></l></block></block><script><block s="doReport"><block s="reportCombine"><custom-block s="🐦 attribute %s from tweet %obj"><l>geo.coordinates</l><block var="tweet"/></custom-block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block var="#1"/><l>;</l><block var="#2"/></list></block></autolambda><list><l>#1</l><l>#2</l></list></block></block></block></script></block><block s="doIf"><block s="reportNot"><block s="reportEquals"><custom-block s="🐦 attribute %s from tweet %obj"><l>place</l><block var="tweet"/></custom-block><l></l></block></block><script><block s="doDeclareVariables"><list><l>corners</l></list></block><block s="doSetVar"><l>corners</l><block s="reportListItem"><l>1</l><custom-block s="🐦 attribute %s from tweet %obj"><l>place.bounding_box.coordinates</l><block var="tweet"/></custom-block></block></block><block s="doReport"><block s="reportJoinWords"><list><block s="reportQuotient"><block s="reportSum"><block s="reportListItem"><l>2</l><block s="reportListItem"><l>1</l><block var="corners"/></block></block><block s="reportListItem"><l>2</l><block s="reportListItem"><l>3</l><block var="corners"/></block></block></block><l>2</l></block><l>;</l><block s="reportQuotient"><block s="reportSum"><block s="reportListItem"><l>1</l><block s="reportListItem"><l>1</l><block var="corners"/></block></block><block s="reportListItem"><l>1</l><block s="reportListItem"><l>3</l><block var="corners"/></block></block></block><l>2</l></block></list></block></block></script></block><block s="doReport"><l></l></block></script>
</block-definition>
<block-definition s="🐦 tweet %&apos;t&apos; as table" type="reporter" category="twitter">
<header></header>
Expand Down Expand Up @@ -1220,30 +1178,7 @@
</script>
</block-definition>
<block-definition s="CSV %&apos;csv&apos; → table, delimiter %&apos;del&apos;" type="reporter" category="internal">
<header></header>
<code></code>
<translations></translations>
<inputs>
<input type="%s"></input>
<input type="%s">;<options>,&#xD;;</options></input>
</inputs>
<script>
<block s="doReport">
<block s="evaluate">
<block s="reportJSFunction">
<list>
<l>csv</l>
<l>sep</l>
</list>
<l>array = csv.split(&apos;\n&apos;).map( row =&gt; row.split(&apos;;&apos;) ).map( row =&gt; row.map( str =&gt; str.replace(/^\"(.*)\"/, "$1") ) );&#xD;maxLen = Math.max.apply(Math, array.map(row =&gt; row.length));&#xD;array = array.filter(row =&gt; row.length == maxLen);&#xD;&#xD;return new List(array.map( row =&gt; new List(row) ));</l>
</block>
<list>
<block var="csv"/>
<block var="del"/>
</list>
</block>
</block>
</script>
<header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s">;<options>,&#xD;;</options></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>csv</l><l>sep</l></list><l>if(typeof String.prototype.mySplit !== "function") {&#xD; String.prototype.mySplit = function (delim) {&#xD; res = [];&#xD; &#xD; openQuote = false;&#xD; escaped = false;&#xD; &#xD; lastSplit = 0;&#xD; i = 0;&#xD; while(i &lt; this.length) {&#xD; c = this.charAt(i++);&#xD; &#xD; if (escaped) { //char is escaped --&gt; ignore&#xD; escaped = false;&#xD; continue;&#xD; } else if (c == &apos;\\&apos;) { // next char will be considered escaped&#xD; escaped = true; &#xD; } else if (c == &apos;"&apos;) { // if quote is open, close it and otherwise&#xD; openQuote = !openQuote; &#xD; } else if (!openQuote &amp;&amp; c == delim) { // array should be split here&#xD; res.push(this.substring(lastSplit, i-1));&#xD; &#xD; // if next char is whitespace --&gt; ignore&#xD; if(this.charAt(i) == " ") {&#xD; i++;&#xD; }&#xD; &#xD; lastSplit = i;&#xD; }&#xD; }&#xD; res.push(this.substring(lastSplit, this.length))&#xD; &#xD; return res;&#xD; }&#xD;}&#xD;&#xD;array = csv.split(&apos;\n&apos;).map( row =&gt; row.mySplit(sep) ).map( row =&gt; row.map( str =&gt; str.replace(/^\"(.*)\"/, "$1") ) );&#xD;maxLen = Math.max.apply(Math, array.map(row =&gt; row.length));&#xD;array = array.filter(row =&gt; row.length == maxLen);&#xD;&#xD;return new List(array.map( row =&gt; new List(row) ));</l></block><list><block var="csv"/><block var="del"/></list></block></block></script>
</block-definition>
<block-definition s="📂CSV from URL %&apos;url&apos; → table, delimiter %&apos;del&apos;" type="reporter" category="data">
<header></header>
Expand Down Expand Up @@ -1304,4 +1239,13 @@
</block>
</script>
</block-definition>
<block-definition s="JSON array %&apos;arr&apos; to list" type="reporter" category="internal">
<header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>txt</l></list><l>parse = JSON.parse(txt);&#xD;return new List(parse.map(x =&gt; (typeof x == "object" ? JSON.stringify(x) : x)));</l></block><list><block var="arr"/></list></block></block></script>
</block-definition>
<block-definition s="🐦 %&apos;num&apos; tweets as list" type="reporter" category="twitter">
<header></header><code></code><translations>de:🐦 _ Tweets als Liste&#xD;</translations><inputs><input type="%n">5</input></inputs><script><block s="doReport"><custom-block s="JSON array %s to list"><custom-block s="SnapTwitter request %s"><block s="reportJoinWords"><list><l>twitter/get/multiple/</l><block var="num"/></list></block></custom-block></custom-block></block></script>
</block-definition>
<block-definition s="🐦tweet list %&apos;list&apos; as table" type="reporter" category="twitter">
<header></header><code></code><translations>de:🐦Tweetliste _ als Tabelle&#xD;</translations><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>attribs</l><l>return</l></list></block><block s="doSetVar"><l>attribs</l><block s="reportNewList"><list></list></block></block><block s="doForEach"><l>tweet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportListItem"><l>1</l><l/></block></autolambda><list></list></block><l/></block></autolambda><list></list></block><block s="reportMap"><block s="reifyReporter"><autolambda><custom-block s="🐦 tweet %obj as table"><l/></custom-block></autolambda><list></list></block><block var="list"/></block></block><script><block s="doForEach"><l>attrib</l><block var="tweet"/><script><block s="doIf"><block s="reportNot"><block s="reportListContainsItem"><block var="attribs"/><block var="attrib"/></block></block><script><block s="doAddToList"><block var="attrib"/><block var="attribs"/></block></script></block></script></block></script></block><block s="doSetVar"><l>return</l><block s="reportNewList"><list><block var="attribs"/></list></block></block><block s="doForEach"><l>tweet</l><block var="list"/><script><block s="doDeclareVariables"><list><l>tweetAsList</l></list></block><block s="doSetVar"><l>tweetAsList</l><block s="reportNewList"><list></list></block></block><block s="doForEach"><l>attrib</l><block var="attribs"/><script><block s="doAddToList"><custom-block s="🐦 attribute %s from tweet %obj"><block var="attrib"/><block var="tweet"/></custom-block><block var="tweetAsList"/></block></script></block><block s="doAddToList"><block var="tweetAsList"/><block var="return"/></block></script></block><block s="doReport"><block var="return"/></block></script>
</block-definition>
</blocks>
6 changes: 3 additions & 3 deletions website/en/legal.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ <h2>Imprint </h2>
<h3>Information according to § 5 TMG and responsible for the content according to § 55 Abs. 2 RStV</h3>
<p>
Dr. Andreas Grillenberger<br />
Free University Berlin<br />
Didactics of Computer Science<br />
Queen Luise Street 24/26<br />
Freie Universität Berlin<br />
Computing Education Research Group<br />
Königin-Luise-Str. 24/26<br />
14195 Berlin<br />
</p>
<p>
Expand Down
63 changes: 63 additions & 0 deletions website/en/legal.html~
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!--#include file="/common/header.html"-->
<!--#include file="/common/logo-de.html"-->

<div class="row bg-light p-5">
<div class="col">
<h2>Imprint </h2>

<h3>Information according to § 5 TMG and responsible for the content according to § 55 Abs. 2 RStV</h3>
<p>
Dr. Andreas Grillenberger<br />
Free University Berlin<br />
Didactics of Computer Science<br />
Queen Luise Street 24/26<br />
14195 Berlin<br />
</p>
<p>
<strong>Contact</strong><br />
phone: +49 30 838 66103<br />
E-mail: [email protected]<br />
</p>

<h3>Conditions of use</h3>
<p>
Texts, images, graphics and the design of these Internet pages may be subject to copyright.
</p>
<p>
According to Section 5 of the German Copyright Act (UrhG), laws, ordinances, official decrees and announcements as well as decisions and officially written guidelines on decisions and other official works that have been published in the official interest for general information are not protected by copyright, with the proviso that the provisions on the prohibition of changes and the indication of sources in Section 62 (1) to (3) and Section 63 (1) and (2) UrhG shall apply mutatis mutandis.
</p>
<p>
As a private person you may use copyrighted material for private and other personal use within the scope of § 53 Copyright Act (UrhG). Reproduction or use of these pages or parts thereof in other electronic or printed publications and their publication is only permitted with our consent. On request, the persons responsible for the content will grant such permission. The reprinting and evaluation of press releases and speeches are generally permitted provided the source is acknowledged.
</p>
<p>
Furthermore, texts, images, graphics and other files may be subject in whole or in part to the copyright of third parties. The persons responsible for the content will also provide you with more detailed information on the existence of possible third-party rights, unless these rights have already been identified by corresponding references in the website.
</p>

<h3>Disclaimer</h3>
<p>
All information provided on this website has been compiled and checked to the best of our knowledge and belief. However, we cannot guarantee that the information provided is up-to-date, correct, complete or available at all times. A contractual relationship with the users of the Internet offer is not established.
</p>
<p>
We are not liable for damages resulting from the use of this website. This exclusion of liability does not apply insofar as the provisions of § 839 of the German Civil Code (liability for breach of official duty) are relevant. We are not liable for any damage caused by malware or the installation or use of software when calling up or downloading data.
</p>
<p>
As a service provider we are responsible according to § 7 Abs.1 TMG for our own contents on these pages according to the general laws. According to §§ 8 to 10 TMG, we are not obliged to monitor transmitted or stored third-party information or to investigate circumstances that indicate illegal activity.
</p>
<p>
Obligations to remove or block the use of information in accordance with general laws remain unaffected by this. A liability in this respect is however only possible from the time of knowledge of a concrete infringement. As soon as we become aware of such infringements, we will remove the content immediately.
</p>
<p>
The operator expressly reserves the right to change, supplement or delete individual web pages, web services or the entire offer without prior notice or to temporarily or permanently cease publication.
</p>

<h3>Liability for links</h3>
<p>
Our offer contains links to external websites of third parties on whose contents we have no influence. Therefore, we cannot assume any liability for these external contents. The respective provider or operator of the pages is always responsible for the contents of the linked pages. The linked pages were checked for possible legal infringements at the time of linking. Illegal contents were not recognisable at the time of linking.
</p>
<p>
However, a permanent control of the contents of the linked pages is not reasonable without concrete evidence of a violation of law. As soon as we become aware of any legal infringements, we will remove such links immediately.
</p>
</div>
</div>

<!--#include file="/common/footer.html"-->

0 comments on commit a2b6989

Please sign in to comment.