-
Notifications
You must be signed in to change notification settings - Fork 28
Add support for user-supplied fragments config #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,16 @@ | |
| # If undefined, its value is assumed to be `$XDG_DATA_HOME/dasht/docsets/` | ||
| # or, if `XDG_DATA_HOME` is undefined, `$HOME/.local/share/dasht/docsets/`. | ||
| # | ||
| # `DASHT_FRAGMENTS_CONF` | ||
| # Defines the filesystem location where custom URI fragment definition for | ||
| # your [Dash] docsets are stored. These file has the format | ||
| # *DOCSET* `=` *FRAGMENT* | ||
| # where *DOCTSET* and *FRAGMENT* are separated by a space followed by a | ||
| # `=` followed by another space character. The *FRAGMENT* starts with a | ||
| # `#` character. If the environment variable is undefined, its value is | ||
| # assumed to be `$XDG_DATA_HOME/dasht/fragments.conf` or, if `XDG_DATA_HOME` | ||
| # is undefined, `$HOME/.local/share/dasht/fragments.conf`. | ||
| # | ||
| # ## EXIT STATUS | ||
| # | ||
| # 44 | ||
|
|
@@ -87,19 +97,21 @@ | |
| # Distributed under the terms of the ISC license (see the LICENSE file). | ||
|
|
||
| : ${DASHT_DOCSETS_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/docsets} | ||
| : ${DASHT_FRAGMENTS_CONF:=${XDG_DATA_HOME:-$HOME/.local/share}/dasht/fragments.conf} | ||
|
|
||
| pattern=$(echo " $1 " | sed -e 's/[%_]/\\&/g' -e 's/[[:space:]]\{1,\}/%/g') | ||
| test $# -gt 0 && shift # shift off PATTERN so argv contains solely DOCSETs | ||
|
|
||
| status=44 # (default) exit with a nonzero status when no results are found | ||
| trap 'status=0' USR1 # override default exit status when results are found | ||
| [ -r "$DASHT_FRAGMENTS_CONF" ] && fragments_conf="$DASHT_FRAGMENTS_CONF" || fragments_conf= | ||
Holzhaus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| dasht-docsets "$@" | while read -r docset; do | ||
| database="$DASHT_DOCSETS_DIR/$docset".docset/Contents/Resources/docSet.dsidx | ||
| file_url="file://$(dirname "$database")/Documents/" | ||
|
|
||
| dasht-query-exec "$pattern" "$database" -line | | ||
| awk -v docset="$docset" -v file_url="$file_url" ' | ||
| awk -v docset="$docset" -v file_url="$file_url" -v fragments_conf="$fragments_conf" ' | ||
| BEGIN { | ||
| # default URI fragments that move user | ||
| # past navigation links at top of page | ||
|
|
@@ -241,6 +253,14 @@ dasht-docsets "$@" | while read -r docset; do | |
| fragment_by_docset["jQuery"] = "#content" | ||
| fragment_by_docset["jQuery_Mobile"] = "#content" | ||
| fragment_by_docset["jQuery_UI"] = "#content" | ||
|
|
||
| if (fragments_conf != "") { | ||
| while (getline < fragments_conf) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might avoid reading the fragments file here if it contents are passed in through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, my |
||
| { | ||
| split($0,field," = "); | ||
| fragment_by_docset[field[1]] = field[2]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| { $1 = $1 } # strip whitespace from key | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.