node-sword-interface 0.250.0 → 0.253.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/napi_module/node_sword_interface.cpp +11 -7
- package/src/napi_module/node_sword_interface.hpp +2 -0
- package/src/node_sword_cli.cpp +3 -3
- package/src/sword_backend/module_search.cpp +11 -4
- package/src/sword_backend/module_search.hpp +1 -1
- package/src/sword_backend/text_processor.cpp +8 -0
package/package.json
CHANGED
|
@@ -142,9 +142,9 @@ NodeSwordInterface::NodeSwordInterface(const Napi::CallbackInfo& info) : Napi::O
|
|
|
142
142
|
Napi::Env env = info.Env();
|
|
143
143
|
Napi::HandleScope scope(env);
|
|
144
144
|
|
|
145
|
-
std::string customHomeDir = "";
|
|
146
145
|
std::string localeDir = "";
|
|
147
|
-
|
|
146
|
+
this->customHomeDir = "";
|
|
147
|
+
|
|
148
148
|
bool homeDirError = false;
|
|
149
149
|
bool localeDirError = false;
|
|
150
150
|
|
|
@@ -153,9 +153,9 @@ NodeSwordInterface::NodeSwordInterface(const Napi::CallbackInfo& info) : Napi::O
|
|
|
153
153
|
this->_currentModuleSearchWorker = 0;
|
|
154
154
|
|
|
155
155
|
if (info[0].IsString()) {
|
|
156
|
-
customHomeDir = string(info[0].As<Napi::String>());
|
|
156
|
+
this->customHomeDir = string(info[0].As<Napi::String>());
|
|
157
157
|
|
|
158
|
-
if (!this->dirExists(info, customHomeDir)) {
|
|
158
|
+
if (!this->dirExists(info, this->customHomeDir)) {
|
|
159
159
|
homeDirError = true;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -171,10 +171,10 @@ NodeSwordInterface::NodeSwordInterface(const Napi::CallbackInfo& info) : Napi::O
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
if (!homeDirError && !localeDirError) { // We only proceed if there has not been any issue with the homeDir or localeDir
|
|
174
|
-
this->_moduleStore = new ModuleStore(customHomeDir);
|
|
174
|
+
this->_moduleStore = new ModuleStore(this->customHomeDir);
|
|
175
175
|
this->_moduleHelper = new ModuleHelper(*(this->_moduleStore));
|
|
176
|
-
this->_repoInterface = new RepositoryInterface(this->_swordStatusReporter, *(this->_moduleHelper), customHomeDir);
|
|
177
|
-
this->_moduleInstaller = new ModuleInstaller(*(this->_repoInterface), *(this->_moduleStore), customHomeDir);
|
|
176
|
+
this->_repoInterface = new RepositoryInterface(this->_swordStatusReporter, *(this->_moduleHelper), this->customHomeDir);
|
|
177
|
+
this->_moduleInstaller = new ModuleInstaller(*(this->_repoInterface), *(this->_moduleStore), this->customHomeDir);
|
|
178
178
|
this->_napiSwordHelper = new NapiSwordHelper(*(this->_moduleHelper), *(this->_moduleStore));
|
|
179
179
|
this->_textProcessor = new TextProcessor(*(this->_moduleStore), *(this->_moduleHelper));
|
|
180
180
|
this->_moduleSearch = new ModuleSearch(*(this->_moduleStore), *(this->_moduleHelper), *(this->_textProcessor));
|
|
@@ -952,6 +952,10 @@ Napi::Value NodeSwordInterface::getSwordPath(const Napi::CallbackInfo& info)
|
|
|
952
952
|
Napi::HandleScope scope(env);
|
|
953
953
|
|
|
954
954
|
FileSystemHelper fsHelper;
|
|
955
|
+
if (this->customHomeDir != "") {
|
|
956
|
+
fsHelper.setCustomHomeDir(customHomeDir);
|
|
957
|
+
}
|
|
958
|
+
|
|
955
959
|
Napi::String swordPath = Napi::String::New(env, fsHelper.getUserSwordDir());
|
|
956
960
|
unlockApi();
|
|
957
961
|
return swordPath;
|
package/src/node_sword_cli.cpp
CHANGED
|
@@ -214,13 +214,13 @@ int main(int argc, char** argv)
|
|
|
214
214
|
//string translation = sword_facade.getSwordTranslation(string("/usr/share/sword/locales.d"), string("de"), string("locales"));
|
|
215
215
|
//cout << translation << endl;
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
vector<Verse> searchResults = moduleSearch.getModuleSearchResults("GerNeUe", "Glaube", SearchType::multiWord, SearchScope::NT, true);
|
|
218
218
|
cout << "Got " << searchResults.size() << " results!" << endl;
|
|
219
219
|
for (unsigned int i=0; i < searchResults.size(); i++) {
|
|
220
220
|
cout << searchResults[i].reference << endl;
|
|
221
|
-
}
|
|
221
|
+
}
|
|
222
222
|
|
|
223
|
-
get_book_headers(textProcessor)
|
|
223
|
+
/*get_book_headers(textProcessor);*/
|
|
224
224
|
|
|
225
225
|
return 0;
|
|
226
226
|
}
|
|
@@ -50,10 +50,17 @@
|
|
|
50
50
|
using namespace std;
|
|
51
51
|
using namespace sword;
|
|
52
52
|
|
|
53
|
-
ListKey ModuleSearch::getScopeKey(SearchScope scope)
|
|
53
|
+
ListKey ModuleSearch::getScopeKey(SWModule* module, SearchScope scope)
|
|
54
54
|
{
|
|
55
55
|
ListKey key;
|
|
56
56
|
|
|
57
|
+
if (module == 0) {
|
|
58
|
+
cerr << "ModuleSearch::getScopeKey / received 0 pointer for module!!!";
|
|
59
|
+
return key;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
VerseKey verseKey = module->getKey();
|
|
63
|
+
|
|
57
64
|
switch (scope) {
|
|
58
65
|
case SearchScope::OT:
|
|
59
66
|
{
|
|
@@ -63,7 +70,7 @@ ListKey ModuleSearch::getScopeKey(SearchScope scope)
|
|
|
63
70
|
"Isaiah;Jeremiah;Lamentations;Ezekiel;Daniel;Hosea;Joel;Amos;Obadiah;"
|
|
64
71
|
"Jonah;Micah;Nahum;Habakkuk;Zephaniah;Haggai;Zechariah;Malachi;";
|
|
65
72
|
|
|
66
|
-
key =
|
|
73
|
+
key = verseKey.parseVerseList(otBooks, "", true);
|
|
67
74
|
break;
|
|
68
75
|
}
|
|
69
76
|
|
|
@@ -74,7 +81,7 @@ ListKey ModuleSearch::getScopeKey(SearchScope scope)
|
|
|
74
81
|
"I Timothy;II Timothy;Titus;Philemon;Hebrews;James;I Peter;II Peter;"
|
|
75
82
|
"I John;II John;III John;Jude;Revelation of John;";
|
|
76
83
|
|
|
77
|
-
key =
|
|
84
|
+
key = verseKey.parseVerseList(ntBooks, "", true);
|
|
78
85
|
break;
|
|
79
86
|
}
|
|
80
87
|
|
|
@@ -119,7 +126,7 @@ vector<Verse> ModuleSearch::getModuleSearchResults(string moduleName,
|
|
|
119
126
|
ListKey scopeKey;
|
|
120
127
|
|
|
121
128
|
if (searchScope != SearchScope::BIBLE) {
|
|
122
|
-
scopeKey = this->getScopeKey(searchScope);
|
|
129
|
+
scopeKey = this->getScopeKey(module, searchScope);
|
|
123
130
|
scope = &scopeKey;
|
|
124
131
|
}
|
|
125
132
|
|
|
@@ -138,6 +138,14 @@ string TextProcessor::getFilteredText(const string& text, int chapter, int verse
|
|
|
138
138
|
secHead << "chapter=\"" << chapter << "\"";
|
|
139
139
|
this->findAndReplaceAll(filteredText, secHeadClassFilter, secHead.str());
|
|
140
140
|
|
|
141
|
+
if (filteredText.find("subType=\"x-Chapter") != string::npos ||
|
|
142
|
+
filteredText.find("type=\"chapter") != string::npos) {
|
|
143
|
+
|
|
144
|
+
static string swordSectionTitle = "sword-section-title";
|
|
145
|
+
static string swordSectionTitleChapter = "sword-section-title sword-chapter-title";
|
|
146
|
+
this->findAndReplaceAll(filteredText, swordSectionTitle, swordSectionTitleChapter);
|
|
147
|
+
}
|
|
148
|
+
|
|
141
149
|
this->findAndReplaceAll(filteredText, titleEndElementFilter, "</div>");
|
|
142
150
|
this->findAndReplaceAll(filteredText, segStartElementFilter, "");
|
|
143
151
|
this->findAndReplaceAll(filteredText, segEndElementFilter, "");
|