From 776d3fd5090f43482f52ef79cd5bd486bc78f22b Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 8 Oct 2013 09:16:29 -0600 Subject: [PATCH] conflicts as tags --- .../meta/pkg-index/official/static.rkt | 119 ++++++++++++++---- .../meta/pkg-index/official/static/index.js | 1 - 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/pkgs/plt-services/meta/pkg-index/official/static.rkt b/pkgs/plt-services/meta/pkg-index/official/static.rkt index fc728b3291..dbfc9b7ecc 100644 --- a/pkgs/plt-services/meta/pkg-index/official/static.rkt +++ b/pkgs/plt-services/meta/pkg-index/official/static.rkt @@ -47,35 +47,18 @@ (define pkg-list (map path->string (directory-list pkgs-path))) (define pkg-ht - (for/hash ([pkg-name (in-list pkg-list)]) - (define ht (file->value (build-path pkgs-path pkg-name))) + (make-hash)) - (values pkg-name - (hash-set* ht - 'name pkg-name - 'tags (hash-ref ht 'tags empty) - 'search-terms - (let* ([st (hasheq)] - [st (for/fold ([st st]) - ([t (in-list (hash-ref ht 'tags empty))]) - (hash-set st (string->symbol t) #t))] - [st (hash-set st (string->symbol (format "ring:~a" (hash-ref ht 'ring 2))) #t)] - [st (for/fold ([st st]) - ([a (in-list (author->list (hash-ref ht 'author "")))]) - (hash-set st (string->symbol (format "author:~a" a)) #t))] - [st (if (empty? (hash-ref ht 'tags empty)) - (hash-set st ':no-tag: #t) - st)] - [st (if (hash-ref ht 'checksum-error #f) - (hash-set st ':error: #t) - st)]) - st) - 'authors (author->list (hash-ref ht 'author "")))))) + (for ([pkg-name (in-list pkg-list)]) + (define ht (file->value (build-path pkgs-path pkg-name))) - (define basic-dispatch - (pkg-index/basic - (λ () pkg-list) - (λ (pkg-name) (hash-ref pkg-ht pkg-name)))) + (hash-set! + pkg-ht pkg-name + (hash-set* ht + 'name pkg-name + 'ring (hash-ref ht 'ring 2) + 'tags (hash-ref ht 'tags empty) + 'authors (author->list (hash-ref ht 'author ""))))) (define (package-info pn) (hash-ref pkg-ht pn)) @@ -87,6 +70,88 @@ (date->string (seconds->date s #f) #t))) "")) + (define (module-lists-conflict? left right) + (define seen? (make-hash)) + (for ([l (in-list left)]) + (hash-set! seen? l #t)) + (for/or ([r (in-list right)]) + (hash-ref seen? r #f))) + + (define (string-min x y) + (if (string<=? x y) + x + y)) + + (define (string-max x y) + (if (stringsymbol t) #t))] + [st (hash-set st (string->symbol (format "ring:~a" (hash-ref ht 'ring))) #t)] + [st (for/fold ([st st]) + ([a (in-list (author->list (hash-ref ht 'author)))]) + (hash-set st (string->symbol (format "author:~a" a)) #t))] + [st (if (empty? (hash-ref ht 'tags)) + (hash-set st ':no-tag: #t) + st)] + [st (if (hash-ref ht 'checksum-error) + (hash-set st ':error: #t) + st)] + [st (if (empty? conflicts) + st + (hash-set st ':conflicts: #t))]) + st))))) + + + (define basic-dispatch + (pkg-index/basic + (λ () pkg-list) + (λ (pkg-name) (hash-ref pkg-ht pkg-name)))) + (define (page/atom.xml req) (define ps (sort (map package-info pkg-list) diff --git a/pkgs/plt-services/meta/pkg-index/official/static/index.js b/pkgs/plt-services/meta/pkg-index/official/static/index.js index 5a331c6072..08bd19522e 100644 --- a/pkgs/plt-services/meta/pkg-index/official/static/index.js +++ b/pkgs/plt-services/meta/pkg-index/official/static/index.js @@ -1,5 +1,4 @@ // xxx display curation if allowed -// xxx display conflicts as a tag // xxx logout // xxx what user am i // xxx upload