Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from nicolasrlewis/issue20
Browse files Browse the repository at this point in the history
Changes to address issue #20
  • Loading branch information
Fulton Browne committed Oct 7, 2019
2 parents 8f01fa9 + 6e08b23 commit 979bb85
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 55 deletions.
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
<h1 align="center">Welcome to Ara's server👋</h1>
By Andromeda Software


> The server that supports the ara voice assistant!

![alt text](docs/scrs1.png)




[![Known Vulnerabilities](https://snyk.io/test/github/FultonBrowne/Ara-Server/badge.svg)](https://snyk.io/test/github/FultonBrowne/Ara-Server})
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ede27c2ee51e43fbbc4667c4abc19118)](https://www.codacy.com/app/FultonBrowne/Ara-Server?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=FultonBrowne/Ara-Server&amp;utm_campaign=Badge_Grade)



## Author

👤 **Fulton Browne**

* Github: [@FultonBrowne](https://github.com/FultonBrowne)
* Github: [@FultonBrowne](https://github.com/FultonBrowne)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/andromeda-software/Ara-server/issues).
If you contribute please commit to a new branch and explain details in your pull request not in your commit.


[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/fultonbrowne/ara-server)


If you want to become an active contributor go [here](https://findcollabs.com/project/RRBNiqp3CQVNFGTsHWQn).


## Show your support

Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2019 [Fulton Browne](https://github.com/fultonbrowne).<br />
This project is [ GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) licensed.
This project is [GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) licensed.

***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
14 changes: 14 additions & 0 deletions bin/main/com/andromeda/araserver/GetUrl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.andromeda.araserver

/**
* TBC
*/
object getUrl {
/**
* TBC
*/
fun getUrl1() {
var changeme = "TBC changeMe"
}

}
12 changes: 10 additions & 2 deletions bin/main/com/andromeda/araserver/RssMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ import java.io.IOException
import java.net.URL
import java.util.*

/**
* Object used to handle RSS Feeds.
*/
object RssMain {
//Exceptions Throne
/**
* Main Function. Returns feeds based on the passed in mode.
* @param mode the specify the type of feeds to return.
* @return The SyndFeed containing the feeds.
* @throws IOException
* @throws FeedException
*/
@Throws(IOException::class, FeedException::class)
//Main Function
fun rssMain1(mode: Int): SyndFeed {
//Feed link text
val feeds = arrayOfNulls<String>(2)
Expand Down
9 changes: 8 additions & 1 deletion bin/main/com/andromeda/araserver/Update.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* Class used to for running update from beta testers.
*/
package com.andromeda.araserver

class Update {
//the code used for running update from beta testers
/**
* Function used for running update from beta testers.
* @param ver version string.
* @return String.
*/
fun update(ver: String): String {
//Remove the "/update from the uri
val ver1 = ver.removeRange(0, 8)
Expand Down
6 changes: 0 additions & 6 deletions bin/main/com/andromeda/araserver/getUrl.kt

This file was deleted.

12 changes: 6 additions & 6 deletions src/main/java/com/andromeda/araserver/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.andromeda.araserver.pages.Update;
import com.andromeda.araserver.skills.Hello;
import com.andromeda.araserver.pages.RssMain;
import com.andromeda.araserver.pages.apiStart;
import com.andromeda.araserver.pages.ApiStart;
import com.andromeda.araserver.skills.GetInfo;
import com.andromeda.araserver.skills.equations;
import com.andromeda.araserver.skills.locdec;
import com.andromeda.araserver.skills.Equations;
import com.andromeda.araserver.skills.Locdec;
import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.SyndFeedOutput;
Expand Down Expand Up @@ -70,18 +70,18 @@ public NanoHTTPD.Response serve(NanoHTTPD.IHTTPSession session) {
String main2 = "err";
//Functions related to the search api
//Start API function
if (sessionUri.startsWith("/api")) main2 = new apiStart().apiMain(sessionUri);
if (sessionUri.startsWith("/api")) main2 = new ApiStart().apiMain(sessionUri);
//Start the Hello function
else if (sessionUri.startsWith("/hi")) main2 = new Hello().hello();
else if (sessionUri.startsWith("/yelpclient")) main2 = new locdec().main(sessionUri);
else if (sessionUri.startsWith("/yelpclient")) main2 = new Locdec().main(sessionUri);
else if (sessionUri.startsWith("/search")) {
try {
main2 = new GetInfo().main(sessionUri);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
else if (sessionUri.startsWith("/math")) main2 = new equations().main(sessionUri);
else if (sessionUri.startsWith("/math")) main2 = new Equations().main(sessionUri);
else if (sessionUri.startsWith("/update")) main2 = new Update().update(sessionUri);
else {
// if getting RSS info set tag value this will be used to get the correct feed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Scanner;


public class apiStart {
public class ApiStart {
//output to be printed if error
private ArrayList<OutputModel> outputModels = new ArrayList<>();
//output from DB
Expand Down Expand Up @@ -67,7 +67,7 @@ private String ParseApi(String search) {
//print errors
e.printStackTrace();
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
return new Gson().toJson(outputModels);
}
System.out.println("Opened database successfully");
System.out.println(search);
Expand All @@ -81,14 +81,14 @@ private String ParseApi(String search) {
linkval = sqlModel.link + "/" + search.replace(sqlModel.description, "");
break;
}
if (term.endsWith(sqlModel.title) && !sqlModel.title.equals("")) {
if (!"".equals(sqlModel.title) && term.endsWith(sqlModel.title)) {
linkval = sqlModel.link + "/" + search.replace(sqlModel.title, "");

break;
}
}
// parse to avoid errors
if (!(linkval == null)) if (linkval.contains(" "))
if (linkval != null && linkval.contains(" "))
linkval = linkval.replace(" ", "");
System.out.println(linkval);
String url = linkval;
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/andromeda/araserver/pages/RssMain.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.andromeda.araserver.pages

import com.andromeda.araserver.util.sort
import com.andromeda.araserver.util.Sort
import com.rometools.rome.feed.synd.SyndEntry
import com.rometools.rome.feed.synd.SyndFeed
import com.rometools.rome.feed.synd.SyndFeedImpl
Expand All @@ -13,10 +13,18 @@ import java.io.IOException
import java.net.URL
import java.util.*

/**
* Object used to handle RSS Feeds.
*/
object RssMain {
//Exceptions Throne
/**
* Main Function. Returns feeds based on the passed in mode.
* @param mode the specify the type of feeds to return.
* @return The SyndFeed containing the feeds.
* @throws IOException
* @throws FeedException
*/
@Throws(IOException::class, FeedException::class)
//Main Function
fun rssMain1(mode: Int): SyndFeed {
//Feed link text
val feeds = arrayOfNulls<String>(2)
Expand Down Expand Up @@ -76,7 +84,7 @@ object RssMain {

}
//sort and reverse
sortedEntries.addAll(sort().sortDateSyndEntry(entries))
sortedEntries.addAll(Sort().sortDateSyndEntry(entries))
feed.entries = sortedEntries.reversed()
//return the value
return feed
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/andromeda/araserver/pages/Update.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

package com.andromeda.araserver.pages

/**
* Class used to for running update from beta testers.
*/
class Update {
//the code used for running update from beta testers
/**
* Function used for running update from beta testers.
* @param ver version string.
* @return String.
*/
fun update(ver: String): String {
//Remove the "/update from the uri
val ver1 = ver.removeRange(0, 8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.util.ArrayList;

public class equations {
public class Equations {
public String main(String mainurl) {
//new Gson instance
Gson gson = new Gson();
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/andromeda/araserver/skills/GetInfo.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.andromeda.araserver.skills;

import com.andromeda.araserver.util.OutputModel;
import com.andromeda.araserver.util.url;
import com.andromeda.araserver.util.Url;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand All @@ -13,7 +13,6 @@

public class GetInfo {
public String main(String mainurl) throws MalformedURLException {
Boolean try1 = true;
//new gson instance
Gson gson = new Gson();
//place holder values
Expand All @@ -26,7 +25,7 @@ public String main(String mainurl) throws MalformedURLException {
"&titles=" + "apple");
URL url = new URL(urlText);
//parse the json
JsonElement jelement = new JsonParser().parse(new url().main(url));
JsonElement jelement = new JsonParser().parse(new Url().main(url));
System.out.println(jelement);
JsonObject jobject = jelement.getAsJsonObject();
jobject = jobject.getAsJsonObject("query");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import java.util.Arrays;


public class locdec {
String log;
String lat;
String term;
public class Locdec {
private String log;
private String lat;
private String term;

public String main(String search) {
//get api params
Expand All @@ -31,7 +31,7 @@ public String main(String search) {
return new Gson().toJson(yelpSearch());
}

ArrayList<OutputModel> yelpSearch() {
private ArrayList<OutputModel> yelpSearch() {
//new array list for out put
ArrayList<OutputModel> returedval = new ArrayList<>();
// http client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.Comparator;

public class sort {
public class Sort {
//sort Rss data
public ArrayList<SyndEntry> sortDateSyndEntry(ArrayList<SyndEntry> tosort) {
//sort by date
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/andromeda/araserver/util/Url.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.andromeda.araserver.util

import java.net.URL

/**
* Class used to return URL string.
*/
class Url {
/**
* Returns the entire content from the url.
* @param url URL that to obtain content from.
* @return The entire content of the URL as a String as UTF-8.
*/
fun main(url: URL): String {
return url.readText()
}
}
9 changes: 0 additions & 9 deletions src/main/java/com/andromeda/araserver/util/url.kt

This file was deleted.

0 comments on commit 979bb85

Please sign in to comment.