Fixing some S3/gzip stuff and add package removal

This commit is contained in:
Jay McCarthy 2013-10-14 14:30:23 -06:00
parent 01fdd9bc0e
commit 3f8cd3fde3
5 changed files with 45 additions and 30 deletions

View File

@ -49,9 +49,11 @@
(hash-ref pkg-info key
(λ ()
(match key
[(or 'author 'checksum 'source)
[(or 'author 'source)
(error 'pkg "Package ~e is missing a required field: ~e"
(hash-ref pkg-info 'name) key)]
['checksum
""]
['ring
2]
['checksum-error

View File

@ -331,6 +331,16 @@
[else
#f]))))
(define-jsonp/auth
(jsonp/package/del
['pkg pkg])
(ensure-package-author
pkg
(λ ()
(package-remove! pkg)
(signal-static! empty)
#f)))
(define-jsonp/auth
(jsonp/package/curate
['pkg pkg]
@ -363,6 +373,7 @@
(dispatch-rules
[("jsonp" "authenticate") jsonp/authenticate]
[("jsonp" "update") jsonp/update]
[("jsonp" "package" "del") jsonp/package/del]
[("jsonp" "package" "modify") jsonp/package/modify]
[("jsonp" "package" "version" "add") jsonp/package/version/add]
[("jsonp" "package" "version" "del") jsonp/package/version/del]
@ -384,6 +395,7 @@
(λ ()
(forever
(sleep (* 24 60 60))
(printf "Running scheduled update.\n")
(signal-update! empty))))
(serve/servlet
main-dispatch

View File

@ -7,45 +7,37 @@
racket/match
"common.rkt")
(define (make-parent-directory* p)
(make-directory* (path-only p)))
(define s3-config (build-path (find-system-path 'home-dir) ".s3cfg-plt"))
(define s3-bucket "pkgs.racket-lang.org")
(define static.gz-path (path-add-suffix static-path ".gz"))
(define s3cmd-path (find-executable-path "s3cmd"))
(define (upload-all)
(define root (simple-form-path static-path))
(gzip (format "~a/pkgs-all.json" static-path)
(format "~a/pkgs-all.json.gz" static-path))
(for ([f (in-directory root)]
#:when (file-exists? f))
(define f.time (file-or-directory-modify-seconds f))
(define rf (find-relative-path root f))
(define gf (build-path static.gz-path rf))
(make-parent-directory* gf)
(define g.time
(if (file-exists? gf)
(file-or-directory-modify-seconds gf)
-inf.0))
(when (> f.time g.time)
(printf "gzipping ~a\n" f)
(gzip f gf)))
(system* s3cmd-path
"-c" s3-config
"sync"
"-m" "application/javascript"
"--acl-public"
"--add-header" "Content-Encoding: gzip"
"--delete-removed"
(format "~a/pkgs-all.json.gz" static-path)
(format "s3://~a/pkgs-all.json.gz" s3-bucket))
(system* s3cmd-path
"-c" s3-config
"sync"
"-M"
"--acl-public"
"--add-header" "Content-Encoding:gzip"
"--delete-removed"
(format "~a/" static.gz-path)
(format "s3://~a/" s3-bucket)))
(format "~a/" static-path)
(format "s3://~a/" s3-bucket))
(void))
(define (upload-pkgs pkgs)
;; FUTURE make this more efficient

View File

@ -24,9 +24,10 @@
</table>
<button id="login_button">Log In</button>
<p>If you enter an unclaimed email address, then an account will
be created.</p>
be created with the password you type in, after you confirm
the email address.</p>
<p>Passwords are stored in the delicious bcrypt format, but
transfered as plain-text over the HTTPS connection.</p>
transferred as plain-text over an HTTPS connection.</p>
</div>
<div id="package_info" class="package">

View File

@ -54,6 +54,13 @@ $( document ).ready(function() {
$( "#pi_name" ).text( pkgi['name'] );
make_editbutton ( "pi_name", pkgi['name'], submit_mod_name );
if ( mypkg_p ) {
$( "#pi_name" ).append( $('<button>')
.button({ icons: { primary: "ui-icon-trash" } })
.click( function (e) {
dynamic_pkgsend( "/jsonp/package/del", { } );
$(pkgi['dom_obj']).remove();
$("#package_info").dialog("close"); } ) ); }
$( "#pi_name_inst" ).text( pkgi['name'] );
$( "#pi_ring" ).text( pkgi['ring'] );
@ -261,6 +268,7 @@ $( document ).ready(function() {
$.each( $('#packages_table tr'), function (key, dom) {
var value = $(dom).data("obj");
value['dom_obj'] = dom;
var show = true;
var vterms = value['search-terms'];
@ -366,7 +374,7 @@ $( document ).ready(function() {
return addfilterlink ( tag, tag, "possible" ); } ) ))
.appendTo('#packages_table'); }
$.getJSON( "/pkgs-all.json", function( resp ) {
$.getJSON( "/pkgs-all.json.gz", function( resp ) {
var names = object_keys(resp);
var snames = names.sort(function(a,b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0)); })
@ -414,7 +422,7 @@ $( document ).ready(function() {
$( "#login_error" ).html( "Check your email for an email code." ); }
else if ( resp == "wrong-code" ) {
pt.val("");
$( "#login_error" ).html( "That is the incorrect code." ); }
$( "#login_error" ).html( "That is not the correct code." ); }
else if ( resp ) {
$( "#login_passwd_label" ).html( "Password:" );