Better structure for static files

This commit is contained in:
Jesper Wrang 2017-11-04 20:03:15 +01:00
parent c2623432b4
commit 7281ca23d5
17 changed files with 41 additions and 46 deletions

View file

@ -1,23 +1,23 @@
# Removeddit
[Removeddit](https://removeddit.com) is a site for viewing removed comments from [Reddit](https://www.reddit.com).
[Removeddit](https://removeddit.com) is a site for viewing removed and deleted comments from [Reddit](https://www.reddit.com).
Usage: go to any reddit thread and change the `reddit` in the URL to `removeddit`.
The site will only display the removed comments and thier parents, not the full thread.
This is a done by comparing the comments found from Reddit API and comments from [Jason Baumgartners](https://pushshift.io/) [Pushshift Reddit API](https://github.com/pushshift/api). The frontend is written in pure Javascript (ES6). You can use this code however you want, as long as it's non-commercial.
This is a done by comparing the comments found from Reddit API and comments from [Jason Baumgartners](https://pushshift.io/) [Pushshift Reddit API](https://github.com/pushshift/api). The frontend is written with a fuckington of promises and some [Lodash](https://lodash.com/). You can use this code however you want, as long as it's non-commercial (and preferably open source).
# The "I just want to get this shit running" guide
Using [Ubuntu 16.04](http://releases.ubuntu.com/16.04/) and [nginx](https://www.nginx.com/resources/wiki/)
```
sudo git clone https://github.com/JubbeArt/removeddit.git /var/www/removeddit
sudo apt install -y nginx
sudo cp /var/www/removeddit/config/basic /etc/nginx/sites-available/default
sudo cp /var/www/removeddit/config/basic /etc/nginx/sites-available/default
```
Create a reddit app [here](https://www.reddit.com/prefs/apps/), select **installed app**. For "redirect url" it doesn't really matter in this case, you can pick `http://localhost`.
Copy the **client ID** for your app set it as a variable in `id.js`, e.g. with
```
sudo nano /var/www/removeddit/static/id.js
sudo nano /var/www/removeddit/static/js/id.js
# Insert with ctrl-shift-v
# Save with ctrl-o, exit with ctrl-x
```

View file

@ -7,8 +7,8 @@
<meta type="author" content="Jesper Wrang">
<meta name="google-site-verification" content="Hb7-KTi33kHkzQwP9_7s5DxecMN2xFctAm3e21fu4R0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/favicon.ico">
<link href="/static/css/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/images/favicon.ico">
</head>
<body>
<header id="header">

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View file

@ -4,9 +4,9 @@
var Status = (function(){
var loadingText = document.getElementById("loading-text");
var statusImage = document.getElementById("loading-image");
var loadingImg = "/static/loading.gif";
var successImg = "/static/done.png";
var errorImg = "/static/error.png";
var loadingImg = "/static/images/loading.gif";
var successImg = "/static/images/done.png";
var errorImg = "/static/images/error.png";
return {
loading: function(msg) {
@ -25,21 +25,19 @@ return {
loadingText.innerHTML = "<b>"+msg+"</b>"
console.error(msg)
}
}})()
}})();
// Check browser support
var isSupported = self.fetch && _ && self.Promise;
var isSupported = self.fetch && self._ && self.Promise;
if(!isSupported) {
console.log("isSupported",isSupported);
(function() {
var isMissing = [];
if(!self.fetch) isMissing.push("fetch");
if(!self.Promise) isMissing.push("promise");
if(!_) push("lodash");
if(!self._) isMissing.push("lodash");
var url = "https://www.reddit.com/message/compose/?to=Jubbeart";
url += "&subject="+encodeURIComponent("Missing dependencies: " + isMissing.join(" "));
@ -50,8 +48,6 @@ if(!isSupported) {
}
// Reddit API
var Reddit = (function() {
var init = {headers: {"Authorization": ""}};
@ -85,7 +81,7 @@ return {
})
}
}})()
}})();
// Helper functions for fetch
@ -119,7 +115,7 @@ return {
json: json
}})()
}})();
var URLs = (function(){
var reddit = "https://oauth.reddit.com";
@ -149,7 +145,7 @@ return {
tmpDiv.innerHTML = htmlString
return tmpDiv.childNodes.length === 0 ? "" : tmpDiv.childNodes[0].nodeValue
}
}})()
}})();
// For text formatting
@ -183,4 +179,4 @@ return {
prettyScore: function(score) {
return score >= 10000 ? (score / 1000).toFixed(1) + "k" : score;
}
}})()
}})();

View file

@ -82,7 +82,7 @@ return {
}
});
}
}})()
}})();
// ------------------------------------------------------------------------------
// ----------------------- Store and genrates comments --------------------------
@ -190,7 +190,7 @@ return {
ThreadHTML.createComments();
})
}
}})()
}})();
@ -246,7 +246,7 @@ var HandleIDs = (function(){
morechildren: morechildren,
removed: removed
};
})()
})();
// ------------------------------------------------------------------------------
@ -279,7 +279,7 @@ var Extract = (function(){
return {
normal: normal
};
})()
})();
// ------------------------------------------------------------------------------
@ -406,7 +406,7 @@ var ThreadHTML = (function(){
createCommentSection: createCommentSection,
createComments: createComments
}
})()
})();
if(isSupported) {
app.loadPage()

View file

@ -7,24 +7,23 @@
<meta type="author" content="Jesper Wrang">
<meta name="google-site-verification" content="Hb7-KTi33kHkzQwP9_7s5DxecMN2xFctAm3e21fu4R0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/favicon.ico">
<link href="/static/css/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/images/favicon.ico">
</head>
<body>
<header id="header">
<a href="/" id="header-title-link"><h1 id="header-title">Removeddit</h1></a>
<div id="loading">
<p id="loading-text"></p>
<img id="loading-image" src="/static/loading.gif"></img>
<img id="loading-image" src="/static/images/loading.gif"></img>
</div>
</header>
<div id="main"></div>
<script src="/static/lodash.min.js"></script>
<script src="/static/promise.min.js"></script>
<script src="/static/fetch.js"></script>
<script src="/static/id.js"></script>
<script src="/static/functions.js"></script>
<script src="/static/subreddit.js"></script>
<script src="/static/js/libraries/lodash.min.js"></script>
<script src="/static/js/polyfills/promise.min.js"></script>
<script src="/static/js/polyfills/fetch.js"></script>
<script src="/static/js/id.js"></script>
<script src="/static/js/functions.js"></script>
<script src="/static/js/subreddit.js"></script>
</body>
</html>
</html>

View file

@ -7,24 +7,24 @@
<meta type="author" content="Jesper Wrang">
<meta name="google-site-verification" content="Hb7-KTi33kHkzQwP9_7s5DxecMN2xFctAm3e21fu4R0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/static/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/favicon.ico">
<link href="/static/css/style.css" rel="stylesheet">
<link rel="shotcut icon" href="/static/images/favicon.ico">
</head>
<body>
<header id="header">
<a href="/" id="header-title-link"><h1 id="header-title">Removeddit</h1></a>
<div id="loading">
<p id="loading-text"></p>
<img id="loading-image" src="/static/loading.gif"></img>
<img id="loading-image" src="/static/images/loading.gif"></img>
</div>
</header>
<div id="main"></div>
<script src="/static/snuownd.js"></script>
<script src="/static/lodash.min.js"></script>
<script src="/static/promise.min.js"></script>
<script src="/static/fetch.js"></script>
<script src="/static/id.js"></script>
<script src="/static/functions.js"></script>
<script src="/static/thread.js"></script>
<script src="/static/js/libraries/snuownd.js"></script>
<script src="/static/js/libraries/lodash.min.js"></script>
<script src="/static/js/polyfills/promise.min.js"></script>
<script src="/static/js/polyfills/fetch.js"></script>
<script src="/static/js/id.js"></script>
<script src="/static/js/functions.js"></script>
<script src="/static/js/thread.js"></script>
</body>
</html>