add/del author
This commit is contained in:
parent
5b68b0a0ad
commit
ee3f06c64c
|
@ -180,7 +180,7 @@
|
|||
(list email)
|
||||
empty empty
|
||||
(list "Someone tried to register your email address for an account on the Racket Package Catalog."
|
||||
"If you want to proceed, use this email code:"
|
||||
"If you want to proceed, use this code:"
|
||||
""
|
||||
correct-email-code
|
||||
""
|
||||
|
@ -229,6 +229,20 @@
|
|||
['tag tag])
|
||||
#f)
|
||||
|
||||
;; XXX
|
||||
(define-jsonp/auth
|
||||
(jsonp/package/author/add
|
||||
['pkg pkg]
|
||||
['author author])
|
||||
#f)
|
||||
|
||||
;; XXX
|
||||
(define-jsonp/auth
|
||||
(jsonp/package/author/del
|
||||
['pkg pkg]
|
||||
['author author])
|
||||
#f)
|
||||
|
||||
;; XXX
|
||||
(define-jsonp/auth
|
||||
(jsonp/package/curate
|
||||
|
@ -250,6 +264,8 @@
|
|||
[("jsonp" "package" "version" "del") jsonp/package/version/del]
|
||||
[("jsonp" "package" "tag" "add") jsonp/package/tag/add]
|
||||
[("jsonp" "package" "tag" "del") jsonp/package/tag/del]
|
||||
[("jsonp" "package" "author" "add") jsonp/package/author/add]
|
||||
[("jsonp" "package" "author" "del") jsonp/package/author/del]
|
||||
[("jsonp" "package" "curate") jsonp/package/curate]
|
||||
[("api" "upload") #:method "post" api/upload]
|
||||
[else redirect-to-static]))
|
||||
|
@ -257,7 +273,9 @@
|
|||
(define (go port)
|
||||
(printf "launching on port ~a\n" port)
|
||||
(serve/servlet
|
||||
main-dispatch
|
||||
(λ (req)
|
||||
(displayln (url->string (request-uri req)))
|
||||
(main-dispatch req))
|
||||
#:command-line? #t
|
||||
#:listen-ip #f
|
||||
#:ssl? #t
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<tr><td>Package Name:</td><td><span id="pi_name"></span></td></tr>
|
||||
<tr><td>Ring:</td><td><span id="pi_ring"></span></td></tr>
|
||||
<tr><td>Authors:</td><td><span id="pi_authors"></span></td></tr>
|
||||
<tr id="pi_add_author_row"><td></td><td><input type="text" id="pi_add_author_text" class="text ui-widget-content ui-corner-all" /><button id="pi_add_author_button">Add Author</button></td></tr>
|
||||
<tr><td>Source:</td><td><span id="pi_source"></span></td></tr>
|
||||
<tr><td>Checksum:</td><td><span id="pi_checksum"></span></td></tr>
|
||||
<tr><td>Last Updated:</td><td><span id="pi_last_updated"></span></td></tr>
|
||||
|
|
|
@ -36,7 +36,7 @@ $( document ).ready(function() {
|
|||
var active_info = false;
|
||||
var target_pkg = false;
|
||||
function update_info( pkgi ) {
|
||||
console.log( pkgi );
|
||||
// console.log( pkgi );
|
||||
change_hash( "[" + pkgi['name'] + "]" );
|
||||
|
||||
var mypkg_p = ($.inArray(me(), pkgi['authors'] ) != -1);
|
||||
|
@ -48,11 +48,18 @@ $( document ).ready(function() {
|
|||
|
||||
$( "#pi_name_inst" ).text( pkgi['name'] );
|
||||
$( "#pi_ring" ).text( pkgi['ring'] );
|
||||
// xxx show add/delete buttons
|
||||
$( "#pi_authors" ).html("")
|
||||
.append( $.map( pkgi['authors'],
|
||||
function ( author, i ) {
|
||||
return [author, " "]; } ) )
|
||||
if ( mypkg_p && author != me() ) {
|
||||
return [ author, jslink( "[x]", function () { submit_remove_author(author); }),
|
||||
" "]; }
|
||||
else {
|
||||
return [author, " "]; }} ) );
|
||||
if ( mypkg_p ) {
|
||||
$( "#pi_add_author_row" ).show(); }
|
||||
else {
|
||||
$( "#pi_add_author_row" ).hide(); }
|
||||
|
||||
$( "#pi_source" ).html( $('<a>', { text: pkgi['source'],
|
||||
href: pkgi['source_url'] } ));
|
||||
|
@ -70,13 +77,12 @@ $( document ).ready(function() {
|
|||
// xxx make this button do something
|
||||
$( "#pi_description" ).append( $('<button>').button({ icons: { primary: "ui-icon-pencil" } }) ); }
|
||||
|
||||
if ( mypkg_p ) {
|
||||
($( "#pi_tags" ).html("").append( $.map( pkgi['tags'], function ( tag, i ) {
|
||||
($( "#pi_tags" ).html("").append( $.map( pkgi['tags'], function ( tag, i ) {
|
||||
if ( mypkg_p ) {
|
||||
return [ tag, jslink( "[x]", function () { submit_remove_tag(tag); }),
|
||||
" "]; } ) )); }
|
||||
else {
|
||||
($( "#pi_tags" ).html("").append( $.map( pkgi['tags'], function ( tag, i ) {
|
||||
return [tag, " "]; } ) )); }
|
||||
" "]; }
|
||||
else {
|
||||
return [tag, " "]; } } ) ));
|
||||
|
||||
// xxx show add and delete buttons
|
||||
$( "#pi_versions" ).html("").append( $.map( pkgi['versions'], function ( vo, v ) {
|
||||
|
@ -112,6 +118,31 @@ $( document ).ready(function() {
|
|||
if (e.which == 13) { submit_add_tag (); } } );
|
||||
$( "#pi_add_tag_button" ).click( function (e) { submit_add_tag (); } );
|
||||
|
||||
function submit_remove_author ( author ) {
|
||||
dynamic_pkgsend( "/jsonp/package/author/del", { author: author } );
|
||||
|
||||
var author_index = $.inArray(author, active_info['authors']);
|
||||
active_info['authors'].splice( author_index, 1 );
|
||||
delete active_info['search-terms'][ "author:" + author ];
|
||||
evaluate_search();
|
||||
|
||||
update_info( active_info ); }
|
||||
function submit_add_author () {
|
||||
var it = $( "#pi_add_author_text" );
|
||||
var author = it.val();
|
||||
it.val("");
|
||||
|
||||
dynamic_pkgsend( "/jsonp/package/author/add", { author: author } );
|
||||
|
||||
active_info['authors'].push( author );
|
||||
active_info['search-terms'][ "author:" + author ] = true;
|
||||
evaluate_search();
|
||||
|
||||
update_info( active_info ); }
|
||||
$( "#pi_add_author_text" ).keypress( function (e) {
|
||||
if (e.which == 13) { submit_add_author (); } } );
|
||||
$( "#pi_add_author_button" ).click( function (e) { submit_add_author (); } );
|
||||
|
||||
var search_terms = { };
|
||||
|
||||
function clear_terms () {
|
||||
|
@ -154,7 +185,8 @@ $( document ).ready(function() {
|
|||
// thing, particularly with the Back button because we
|
||||
// don't add the tags in the same order the user add them
|
||||
// in. We could do that though.
|
||||
console.log("hash changed beneath me!"); } });
|
||||
// console.log("hash changed beneath me!");
|
||||
return 42; } });
|
||||
|
||||
function filterlink ( text, tclass, f ) {
|
||||
return [ jslink(text, f).addClass(tclass), " " ]; };
|
||||
|
|
Loading…
Reference in New Issue
Block a user