Skip to content

Commit

Permalink
starred repos feature
Browse files Browse the repository at this point in the history
  • Loading branch information
intika committed Mar 27, 2019
1 parent 39fdb85 commit 8463b49
Show file tree
Hide file tree
Showing 19 changed files with 34,298 additions and 214 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- My-Starhub: notification for new followers, un-follower, stars, un-star
- My-Starhub: global user statistics on activities and used languages
- My-Starhub: main user organization statistic
- My-Starhub: list search and filter starred repos
- Statistics: stars and releases downloads counter analytics
- Tools: github applications selection and listing
- Tools: mail finder, username and user-id converter, site preview and git downloader
Expand Down
32 changes: 32 additions & 0 deletions controllers/starred.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package controllers

import (
"net/http"

"github.com/Github-Web-Apps/Starhub/config"
"github.com/Github-Web-Apps/Starhub/shared/pages"
"github.com/gorilla/sessions"
)

// Starred ctrl
type Starred struct {
Base
}

// NewStarred ctrl
func NewStarred(
config config.Config,
session sessions.Store,
) *Starred {
return &Starred{
Base: Base{
config: config,
session: session,
},
}
}

// Handler handles /Downloads
func (ctrl *Starred) Handler(w http.ResponseWriter, r *http.Request) {
pages.Render(w, "starred", ctrl.sessionData(w, r))
}
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ func main() {
mux.Methods(http.MethodGet).Path("/profile").HandlerFunc(
controllers.NewProfile(config, session).Handler,
)
mux.Methods(http.MethodGet).Path("/startrack").HandlerFunc(
mux.Methods(http.MethodGet).Path("/starred").HandlerFunc(
controllers.NewStarred(config, session).Handler,
)
mux.Methods(http.MethodGet).Path("/startrack").HandlerFunc(
controllers.NewStartrack(config, session).Handler,
)
mux.Methods(http.MethodGet).Path("/downloads").HandlerFunc(
)
mux.Methods(http.MethodGet).Path("/downloads").HandlerFunc(
controllers.NewDownloads(config, session).Handler,
)
mux.Methods(http.MethodGet).Path("/tools").HandlerFunc(
)
mux.Methods(http.MethodGet).Path("/tools").HandlerFunc(
controllers.NewTools(config, session).Handler,
)
mux.Methods(http.MethodGet).Path("/apps").HandlerFunc(
)
mux.Methods(http.MethodGet).Path("/apps").HandlerFunc(
controllers.NewApps(config, session).Handler,
)
)
mux.Methods(http.MethodGet).Path("/schedule").HandlerFunc(
controllers.NewSchedule(config, session, store).Handler,
)
Expand Down
1 change: 1 addition & 0 deletions static/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h3 class="ui header">
</br>
</br>
- Watchub by <a class="ui" href="https://github.com/caarlos0" target="_blank">@caarlos0</a></br>
- Starhub by <a class="ui" href="https://github.com/hanula" target="_blank">@hanula</a></br>
- Startrack by <a class="ui" href="https://github.com/seladb" target="_blank">@seladb</a></br>
- Cookie-Notice by <a class="ui" href="https://github.com/AOEpeople" target="_blank">@AOEpeople</a></br>
- HTML-Preview by <a class="ui" href="https://github.com/niutech" target="_blank">@niutech</a></br>
Expand Down
46 changes: 30 additions & 16 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ <h3 class="ui header">Features:</h3>
- My-Starhub: notification for new followers, un-follower, stars, un-star</br>
- My-Starhub: global user statistics on activities and used languages</br>
- My-Starhub: main user organization statistic</br>
- My-Starhub: list search and filter starred repos</br>
- Statistics: stars and releases downloads counter analytics</br>
- Tools: github applications selection and listing</br>
- Tools: mail finder, username and user-id converter, site preview and git downloader</br>
Expand Down Expand Up @@ -615,35 +616,48 @@ <h3 style="text-align:center; margin-top:0px;">Your profile looks good!</h3>
</div>

<div class="ui padded segment">
<p style="text-align:center; font-size:17px;"><b>Github Profile Center</b></p>
<p style="text-align:center; font-size:17px;"><b>Starhub Profile Center</b></p>

<a class="ui primary small button" target="_blank" title="Github.com dashboard (open in new tab)" style="margin:1%; width:31%;" href="https://github.com/" >
<a class="ui primary small button" title="List search and filter my starred repos" style="margin:1%; width:31%;" href="/starred" >
<img src="" height="16" width="0" style="vertical-align:middle; margin-right:0px;">
<i class="github black icon" height="16" width="16" style="margin-right:5px"></i>
Github dashboard
Starred repos
</a>

<a class="ui primary small button" target="_blank" title="Starhub tools for github (open in new tab)" style="margin:1%; width:31%;" href="/tools" >
<img src="static/logo/logo-16.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Starhub tools
</a>
<a class="ui primary small button" target="_blank" title="Octobox.io (open in new tab)" style="margin:1%; width:31%;" href="https://octobox.io/login" >
<img src="static/logo/3rd/octobox.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Manage issues

<a class="ui primary small button" target="_blank" title="Starhub's applications listing (open in new tab)" style="margin:1%; width:31%;" href="/apps" >
<img src="" height="16" width="0" style="vertical-align:middle; margin-right:0px;">
<i class="star black icon" height="16" width="16" style="margin-right:5px"></i>
Apps listing
</a>
<a class="ui primary small button" target="_blank" title="Astralapp.com (open in new tab)" style="margin:1%; width:31%;" href="https://app.astralapp.com/auth/github" >
<img src="static/logo/3rd/astral.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Manage starred

</div>

<div class="ui padded segment">
<p style="text-align:center; font-size:17px;"><b>Github Tools Bookmarks</b></p>

<a class="ui primary small button" target="_blank" title="Github.com dashboard (open in new tab)" style="margin:1%; width:98%;" href="https://github.com/" >
<img src="" height="16" width="0" style="vertical-align:middle; margin-right:0px;">
<i class="github black icon" height="16" width="16" style="margin-right:5px"></i>
Github dashboard
</a>

<a class="ui primary small button" target="_blank" title="Ghuser.io (open in new tab)" style="margin:1%; width:31%;" href="https://ghuser.io/{{ .User.Login}}" >
<img src="static/logo/3rd/ghu.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Ghuser profile
</a>

<a class="ui primary small button" target="_blank" title="Starhub tools for github (open in new tab)" style="margin:1%; width:31%;" href="/tools" >
<img src="static/logo/logo-16.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Starhub tools
<a class="ui primary small button" target="_blank" title="Octobox.io (open in new tab)" style="margin:1%; width:31%;" href="https://octobox.io/login" >
<img src="static/logo/3rd/octobox.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Manage issues
</a>
<a class="ui primary small button" target="_blank" title="Starhub's applications listing (open in new tab)" style="margin:1%; width:31%;" href="/apps" >
<img src="" height="16" width="0" style="vertical-align:middle; margin-right:0px;">
<i class="star black icon" height="16" width="16" style="margin-right:5px"></i>
Apps listing
<a class="ui primary small button" target="_blank" title="Astralapp.com (open in new tab)" style="margin:1%; width:31%;" href="https://app.astralapp.com/auth/github" >
<img src="static/logo/3rd/astral.png" height="16" width="16" style="vertical-align:middle; margin-right:5px;">
Manage starred
</a>

</div>
Expand Down
24 changes: 16 additions & 8 deletions static/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
<div class="ui center aligned grid large secondary inverted pointing menu" >

<a class="item" href="/" title="Starhub" style="padding-bottom:9px;">
<object data="/static/logo/octocat.svg" type="image/svg+xml" style="height:27px;width:32px">
<img style="height:27px;width:27px;margin:0px" src="/static/logo/logo-32-white.png" />
</object>
<img src="/static/logo/logo-32-white.png" srcset="/static/logo/octocat.svg" style="height:27px;width:32px">
</a>

<a class="item" href="/" title="My profile (Stars, activity, followers, repositories, etc)">My Starhub</a>

<div class="ui simple dropdown item">
Starhub
<i class="dropdown icon"></i>
<div class="ui inverted grey menu" style="margin:0px;">
{{ if eq .User.ID 0 }}
<a class="item" href="/" title="Starhub.be">Home</a>
{{ end }}
<a class="item" href="/login" title="My profile (Stars, activity, followers, repositories, etc)">My Starhub</a>
<a class="item" href="/starred" title="My starred repositories">My Starred Repos</a>
</div>
</div>

<div class="ui simple dropdown item">
Statistics
Expand All @@ -47,16 +55,16 @@
Toolbox
<i class="dropdown icon"></i>
<div class="ui inverted grey menu" style="margin:0px;">
<a class="item" href="/apps" title="Github apps listing">Github Apps</a>
<a class="item" href="/tools#mail-finder" title="Find any user email">Github Mail Finder</a>
<a class="item" href="/profile" title="Starhub github's profile summary for any user">Github Profiler</a>
<a class="item" href="/apps" title="Github apps listing">Github Applications</a>
<a class="item" href="/tools#mail-finder" title="Find any user email">Github eMail Finder</a>
<a class="item" href="/tools#site-preview" title="Preview HTML files">Github Site Preview</a>
<a class="item" href="/tools#userid-converter" title="Convert user-id to username">Github User-ID Converter</a>
<a class="item" href="/tools#folder-downloader" title="Download any folder from a repo">Github Folder Downloader</a>
<a class="item" href="/tools#username-converter" title="Convert username to user-id">Github Username Converter</a>
</div>
</div>

<a class="item" href="/profile" title="Starhub github's profile summary for any user">Profiler</a>
<a class="item" href="/donate" title="Support us">Donate</a>
<a class="item" href="/contact" title="Contact, links, about and privacy policy">About</a>

Expand Down
183 changes: 1 addition & 182 deletions static/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ <h3 class="ui header" id="titleBox" style="visibility:hidden; height:0px; paddin

<div id="activityDiv" class="ui padded segment" style="text-align: center; visibility:hidden; height:0px; padding:0px; margin:0px;">

<script>
function tabClickSwitch (){
var activateMeTab = 'tabTitle1';
var activateMeDiv = 'tabDiv1';
var desactivateMeTab = 'tabTitle2';
var desactivateMeDiv = 'tabDiv2';
document.getElementById(activateMeTab).classList.toggle('active');
document.getElementById(activateMeDiv).classList.toggle('active');
document.getElementById(desactivateMeTab).classList.toggle('active');
document.getElementById(desactivateMeDiv).classList.toggle('active');
}
</script>

<div class="ui top attached tabular menu" onclick="tabClickSwitch()" style="height:30px; min-height:0px; margin-top:0px;">
<a class="item active" id="tabTitle1" data-tab="first" style="width:50%;padding:0px;height:30px;"><p style="text-align:center; margin:auto;">
Private Activity</p></a>
Expand Down Expand Up @@ -410,175 +397,7 @@ <h3 class="ui header" id="titleBox" style="visibility:hidden; height:0px; paddin

<link rel="stylesheet" href="static/resources/notifications/notifications.css" type="text/css">
<script src="static/resources/notifications/notifications.js" type="text/javascript"></script>
<script>

function showDiv(div){
document.getElementById(div).style.height = "";
document.getElementById(div).style.padding = "";
document.getElementById(div).style.margin = "";
document.getElementById(div).style.visibility = "visible";
}

function hideDiv(div){
document.getElementById(div).style.height = "0px";
document.getElementById(div).style.padding = "0px";
document.getElementById(div).style.margin = "0px";
document.getElementById(div).style.visibility = "hidden";
}

const myNotification = window.createNotification({
closeOnClick: true,
displayCloseButton: false,
//nfc-top-right
//nfc-top-left
//nfc-bottom-right
//nfc-bottom-left
positionClass: 'nfc-top-left',
onclick: false,
showDuration:5000,
// success, info, warning, error, and none
theme: 'info'
});

function checkUserIDandProceed (login) {
getIdFor(login, function(username, id) {
//alert(id);
//alert(login);
loadGlobal(login);
})
}

function getIdFor (username, callback) {
$.getJSON('https://api.github.com/users/' + username + "?callback=?", {},
function(json) {
var id = json["data"]["id"]
if (id) {callback(username, id)} else {
//$('#div2').hide();
//$('#div5').hide();
showDiv("titleBox");
showDiv("searchBox");
myNotification({message: 'Unknown github user, or limit reached',});
}
});
}

var usernameProf = window.location.pathname;
usernameProf = usernameProf[0] == '/' ? usernameProf.substr(1) : usernameProf;

$(document).ready(function() {

if ((usernameProf) && (usernameProf != 'profile')) {
checkUserIDandProceed(usernameProf);
} else {
//$('#div2').hide();
//$('#div5').hide();
showDiv("titleBox");
showDiv("searchBox");
}

});

function profile() {
var userInput = $("#username").val();
if (userInput) {
checkUserIDandProceed(userInput);
}
}

function loadScript(src){
var script = document.createElement('script');
script.onload = function () {
};
script.src = src;
document.head.appendChild(script);
}

function loadGlobal(user) {

showDiv("activityDiv");
//showDiv("div2");
//showDiv("div5");
//$('#div2').show();
//$('#div5').show();
showDiv("div3");
showDiv("div4");
showDiv("div6");
document.getElementById("activityDiv").style.height = "auto";
document.getElementById("activityDiv").style.visibility = "visible";

document.getElementById("github-language-distribution").innerHTML = "";
document.getElementById("github-contributions").innerHTML = "<div id='divGitStatLoader' class='ui active centered inline loader' style='height:0px; visibility:hidden;'></div>";
document.getElementById("gitWid").innerHTML = "";

document.getElementById("grapHref").href = "https://github.com/" + user;
document.getElementById("ghuserLink").href = "https://ghuser.io/" + user;

document.getElementById("iframeProfile").height = "350px";
document.getElementById("iframeProfile").src = "static/resources/github-id/?q=" + user;
document.getElementById("divGitStatLoader").style.height = "";
document.getElementById("divGitStatLoader").style.visibility = "visible";

document.getElementById("gitWid").innerHTML = "<div class='github-widget' style='width:550px; margin:auto;' data-username='" + user + "'></div>";

loadScript("static/resources/widgets/widget.js");

setTimeout(privLoadActi(pageBrowsePriv, '2', pageFilterPriv, user), 2000);
setTimeout(pubLoadActi(pageBrowsePub, '1', pageFilterPub, user), 2000);

(async () => {
const GITHUB_USERNAME = user;
const COMMITS_CONTAINER = '#github-contributions';
const LANGUAGES_CONTAINER = '#github-language-distribution';

const githubStats = await GithubStats(GITHUB_USERNAME);

let githubCommits = document.querySelector(COMMITS_CONTAINER);
/* Render SVG for commit contributions */
let commitsContribSVG = githubStats.commitsContribSVG({
rows: 7,
space: 2,
rectWidth: 8,
levelColors: [
{
minCommits: 0,
color: '#ebedf0'
},
{
minCommits: 1,
color: '#c6e48b'
},
{
minCommits: 9,
color: '#7bc96f'
},
{
minCommits: 17,
color: '#239a3b'
},
{
minCommits: 26,
color: '#196127'
}
]
});
githubCommits.appendChild(commitsContribSVG);

let githubLanguageDistribution = document.querySelector(LANGUAGES_CONTAINER);
/* Render SVG for language contributions */
let languageContribSVG = githubStats.languagesContribSVG({
barHeight: 20,
barWidth: githubLanguageDistribution.offsetWidth/2,
lineSpacing: 4,
languageNameWidth: 100,
fontSize: 14
});
githubLanguageDistribution.appendChild(languageContribSVG);
document.getElementById("divGitStatLoader").style.height = "0px";
document.getElementById("divGitStatLoader").style.visibility = "hidden";
})();
}

</script>
<script src="static/resources/profiler/profiler.js" type="text/javascript"></script>

</div>
</div>
Expand Down
Loading

0 comments on commit 8463b49

Please sign in to comment.