-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Readme on old features and rewording of title vs direntry #241
Readme on old features and rewording of title vs direntry #241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly related to titleName -> title, and dirEntry.name() to dirEntry.title.
function removeDuplicateTitlesInDirEntryArray(array) { | ||
array.sort(function(dirEntryA, dirEntryB) { | ||
if (dirEntryA.title < dirEntryB.title) return -1; | ||
if (dirEntryA.title > dirEntryB.title) return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dirEntry.title property is also accessed via dirEntry.name and dirEntry.getReadableName. Maybe this name and getReadableName can be removed so that everywhere there is just one way title is accessed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. It was probably meaningful with Evopedia archives, but is not any more.
www/js/lib/zimArchive.js
Outdated
callback(title.name(), utf8.parse(data)); | ||
ZIMArchive.prototype.readArticle = function(dirEntry, callback) { | ||
return dirEntry.readData().then(function(data) { | ||
callback(dirEntry.name(), utf8.parse(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be just dirEntry.title instead of .name()
www/js/lib/zimArchive.js
Outdated
callback(title.name(), data); | ||
ZIMArchive.prototype.readBinaryFile = function(dirEntry, callback) { | ||
return dirEntry.readData().then(function(data) { | ||
callback(dirEntry.name(), data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also remembered this was a weird flow while debugging readArticle.
zimdirent.readData just calls zimfile.blob. this readData function seemed an extra step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite : it hides the concept of cluster
www/js/lib/zimArchive.js
Outdated
@@ -270,7 +254,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'], | |||
* @param {String} titleName | |||
* @return {Promise} resolving to the title object or null if not found. | |||
*/ | |||
ZIMArchive.prototype.getTitleByName = function(titleName) { | |||
ZIMArchive.prototype.getDirEntryByTitleName = function(titleName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too Name can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
titleName can be changed to title everywhere I think
The first versions of this application were originally part of the Evopedia project: http://www.evopedia.info (now discontinued). There was a "articles nearby" feature, that was able to find articles around your location. It has been deleted from the source code with everything related to Evopedia (but still in git history in versions<=2.0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be I think more readable and stick in memory of devs as a simple list rather than a para.
Useful Features Unavailable in Current Build:
- Evopedia archive support
- Find Articles Nearby (Geo based search)
- Firefox OS port
- Phonegap/Cordova port (incomplete)
Please consult Git History for reference.
tests/tests.js
Outdated
assert.ok(title !== null, "Title found"); | ||
assert.ok(!title.isRedirect(), "Title is not a redirect."); | ||
assert.equal(title.name(), "Night Time Is the Right Time", "Correct redirected title name."); | ||
localZimArchive.getDirEntryByTitleName("A/(The_Night_Time_Is)_The_Right_Time.html").then(function(dirEntry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TitleName ->Title
.name() -> .title
www/js/app.js
Outdated
messagePort.postMessage({'action': 'giveContent', 'titleName' : titleName, 'content': content}); | ||
console.log("content sent to ServiceWorker"); | ||
}); | ||
} | ||
}; | ||
selectedArchive.getTitleByName(titleName).then(readFile).fail(function() { | ||
selectedArchive.getDirEntryByTitleName(titleName).then(readFile).fail(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
titleName to title
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of places in this file where above change applies.
also .name() to .title
@@ -20,7 +20,7 @@ | |||
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/> | |||
*/ | |||
'use strict'; | |||
define(['xzdec_wrapper', 'util', 'utf8', 'q'], function(xz, util, utf8, Q) { | |||
define(['xzdec_wrapper', 'util', 'utf8', 'q', 'zimDirEntry'], function(xz, util, utf8, Q, zimDirEntry) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to add a comment on the "blob" function. So am adding here.
This function took me the longest to figure out. Okay I didn't know what Promises were so that didn't help :)
But even after...I think what was missing to me was how the decompression process works. Just a brief note in the function documentation would be really useful. Like what is chunk size? Relationship to the compressed data read length. To read the 16 bytes to get blob address for example why is chunk size set to 5 KB. Basically some kind of note on how this works would be great. By changing these sizes (data length/chunk size) can reads be done faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nextCluster = readInt(clusterOffsets, 8, 8); This nextCluster doesn't seem to get used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't master this code portion (I did not write it myself).
I agree with you that it lacks some comments. And it might be a place where some optimization could take place.
I'll leave it as it is for now.
www/js/lib/zimArchive.js
Outdated
return title.readData().then(function(data) { | ||
callback(title.name(), utf8.parse(data)); | ||
ZIMArchive.prototype.readArticle = function(dirEntry, callback) { | ||
return dirEntry.readData().then(function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this return here required? The callback handles the end of the read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True : it's unnecessary
…eName(). To help understanding the code.
I pushed another commit that addresses some of your comments. |
Ok. Sounds good to me! |
Getting rid of this "Title" concept modifies a lot of code.
@sharun-s : is that what you expected in #218 ?