diff --git a/.gitignore b/.gitignore index 215b9c4..2851e28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# ===== Custom.gitignore ===== # +feeds + # ===== Global/Linux.gitignore ===== # *~ diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..23e732f --- /dev/null +++ b/.vimrc @@ -0,0 +1,34 @@ +set nocompatible + +function! Mirror(dict) + for [key, value] in items(a:dict) + let a:dict[value] = key + endfor + return a:dict +endfunction + +function! S(number) + return submatch(a:number) +endfunction + +function! SwapWords(dict, ...) + let words = keys(a:dict) + values(a:dict) + let words = map(words, 'escape(v:val, "|")') + if(a:0 == 1) + let delimiter = a:1 + else + let delimiter = '/' + endif + let pattern = '\v(' . join(words, '|') . ')' + exe '%s' . delimiter . pattern . delimiter + \ . '\=' . string(Mirror(a:dict)) . '[S(0)]' + \ . delimiter . 'g' +endfunction + +function! FixFileUrl() + exe 0 + let @q = 'jf>l"ayt -1.4 -http://frankfurt.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://london.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://newyork.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://sanfrancisco.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://singapore.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://tokyo.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz -http://sydney.kapeli.com/feeds/zzz/user_contributed/build/CouchDB/CouchDB.tgz - diff --git a/Julia.xml b/Julia.xml deleted file mode 100644 index c1064e9..0000000 --- a/Julia.xml +++ /dev/null @@ -1,10 +0,0 @@ - -0.3.6 -http://frankfurt.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://london.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://newyork.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://sanfrancisco.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://singapore.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://tokyo.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz -http://sydney.kapeli.com/feeds/zzz/user_contributed/build/Julia/Julia.tgz - diff --git a/Phalcon.xml b/Phalcon.xml deleted file mode 100644 index 72a5fb7..0000000 --- a/Phalcon.xml +++ /dev/null @@ -1,10 +0,0 @@ - -2.0.0 -http://frankfurt.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://london.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://newyork.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://sanfrancisco.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://singapore.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://tokyo.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz -http://sydney.kapeli.com/feeds/zzz/user_contributed/build/Phalcon/Phalcon.tgz - diff --git a/list b/list deleted file mode 100644 index f6a2d6c..0000000 --- a/list +++ /dev/null @@ -1,2 +0,0 @@ -Pin.xml -dash_docsets.sh diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..c574c28 --- /dev/null +++ b/update.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +INBUILT_FEED='https://github.com/Kapeli/feeds' +CONTRIB_FEED='http://sanfrancisco.kapeli.com/feeds/zzz/user_contributed/build/index.json' + +# Update the INBUILT_FEED from upstream +if [ -d "$(basename "$INBUILT_FEED")" ]; then + cd "$(basename "$INBUILT_FEED")" && git checkout master && git pull && cd .. +else + git clone "$INBUILT_FEED" +fi + +# Update the CONTRIB_FEED from upstream +wget -qO - "$CONTRIB_FEED" | \ + sed -n -e '/^ \{4\}"/p' \ + -e '/^ "archive" :.*tgz"/p' \ + -e '/^ "version" :/p' | \ + awk -F '"' 'NR%3==1 { nm = $2 ; next } + NR%3==2 { ar = $4 ; ; next } + NR%3==0 { vr = $4 ; + of = nm ".xml" + print "" > of + print "" vr "" >> of + print "http://frankfurt.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://london.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://newyork.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://sanfrancisco.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://singapore.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://tokyo.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "http://sydney.kapeli.com/feeds/zzz/user_contributed/build/" nm "/" ar "" >> of + print "" >> of + ar = ""; vr = ""; nm = ""; next ; + }' + +# Remove duplicate files and keep only the more recent versions +rm CouchDB.xml Julia.xml Phalcon.xml + +# This is bound to have some errors +# Detect erroneous files + +# Get all files that have malformed URLs +MALFORMED_FILES=$(grep -L "http://.*\.tgz" ./*.xml) + +# Fix MALFORMED_FILES using some regex magic (need to make this better and not look stupid) +for file in $MALFORMED_FILES; do + vim "$file" -u ./.vimrc +'call FixFileUrl()' +wq +done + +# Extract URLs from all files and creat a wget input file +WGET_URLS='/tmp/docsets_url' +grep "http://london\..*\.tgz" ./**/*.xml -o --no-filename > "$WGET_URLS" + +# Download the archives and extract them to proper docsets directory +cd "${1='/tmp/'}" && \ + wget --continue -i "$WGET_URLS" +#&& \ +# tar xzf ./*.tgz -C "$HOME/.local/share/Zeal/Zeal/docsets/"