Skip to content

Commit

Permalink
Full text save
Browse files Browse the repository at this point in the history
  • Loading branch information
Egil Moeller committed Sep 16, 2011
1 parent a017db7 commit c196016
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions etherpad/src/plugins/fullTextSave/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import("etherpad.log");
import("dispatch.{Dispatcher,PrefixMatcher,forward}");
import("sqlbase.sqlobj");
import("etherpad.collab.server_utils");
import("etherpad.utils");
import("etherpad.pad.padutils");
import("fastJSON");

function padModelWriteToDB(args) {
var old = sqlobj.selectSingle("PAD_FULLTEXT", { PAD_ID: args.padId });
if (old !== null) {
sqlobj.update("PAD_FULLTEXT", {PAD_ID: args.padId }, {TEXT: args.pad.text()});
} else {
sqlobj.insert("PAD_FULLTEXT", {PAD_ID: args.padId, TEXT: args.pad.text()});
}
}
28 changes: 28 additions & 0 deletions etherpad/src/plugins/fullTextSave/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import("etherpad.log");
import("plugins.fullTextSave.hooks");
import("sqlbase.sqlobj");
import("sqlbase.sqlcommon");

function fullTextSaveInit() {
this.hooks = ['padModelWriteToDB'];
this.description = 'Saves a full text copy of the latest version of a pad for external search tools (e.g. lucene)';
this.padModelWriteToDB = hooks.padModelWriteToDB;

this.install = install;
this.uninstall = uninstall;
}

function install() {
log.info("Installing fullTextSave");

sqlobj.createTable('PAD_FULLTEXT', {
PAD_ID: 'varchar(128) character set utf8 collate utf8_bin not null references PAD_META(ID)',
TEXT: 'text collate utf8_bin not null'
});

}

function uninstall() {
log.info("Uninstalling fullTextSave");
}

0 comments on commit c196016

Please sign in to comment.