Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community/: Add a webpage for Listing Issues #291

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
de15cb2
Sync Moban
KVGarg Aug 4, 2019
6e9765d
data/: Update Contributor model
KVGarg Jun 8, 2019
c6afccd
.coafile: Ignore openhub module
KVGarg Jun 10, 2019
ab5e860
tests/: Remove dependency of testusers'
Jun 25, 2019
dc36c9f
travis.yml: Install Python v3.6.3
KVGarg Jul 30, 2019
c81d98c
git.py: CI build pass
KVGarg Feb 11, 2019
7f2877a
Enhance the community website homepage
KVGarg Jun 7, 2019
8323939
ci_build/: Re-design build-logs webpage
KVGarg Jun 9, 2019
6bc955e
gci/: Redesign gci students web-page
KVGarg Jun 12, 2019
0746873
data/: Re-design the contributors webpage
KVGarg Jun 13, 2019
c2f5c96
meta-review/: Redesign the webpage
KVGarg Jun 14, 2019
686c2d3
gamification/: Redesign the webpage
KVGarg Jun 14, 2019
5158608
Add netlify-OAuth
KVGarg Jul 11, 2019
41c5e35
community/: Add a joining netlify form
KVGarg Jul 20, 2019
a012693
community/: Display contributor statistics
KVGarg Jul 28, 2019
e05a821
community/: Add a form for uploading google forms
KVGarg Jul 31, 2019
7274277
community/: Add a form for adding calendar events
KVGarg Jul 31, 2019
e94bc5c
community/: Add a form for applying as a mentor
KVGarg Jul 31, 2019
6048e0e
community/: Add a form for adding a gsoc student
KVGarg Jul 31, 2019
e9dd16a
community/: Add a request form to assign issue
KVGarg Aug 1, 2019
7714d9e
community/: Add a newcomer promotion request form
KVGarg Aug 1, 2019
bfbc9c1
community/: Add a feedback form
KVGarg Aug 1, 2019
577b609
Remove openhub and model apps
Jun 28, 2019
8daed65
openhub/: Use openhub_django pypi package
Jun 28, 2019
6fe3e7f
community/: Display org teams
KVGarg Aug 2, 2019
9922faf
community/: Add a webpage for Listing Issues
KVGarg Aug 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add netlify-OAuth
The contributor can sign-in with either
GitHub or GitLab account provided the
user is member of the organization. The
validation is being performed via a http
request which accepts the access_token
retrieved from the netlify o-authentication.

Closes #262
KVGarg committed Aug 5, 2019
commit 51586083980cacc73c5340355f1462b25ffdbffc
2 changes: 1 addition & 1 deletion .coafile
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ shell = bash
# for use by other organizations.
files = **
# .coverage crashes AnnotationBear
ignore += .coafile, *requirements.txt, .travis.yml, LICENSE, .nocover.yaml, .moban.yaml, .moban.dt/community-*.jj2, public/**, _site/**, .ci/check_moban.sh, .coverage
ignore += .coafile, *requirements.txt, .travis.yml, LICENSE, .nocover.yaml, .moban.yaml, .moban.dt/community-*.jj2, public/**, _site/**, .ci/check_moban.sh, .coverage, static/js/main.js
bears = KeywordBear
language = python 3
keywords = coala
70 changes: 70 additions & 0 deletions static/css/main.css
Original file line number Diff line number Diff line change
@@ -23,6 +23,13 @@ body {
cursor: pointer;
}

.close-form {
justify-content: end;
padding: 10px 10px 0 0;
font-size: 1.5em;
cursor: pointer;
}

.custom-green-color-font {
color: #2d5d13
}
@@ -39,6 +46,23 @@ body {
color: #37474f;
}

.error-message {
background-color: #d57c7b;
color: white;
margin: 0 10px;
padding: 5px 10px;
}

.form-popup {
width: 100%;
height: 100%;
justify-content: center;
display: none;
opacity:.95;
z-index: 1002;
position:fixed;
}

footer .footer-icons {
display: flex;
flex-wrap: wrap;
@@ -59,6 +83,14 @@ footer .social-buttons {
font-size: larger;
}

.login-form {
width: 30%;
min-width: 340px;
background-color: white;
box-shadow: 0 -5px 15px black;
margin: 5em auto;
}

.main-content {
background-color: #edf5af;
padding-bottom: 3%;
@@ -76,10 +108,44 @@ nav .brand-logo img {
width: 60px;
}

.netlify-image {
min-width:133px;
width: 50%;
}

.nav-menu-font-size,
.sidenav .nav-menu-font-size {
font-size: 20px;
}

.oauth-error {
display: none;
}

.oauth-providers {
justify-content: center;
flex-direction: column;
}

.oauth-providers a{
margin: 0.5em;
font-weight: bold;
width: 80%;
}

.organizations {
justify-content: center;
}

.org-logo {
min-width: 133px;
width: 35%;
}

.organizations img {
padding: 10px;
}

p {
font-size: medium;
}
@@ -144,6 +210,10 @@ p {
list-style: none;
}

#user-dropdown li.user-logout {
display: none;
}

.web-page-details {
width: 100%;
}
98 changes: 98 additions & 0 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/* globals Cookies, netlify */
$(document).ready(function(){

var login_user_el = $('.login-user');
var logout_user_el = $('.user-logout');

function activate_dropdown(){
if ($('nav').width() < 992 ){
$(".dropdown-trigger-sidenav").dropdown({coverTrigger: false});
@@ -10,8 +15,76 @@ $(document).ready(function(){
}
}

function check_user_authenticated_or_not() {
if(Cookies.get('authenticated')){
modify_html_elements('none', 'none', 'block');
}
}

function get_error_message(oauth_provider, err){
return 'Error Authenticating with ' + oauth_provider + '. ' + err +
'. Please try again later!';
}

function display_error_message(oauth_provider, error_info) {
$('.error-message').text(get_error_message(oauth_provider, error_info));
$('.oauth-error').css('display', 'block');
}

function modify_html_elements(popup_form_display, login_option_display,
logout__option_display) {
$('.form-popup').css('display', popup_form_display);
login_user_el.css('display', login_option_display);
logout_user_el.css('display', logout__option_display);
}

function manipulate_web_page_data(oauth_provider, http_response_text) {
var json_data = JSON.parse(http_response_text);
if (json_data.valid) {
// Cookies expires in 3 days
Cookies.set('authenticated', true, {expires: 3});
Cookies.set('username', json_data.user, {expires: 3});
modify_html_elements('none', 'none', 'block');
}
else {
display_error_message(oauth_provider, json_data.message);
}
}

function validate_user(oauth_provider, access_token){
var url = 'https://webservices.coala.io/'+ oauth_provider + '/' +
access_token +'/validate';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
manipulate_web_page_data(oauth_provider, this.responseText);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}

function login_with(oauth_provider){
var authenticator = new netlify.default({});
authenticator.authenticate(
{
provider:oauth_provider,
scope: oauth_provider==='github'?"user":"api"
}, function(err, data) {
if(err){
display_error_message(oauth_provider, err);
}
else {
validate_user(data.provider, data.token);
}
}
);
}

activate_dropdown();

check_user_authenticated_or_not();

$('.sidenav').sidenav();
$('select').formSelect();

@@ -20,4 +93,29 @@ $(document).ready(function(){
});

$('#current-year').html(new Date().getFullYear());

login_user_el.click(function () {
$('.form-popup').css('display', 'block');
});

$('.close-form').click(function () {
$('.form-popup').css('display', 'none');
$('.oauth-error').css('display', 'none');
});

logout_user_el.click(function () {
Cookies.remove('authenticated');
Cookies.remove('username');
modify_html_elements('none', 'block','none');
});

$('.login-with-github').click(function(e) {
e.preventDefault();
login_with('github');
});

$('.login-with-gitlab').click(function(e) {
e.preventDefault();
login_with('gitlab');
});
});
32 changes: 31 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@

<script src="//code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<!-- Nelify's authentiation library -->
<script src="//unpkg.com/netlify-auth-providers"></script>
<script src="//cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script src="{% static 'js/main.js' %}"></script>
{% block add_js_files %}{% endblock %}

@@ -81,9 +84,36 @@
</ul>

<ul id="user-dropdown" class="dropdown-content">
<li><a href="#">Login</a></li>
<li class="login-user"><a>Login</a></li>
<li class="user-logout"><a>Logout</a></li>
</ul>

<div class="apply-flex form-popup">
<div class="login-form">
<div class="apply-flex close-form">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
<div class="oauth-error">
<p class="error-message"></p>
</div>
<span class="apply-flex organizations">
<img src="{{ org.logo_url }}" class="org-logo" alt="org-logo">
<i class="fa fa-plus" aria-hidden="true"></i>
<img src="//flaviocopes.com/netlify/banner.png" class="netlify-image" alt="netlify-logo">
</span>
<div class="apply-flex oauth-providers">
<a class="waves-effect waves-light btn-large login-with-github">
<i class="fa fa-github left" aria-hidden="true"></i>
Login with GitHub
</a>
<a class="waves-effect waves-light btn-large login-with-gitlab">
<i class="fa fa-gitlab left" aria-hidden="true"></i>
Login with GitLab
</a>
</div>
</div>
</div>

<div class="main-content">
{% block main-content %}
{% endblock %}