1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-22 04:40:09 +01:00

License page: suggest the license to a repository

This commit is contained in:
Felipe Lube de Bragança 2018-10-09 18:27:26 +00:00
parent 3e59b04824
commit 8f177d9c77
5 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,7 @@
<script src="/assets/vendor/jquery/jquery.min.js"></script>
<script src="/assets/vendor/qtip2/jquery.qtip.min.js"></script>
<script src="/assets/vendor/clipboard/dist/clipboard.min.js"></script>
<script src="/assets/vendor/javascript-auto-complete/auto-complete.min.js"></script>
<script>
window.annotations = {{ site.data.rules | jsonify }};
</script>

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Chivo:900">
<link rel="stylesheet" href="/assets/css/application.css?v={{ site.github.build_revision }}">
<link rel="stylesheet" href="/assets/vendor/javascript-auto-complete/auto-complete.css">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<!--[if lt IE 9]>
<script src="/assets/vendor/html5shiv/dist/html5shiv.js"></script>

View File

@ -1,6 +1,8 @@
<div class="sidebar">
<a href="#" data-clipboard-target="#license-text" data-proofer-ignore="true" class="js-clipboard-button button">Copy license text to clipboard</a>
<h3>Suggest this license</h3>
<input type="text" data-license-id="{{ page.spdx-id }}" placeholder="Type a project name" id="reposiory-search" />
<div class="how-to-apply">
<h3>How to apply this license</h3>

View File

@ -294,6 +294,11 @@ strong {
width: 100%;
}
.sidebar input#reposiory-search {
width: 100%;
padding: 5px 10px;
}
.note {
color: #687072;
}

View File

@ -31,6 +31,7 @@ class Choosealicense
constructor: ->
@initTooltips()
@initClipboard()
@initAutocomplete()
# Init tooltip action
initTooltips: ->
@ -71,5 +72,25 @@ class Choosealicense
clipboardComplete: (client, args) ->
@textContent = "Copied!"
# Initializes JavaScript-autoComplete plugin
initAutocomplete: ->
new autoComplete {
selector: "#reposiory-search",
delay: 300,
source: (term, response) ->
$.getJSON "https://api.github.com/search/repositories", {q: term}, (data) ->
if data and data.total_count > 0
response (data.items
.filter (item) -> item.archived == false && !item.license
.map (item) -> item.full_name)
else
response([])
onSelect: (event, repository, item) ->
licenseId = event.target.getAttribute("data-license-id")
if licenseId
window.open 'https://github.com/'+repository+'/community/license/new?template='+licenseId
else
window.open 'https://github.com/'+repository+'/community/license/new'
}
$ ->
new Choosealicense()