mirror of
https://github.com/mipmip/home-manager-option-search.git
synced 2024-09-11 23:27:11 +03:00
a lot
This commit is contained in:
parent
e6a48dfd4e
commit
b506408f44
17
.github/workflows/update.yml
vendored
Normal file
17
.github/workflows/update.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: "parse and deploy"
|
||||
on:
|
||||
schedule:
|
||||
- cron: '05 4 * * *'
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: parse options and create search
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.7
|
||||
- run: ruby scripts/parse_appendix.rb && bash scripts/commitpush.sh
|
20
README.md
20
README.md
@ -1,16 +1,26 @@
|
||||
# home-manager option search
|
||||
|
||||
Find home manager options quickly.
|
||||
|
||||
## Version 1
|
||||
|
||||
- [x] finish nokogiri
|
||||
- [x] write to json
|
||||
- [x] make search front end
|
||||
- [x] write last updated
|
||||
- [x] reference to home manager and appendix page
|
||||
- [ ] github actions
|
||||
- [ ] run
|
||||
- [ ] commit
|
||||
- [ ] onclick show complete listing
|
||||
- [ ] preserve links etc...
|
||||
|
||||
## Next version
|
||||
- [ ] cleanup/reorganize
|
||||
- [ ] improve style
|
||||
- [ ] search improvements
|
||||
- [ ] no results when nothing entered
|
||||
- [ ] allow enter
|
||||
- [ ] read url
|
||||
- [ ] preserve links etc...
|
||||
- [ ] onclick show complete listing
|
||||
- [ ] cleanup/reorganize
|
||||
- [ ] improve style
|
||||
- [ ] footer/header like the NUR
|
||||
- [ ] hugo? page per option
|
||||
- [ ] github actions
|
||||
|
18
index.html
18
index.html
@ -5,7 +5,7 @@
|
||||
<title>Home Manager - option search (proto)</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -15,12 +15,19 @@
|
||||
<i class="fa fa-github-square"></i>
|
||||
<a href="https://github.com/mipmip/home-manager-option-search">https://github.com/mipmip/home-manager-option-search</a>
|
||||
</h4>
|
||||
<h4>
|
||||
<i class="fa fa-book"></i>
|
||||
<a href="https://nix-community.github.io/home-manager/options.html">Home Manager options in official documentation</a>
|
||||
</h4>
|
||||
|
||||
<div id="lastUpdateElement"></div>
|
||||
|
||||
<ul class="list-inline">
|
||||
<li>Options indexed by:</li>
|
||||
<li>Search in:</li>
|
||||
<li><input type="checkbox" checked id="indexOnTitleCheckbox"> Title</li>
|
||||
<li><input type="checkbox" checked id="indexOnDescriptionCheckbox"> Description</li>
|
||||
<li>Index strategy:</li>
|
||||
|
||||
<li>Search strategy:</li>
|
||||
<li>
|
||||
<select id="indexStrategySelect">
|
||||
<option value="JsSearch.AllSubstringsIndexStrategy">All substrings</option>
|
||||
@ -28,6 +35,7 @@
|
||||
<option value="JsSearch.PrefixIndexStrategy" selected>Prefix matching</option>
|
||||
</select>
|
||||
</li>
|
||||
<!--
|
||||
<li><input type="checkbox" id="removeStopWordsCheckbox"> Remove stop words</li>
|
||||
<li>Sanitizer:</li>
|
||||
<li>
|
||||
@ -38,6 +46,7 @@
|
||||
</li>
|
||||
<li><input type="checkbox" id="useStemmingCheckbox"> Use stemming</li>
|
||||
<li><input type="checkbox" id="tfIdfRankingCheckbox" checked> TF-IDF ranking</li>
|
||||
-->
|
||||
</p>
|
||||
|
||||
<form>
|
||||
@ -50,6 +59,7 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<table id="indexedOptionsTable" class="table table-striped table-condensed hidden">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -74,6 +84,6 @@
|
||||
|
||||
<script type="text/javascript" src="https://rawgit.com/kristopolous/Porter-Stemmer/master/PorterStemmer1980.min.js"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/js-search@1.3.7/dist/umd/js-search.min.js"></script>
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,12 +1,13 @@
|
||||
var search, results, allOptions = [];
|
||||
var lastUpdate = "?";
|
||||
|
||||
var indexOnDescriptionCheckbox = document.getElementById('indexOnDescriptionCheckbox');
|
||||
var indexStrategySelect = document.getElementById('indexStrategySelect');
|
||||
var removeStopWordsCheckbox = document.getElementById('removeStopWordsCheckbox');
|
||||
//var indexStrategySelect = document.getElementById('indexStrategySelect');
|
||||
//var removeStopWordsCheckbox = document.getElementById('removeStopWordsCheckbox');
|
||||
var indexOnTitleCheckbox = document.getElementById('indexOnTitleCheckbox');
|
||||
var useStemmingCheckbox = document.getElementById('useStemmingCheckbox');
|
||||
var sanitizerSelect = document.getElementById('sanitizerSelect');
|
||||
var tfIdfRankingCheckbox = document.getElementById('tfIdfRankingCheckbox');
|
||||
//var useStemmingCheckbox = document.getElementById('useStemmingCheckbox');
|
||||
//var sanitizerSelect = document.getElementById('sanitizerSelect');
|
||||
//var tfIdfRankingCheckbox = document.getElementById('tfIdfRankingCheckbox');
|
||||
|
||||
var rebuildAndRerunSearch = function() {
|
||||
rebuildSearchIndex();
|
||||
@ -14,42 +15,51 @@ var rebuildAndRerunSearch = function() {
|
||||
};
|
||||
|
||||
indexOnDescriptionCheckbox.onchange = rebuildAndRerunSearch;
|
||||
indexStrategySelect.onchange = rebuildAndRerunSearch;
|
||||
removeStopWordsCheckbox.onchange = rebuildAndRerunSearch;
|
||||
//indexStrategySelect.onchange = rebuildAndRerunSearch;
|
||||
//removeStopWordsCheckbox.onchange = rebuildAndRerunSearch;
|
||||
indexOnTitleCheckbox.onchange = rebuildAndRerunSearch;
|
||||
useStemmingCheckbox.onchange = rebuildAndRerunSearch;
|
||||
sanitizerSelect.onchange = rebuildAndRerunSearch;
|
||||
tfIdfRankingCheckbox.onchange = rebuildAndRerunSearch;
|
||||
//useStemmingCheckbox.onchange = rebuildAndRerunSearch;
|
||||
//sanitizerSelect.onchange = rebuildAndRerunSearch;
|
||||
//tfIdfRankingCheckbox.onchange = rebuildAndRerunSearch;
|
||||
|
||||
var rebuildSearchIndex = function() {
|
||||
search = new JsSearch.Search('description');
|
||||
|
||||
/*
|
||||
if (useStemmingCheckbox.checked) {
|
||||
search.tokenizer = new JsSearch.StemmingTokenizer(stemmer, search.tokenizer);
|
||||
}
|
||||
if (removeStopWordsCheckbox.checked) {
|
||||
search.tokenizer = new JsSearch.StopWordsTokenizer(search.tokenizer);
|
||||
}
|
||||
*/
|
||||
|
||||
search.indexStrategy = eval('new ' + indexStrategySelect.value + '()');
|
||||
search.sanitizer = eval('new ' + sanitizerSelect.value + '()');;
|
||||
//search.sanitizer = eval('new ' + sanitizerSelect.value + '()');;
|
||||
|
||||
search.searchIndex = new JsSearch.UnorderedSearchIndex();
|
||||
|
||||
if (indexOnTitleCheckbox.checked) {
|
||||
search.addIndex('title');
|
||||
}
|
||||
if (indexOnDescriptionCheckbox.checked) {
|
||||
search.addIndex('description');
|
||||
}
|
||||
|
||||
search.addIndex('description');
|
||||
|
||||
search.addDocuments(allOptions);
|
||||
};
|
||||
|
||||
var indexedOptionsTable = document.getElementById('indexedOptionsTable');
|
||||
var lastUpdateElement = document.getElementById('lastUpdateElement');
|
||||
var indexedOptionsTBody = indexedOptionsTable.tBodies[0];
|
||||
var searchInput = document.getElementById('searchInput');
|
||||
var optionCountBadge = document.getElementById('optionCountBadge');
|
||||
|
||||
var updateLastUpdate = function(lastUpdate) {
|
||||
lastUpdateElement.innerHTML = 'Last update: '+ lastUpdate;
|
||||
};
|
||||
|
||||
var updateOptionsTable = function(options) {
|
||||
indexedOptionsTBody.innerHTML = '';
|
||||
|
||||
@ -122,6 +132,7 @@ xmlhttp.onreadystatechange = function() {
|
||||
var json = JSON.parse(xmlhttp.responseText);
|
||||
|
||||
allOptions = json.options;
|
||||
lastUpdate = json.last_update;
|
||||
|
||||
updateOptionCount(allOptions.length);
|
||||
|
||||
@ -131,7 +142,8 @@ xmlhttp.onreadystatechange = function() {
|
||||
|
||||
rebuildSearchIndex();
|
||||
updateOptionsTable(allOptions);
|
||||
updateLastUpdate(lastUpdate);
|
||||
}
|
||||
}
|
||||
xmlhttp.open('GET', 'options.json', true);
|
||||
xmlhttp.open('GET', 'data/options.json', true);
|
||||
xmlhttp.send();
|
File diff suppressed because one or more lines are too long
9
scripts/commitpush.sh
Normal file
9
scripts/commitpush.sh
Normal file
@ -0,0 +1,9 @@
|
||||
if [[ ! -z "$(git diff --exit-code)" ]]; then
|
||||
git add ./data/options.json
|
||||
git commit -m "automatic update options.json"
|
||||
git pull --rebase origin main
|
||||
git push origin main
|
||||
else
|
||||
echo "nothings changed will not commit anything"
|
||||
fi
|
||||
|
@ -75,6 +75,8 @@ end
|
||||
|
||||
|
||||
outobj = {}
|
||||
time = Time.new
|
||||
outobj["last_update"] = time.strftime("%B %d, %Y at %k:%M")
|
||||
outobj["options"] = outarr
|
||||
|
||||
File.open("options.json","w") do |f|
|
Loading…
Reference in New Issue
Block a user