Skip to content
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

Merged

Conversation

mossroy
Copy link
Contributor

@mossroy mossroy commented May 28, 2017

Getting rid of this "Title" concept modifies a lot of code.
@sharun-s : is that what you expected in #218 ?

Copy link
Contributor

@sharun-s sharun-s left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

callback(title.name(), utf8.parse(data));
ZIMArchive.prototype.readArticle = function(dirEntry, callback) {
return dirEntry.readData().then(function(data) {
callback(dirEntry.name(), utf8.parse(data));
Copy link
Contributor

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()

callback(title.name(), data);
ZIMArchive.prototype.readBinaryFile = function(dirEntry, callback) {
return dirEntry.readData().then(function(data) {
callback(dirEntry.name(), data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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) {
Copy link
Contributor

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

Copy link
Contributor

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)
Copy link
Contributor

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:

  1. Evopedia archive support
  2. Find Articles Nearby (Geo based search)
  3. Firefox OS port
  4. 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) {
Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

titleName to title

Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

return title.readData().then(function(data) {
callback(title.name(), utf8.parse(data));
ZIMArchive.prototype.readArticle = function(dirEntry, callback) {
return dirEntry.readData().then(function(data) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True : it's unnecessary

@mossroy
Copy link
Contributor Author

mossroy commented May 28, 2017

I pushed another commit that addresses some of your comments.
I'd like to merge this PR, test and release a version 2.1.0 that would include all the recent commits we made.
Feel free to open other issues if necessary, for a next version

@sharun-s
Copy link
Contributor

Ok. Sounds good to me!

@mossroy mossroy merged commit a3d3c76 into master May 28, 2017
@mossroy mossroy deleted the readme_on_old_features_and_rewording_of_title_vs_direntry branch May 28, 2017 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants