Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/df3181ce15f2
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 07:33:16 2012
Кодировка:

Поисковые слова: m 8

# HG changeset patch
# User boris (netbook)
# Date 1284637795 -14400
# Node ID df3181ce15f285ec4ef106d086fce6a18bc1adf4
# Parent 7a770b1abe2311f3868171f0477ef1cab399a760# Parent d38863e21ada2010867af062b043df532d0d9689
committing hg merge

diff -r 7a770b1abe23 -r df3181ce15f2 .geany
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.geany Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,29 @@
+
+[indentation]
+indent_width=2
+indent_type=1
+indent_hard_tab_width=2
+detect_indent=true
+indent_mode=2
+
+[project]
+name=malakite-blocks3d-wt
+base_path=/home/boris/my-code/Blocks3D/malakite-blocks3d-wt
+make_in_base_path=false
+description=
+run_cmd=
+
+[files]
+current_page=10
+FILE_NAME_0=141;None;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt.pro;0
+FILE_NAME_1=124;C;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/config.h;0
+FILE_NAME_2=479;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/config.C;0
+FILE_NAME_3=451;C++;0;16;0;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt.C;0
+FILE_NAME_4=1072;C;0;16;0;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt-widget.h;0
+FILE_NAME_5=3752;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt-widget.C;0
+FILE_NAME_6=44;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/salt.C;0
+FILE_NAME_7=419;C;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/work-time.h;0
+FILE_NAME_8=24;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/work-time.C;0
+FILE_NAME_9=3329;Javascript;0;16;1;1;1;/home/boris/sell/files/js/jquery.countdown.package-1.5.8/jquery.countdown.js;0
+FILE_NAME_10=1229;None;0;16;0;1;1;/home/boris/helps/hg.txt;0
+FILE_NAME_11=0;None;0;16;0;1;1;/home/boris/helps/LINUX.txt;0
diff -r 7a770b1abe23 -r df3181ce15f2 .hgtags
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgtags Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,1 @@
+c51ef42eb5e5c2c98dac3c99271777905fb4da76 first run
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/blocks3d-wt-widget.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/blocks3d-wt-widget.C Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,298 @@
+
+#include "config.h"
+#include "blocks3d-wt-widget.h"
+#include "salt.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget *parent) :
+ Wt::WContainerWidget(parent)
+{
+ Wt::WText* head = new Wt::WText("Blocks3D", this);
+ head->setStyleClass("header");
+
+ alignment_upload = new Wt::WFileUpload();
+ alignment_textarea = new Wt::WTextArea();
+ alignment_textarea->setColumns(60);
+ alignment_textarea->setRows(20);
+ conformity_upload = new Wt::WFileUpload();
+ conformity_textarea = new Wt::WTextArea();
+ conformity_textarea->setColumns(40);
+ conformity_textarea->setRows(20);
+
+ Wt::WLabel *alignment_label = new Wt::WLabel("Alignment:");
+ alignment_label->setBuddy(alignment_textarea);
+
+ Wt::WLabel *conformity_label = new Wt::WLabel("Confiomity file:");
+ conformity_label->setBuddy(alignment_textarea);
+
+ new Wt::WBreak(this);
+ Wt::WTable *table = new Wt::WTable(this);
+
+ table->elementAt(0, 0)->addWidget(alignment_label);
+ table->elementAt(1, 0)->addWidget(alignment_textarea);
+ table->elementAt(2, 0)->addWidget(alignment_upload);
+
+ table->elementAt(0, 1)->addWidget(conformity_label);
+ table->elementAt(1, 1)->addWidget(conformity_textarea);
+ table->elementAt(2, 1)->addWidget(conformity_upload);
+
+ new Wt::WBreak(this);
+ delta_input = new Wt::WLineEdit(Malakite::defaults::delta, this);
+ delta_validator = new Wt::WDoubleValidator(0.0, 10.0); // FIXME: not to allow empty
+ delta_validator->setMandatory(true);
+ delta_input->setValidator(delta_validator);
+ Wt::WLabel *delta_label = new Wt::WLabel("Distance spreading", this);
+ delta_label->setBuddy(delta_input);
+
+ new Wt::WBreak(this);
+ min_block_width_input = new Wt::WLineEdit(Malakite::defaults::min_block_width, this);
+ min_block_width_validator = new Wt::WIntValidator(3, 9999);
+ min_block_width_validator->setMandatory(true);
+ min_block_width_input->setValidator(min_block_width_validator);
+ Wt::WLabel *min_block_width_label = new Wt::WLabel("Min block width", this);
+ min_block_width_label->setBuddy(min_block_width_input);
+
+ new Wt::WBreak(this);
+ timeout_input = new Wt::WLineEdit(Malakite::defaults::timeout, this);
+ timeout_validator = new Wt::WIntValidator(-1, 30*24*3600);
+ timeout_validator->setMandatory(true);
+ timeout_input->setValidator(timeout_validator);
+ Wt::WLabel *timeout_label = new Wt::WLabel(
+ "Bron-Kerbosh (couple cores) timeout", this);
+ timeout_label->setBuddy(timeout_input);
+
+ new Wt::WBreak(this);
+ timeout2_input = new Wt::WLineEdit(Malakite::defaults::timeout2, this);
+ timeout2_validator = new Wt::WIntValidator(-1, 30*24*3600);
+ timeout2_validator->setMandatory(true);
+ timeout2_input->setValidator(timeout2_validator);
+ Wt::WLabel *timeout2_label = new Wt::WLabel(
+ "Bron-Kerbosh (blocks) timeout", this);
+ timeout2_label->setBuddy(timeout2_input);
+
+
+ new Wt::WBreak(this);
+ Wt::WPushButton *go_button = new Wt::WPushButton("Run", this);
+
+ new Wt::WBreak(this);
+ results_panel = new Wt::WContainerWidget(this);
+
+ go_button->clicked().connect(this, &Blocks3DWidget::go_button_click);
+ alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded);
+ conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded);
+ alignment_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
+ conformity_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
+
+ alignment_upload->changed().connect(alignment_upload, &Wt::WFileUpload::upload);
+ conformity_upload->changed().connect(conformity_upload, &Wt::WFileUpload::upload);
+
+ timer = new Wt::WTimer(this);
+ timer->timeout().connect(this, &Blocks3DWidget::timeout);
+ timer->setInterval(Malakite::refresh_period);
+}
+
+void Blocks3DWidget::go_button_click()
+{
+ try_to_run();
+}
+
+void Blocks3DWidget::fileTooLarge()
+{
+ Wt::WMessageBox::show("Error", "File too large", Wt::Ok);
+}
+
+void Blocks3DWidget::textarea_from_file(Wt::WTextArea* ta, const char* file)
+{
+ std::string temp("");
+ std::string total("");
+ std::ifstream uploaded_file;
+
+ uploaded_file.open(file);
+ if (!uploaded_file)
+ {
+ return;
+ }
+ while (uploaded_file >> temp)
+ {
+ total += temp + "\n";
+ }
+ uploaded_file.close();
+
+ ta->setText(total);
+
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Upload finished", results_panel);
+}
+
+void Blocks3DWidget::alignment_uploaded()
+{
+ textarea_from_file(alignment_textarea,
+ alignment_upload->spoolFileName().c_str());
+}
+
+void Blocks3DWidget::conformity_uploaded()
+{
+ textarea_from_file(conformity_textarea,
+ conformity_upload->spoolFileName().c_str());
+}
+
+void Blocks3DWidget::try_to_run()
+{
+ std::string alignment = alignment_textarea->text().toUTF8();
+ std::string conformity = conformity_textarea->text().toUTF8();
+ if (alignment.empty())
+ {
+ new Wt::WBreak(results_panel);
+ new Wt::WText("No alignment provided", results_panel);
+ return;
+ }
+ if (delta_input->validate() != Wt::WValidator::Valid)
+ {
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Enter delta parameter", results_panel);
+ return;
+ }
+ if (min_block_width_input->validate() != Wt::WValidator::Valid)
+ {
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Enter min block width parameter", results_panel);
+ return;
+ }
+ if (timeout_input->validate() != Wt::WValidator::Valid)
+ {
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Enter timeout parameter", results_panel);
+ return;
+ }
+ if (timeout2_input->validate() != Wt::WValidator::Valid)
+ {
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Enter timeout2 parameter", results_panel);
+ return;
+ }
+
+ std::string r = generateSalt();
+
+ tempfile_alignment =
+ str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_alignment);
+ tempfile_conformity =
+ str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_conformity);
+ tempfile_html =
+ str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_html);
+ tempfile_check =
+ str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_check);
+ tempfile_sh =
+ str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_sh);
+
+ std::ofstream alignment_file;
+ alignment_file.open(tempfile_alignment.c_str());
+ alignment_file << alignment;
+ alignment_file.close();
+
+ if (!conformity.empty())
+ {
+ std::ofstream conformity_file;
+ conformity_file.open(tempfile_conformity.c_str());
+ conformity_file << conformity;
+ conformity_file.close();
+ }
+
+ std::string conformity_option = "";
+ if (!conformity.empty())
+ {
+ conformity_option = str(boost::format("-c %s") % tempfile_conformity);
+ }
+
+ std::string cmd = str(
+ boost::format("cd %s ; "
+ "%s %s -i %s %s -H %s -d %s -m %s -t %s -T %s; "
+ "echo 'f' > %s;")
+ % Malakite::temp_path
+ % Malakite::python_path % Malakite::blocks3d_path
+ % tempfile_alignment
+ % conformity_option
+ % tempfile_html
+ % delta_input->text().toUTF8() % min_block_width_input->text().toUTF8()
+ % timeout_input->text().toUTF8() % timeout2_input->text().toUTF8()
+ % tempfile_check
+ );
+
+ std::cout << cmd << std::endl;
+
+ std::ofstream tempfile_sh_file;
+ tempfile_sh_file.open(tempfile_sh.c_str());
+ tempfile_sh_file << cmd;
+ tempfile_sh_file.close();
+
+ // security???
+ system(str(boost::format("sh %s &") % tempfile_sh.c_str()).c_str());
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Task start", results_panel);
+
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Time elapsed: ", results_panel);
+ worktime = new Worktime(results_panel);
+
+ timer->start();
+
+}
+
+void Blocks3DWidget::timeout()
+{
+ worktime->render();
+ // FIXME: check status of task
+ std::ifstream check_file;
+ check_file.open(tempfile_check.c_str());
+ if (!check_file)
+ {
+ return;
+ }
+ check_file.close();
+
+ timer->stop();
+ worktime->stop();
+
+ std::ifstream tempfile_html_file;
+ tempfile_html_file.open(tempfile_html.c_str());
+ if (!tempfile_html_file)
+ {
+ //~ Wt::WMessageBox::show("Ok", "Ok", Wt::Ok);
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Task failed. Please contact developer", results_panel);
+ return;
+ }
+ tempfile_html_file.close();
+
+ new Wt::WBreak(results_panel);
+ new Wt::WText("Task finished", results_panel);
+
+ new Wt::WText(" | ", results_panel);
+ Wt::WFileResource* html_view =
+ new Wt::WFileResource("text/html", tempfile_html, this);
+ Wt::WAnchor* a_view = new Wt::WAnchor(html_view, "View", results_panel);
+ a_view->setTarget(Wt::TargetNewWindow);
+
+ new Wt::WText(" | ", results_panel);
+ Wt::WFileResource* html_download =
+ new Wt::WFileResource("application/html", tempfile_html, this);
+ new Wt::WAnchor(html_download, "Download", results_panel);
+
+ // FIXME Anchor
+
+}
+
+
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/blocks3d-wt-widget.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/blocks3d-wt-widget.h Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,60 @@
+#ifndef MALAKITE_BLOCKS3D_WIDGET_H_
+#define MALAKITE_BLOCKS3D_WIDGET_H_
+
+#include "config.h"
+#include "work-time.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+class Blocks3DWidget : public Wt::WContainerWidget
+{
+public:
+ Blocks3DWidget(Wt::WContainerWidget *parent=0);
+private:
+ Wt::WFileUpload* alignment_upload;
+ Wt::WTextArea* alignment_textarea;
+ Wt::WFileUpload* conformity_upload;
+ Wt::WTextArea* conformity_textarea;
+
+ Wt::WLineEdit* delta_input;
+ Wt::WLineEdit* min_block_width_input;
+ Wt::WLineEdit* timeout_input;
+ Wt::WLineEdit* timeout2_input;
+
+ Wt::WDoubleValidator *delta_validator;
+ Wt::WIntValidator *min_block_width_validator;
+ Wt::WIntValidator *timeout_validator;
+ Wt::WIntValidator *timeout2_validator;
+
+ Wt::WContainerWidget* results_panel;
+ Wt::WTimer* timer;
+ Worktime* worktime;
+
+ std::string tempfile_alignment;
+ std::string tempfile_conformity;
+ std::string tempfile_html;
+ std::string tempfile_check;
+ std::string tempfile_sh;
+
+ void textarea_from_file(Wt::WTextArea* ta, const char* file);
+ void go_button_click();
+ void alignment_uploaded();
+ void conformity_uploaded();
+ void fileTooLarge();
+ void try_to_run();
+ void timeout();
+ //~ void execute();
+};
+
+#endif // MALAKITE_BLOCKS3D_WIDGET_H_
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/blocks3d-wt.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/blocks3d-wt.C Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,46 @@
+
+#include "config.h"
+#include "blocks3d-wt-widget.h"
+
+#include
+#include
+#include
+
+
+class Blocks3DApplication : public Wt::WApplication
+{
+public:
+ Blocks3DApplication(const Wt::WEnvironment& env);
+private:
+ Blocks3DWidget* blocks3d_widget;
+};
+
+Blocks3DApplication::Blocks3DApplication(const Wt::WEnvironment& env) :
+ Wt::WApplication(env)
+{
+ useStyleSheet("/files/css/1.css");
+ blocks3d_widget = new Blocks3DWidget(root());
+}
+
+
+
+
+Wt::WApplication* createApplication(const Wt::WEnvironment& env)
+{
+ return new Blocks3DApplication(env);
+}
+
+int main(int argc, char **argv)
+{
+ Wt::WServer server(argv[0]);
+ server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
+
+ server.addEntryPoint(Wt::Application, createApplication, Malakite::main_url);
+
+ if (server.start()) {
+ Wt::WServer::waitForShutdown();
+ server.stop();
+ }
+}
+
+
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/blocks3d-wt.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/blocks3d-wt.pro Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,15 @@
+TARGET = blocks3d-wt.exe
+
+SOURCES += config.C
+SOURCES += salt.C
+SOURCES += blocks3d-wt.C
+SOURCES += blocks3d-wt-widget.C
+SOURCES += work-time.C
+
+CONFIG += debug
+CONFIG += precompile_header
+
+
+INCLUDEPATH = /usr/local/include/Wt/
+
+LIBS += -lwthttp -lwt
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/compile.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/compile.sh Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,5 @@
+cd build;
+qmake ../blocks3d-wt.pro && make VERBOSE=0
+#~ cmake .. && make VERBOSE=1
+
+
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/compile_and_run.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/compile_and_run.sh Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,1 @@
+./compile.sh && ./run.sh
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/config.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/config.C Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,35 @@
+
+#include "config.h"
+#include
+#include
+
+
+namespace Malakite
+{
+
+const char* python_path = "python";
+const char* blocks3d_path = "/home/boris/my-code/Blocks3D/Blocks3D_v5/Blocks3D.py";
+const char* temp_path = "/tmp";
+
+const char* main_url = "/";
+
+const char* tempfile_alignment = "in_aln.fasta";
+const char* tempfile_conformity = "in_conf.fasta";
+const char* tempfile_html = "out.html";
+const char* tempfile_check = "check.lock";
+const char* tempfile_sh = "run.sh";
+
+namespace defaults
+{
+
+const char* delta = "2.0";
+const char* min_block_width = "3";
+const char* timeout = "10";
+const char* timeout2 = "10";
+
+}
+
+
+
+}
+
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/config.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/config.h Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,34 @@
+#ifndef MALAKITE_BLOCKS3D_CONFIG_H_
+#define MALAKITE_BLOCKS3D_CONFIG_H_
+
+namespace Malakite
+{
+
+const int refresh_period = 5*1000;
+
+
+extern const char* python_path;
+extern const char* blocks3d_path;
+extern const char* temp_path;
+
+extern const char* main_url;
+
+extern const char* tempfile_alignment;
+extern const char* tempfile_conformity;
+extern const char* tempfile_html;
+extern const char* tempfile_check;
+extern const char* tempfile_sh;
+
+namespace defaults
+{
+
+extern const char* delta;
+extern const char* min_block_width;
+extern const char* timeout;
+extern const char* timeout2;
+
+}
+
+}
+
+#endif // MALAKITE_BLOCKS3D_CONFIG_H_s
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/debug.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/debug.sh Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,3 @@
+cd ./build/;
+gdb --args ./blocks3d-wt.exe -- run --docroot . --http-address 0.0.0.0 --http-port 8000
+
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/files/css/1.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/files/css/1.css Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,5 @@
+
+.header {
+ font-size: 250%;
+ font-weight: bold;
+}
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/files/js/jquery.countdown.pack.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/files/js/jquery.countdown.pack.js Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,7 @@
+/* http://keith-wood.name/countdown.html
+ Countdown for jQuery v1.5.8.
+ Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
+ Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
+ MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
+ Please attribute the author if you use it. */
+eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(B($){B 1i(){8.1D=[];8.1D[\'\']={1j:[\'2C\',\'2D\',\'2E\',\'2F\',\'2G\',\'2H\',\'2I\'],2J:[\'2K\',\'2L\',\'2M\',\'2N\',\'2O\',\'2P\',\'2Q\'],1k:[\'y\',\'m\',\'w\',\'d\'],1u:E,1E:\':\',1V:Q};8.1g={1W:E,1X:E,1Y:E,1Z:E,20:\'2R\',1l:\'\',21:Q,1v:0,1F:\'\',22:\'\',23:\'\',25:Q,26:E,27:E,28:1};$.1m(8.1g,8.1D[\'\']);8.1n=[]}x w=\'G\';x Y=0;x O=1;x W=2;x D=3;x H=4;x M=5;x S=6;$.1m(1i.29,{1o:\'2S\',2T:2U(B(){$.G.2a()},2V),19:[],2W:B(a){8.1G(8.1g,a);1H(8.1g,a||{})},1I:B(a,b,c,e,f,g,h,i){A(1p b==\'2X\'&&b.2Y==P){i=b.1J();h=b.1K();g=b.1L();f=b.1M();e=b.T();c=b.17();b=b.18()}x d=K P();d.2Z(b);d.2b(1);d.31(c||0);d.2b(e||1);d.33(f||0);d.34((g||0)-(U.35(a)<30?a*1a:a));d.36(h||0);d.37(i||0);F d},2c:B(a){F a[0]*38+a[1]*39+a[2]*2d+a[3]*2e+a[4]*2f+a[5]*1a+a[6]},3a:B(a,b){A(!b){F $.G.1g}x c=$.X(a,w);F(b==\'3b\'?c.Z:c.Z[b])},2g:B(a,b){x c=$(a);A(c.2h(8.1o)){F}c.3c(8.1o);x d={Z:$.1m({},b),z:[0,0,0,0,0,0,0]};$.X(a,w,d);8.2i(a)},1N:B(a){A(!8.1O(a)){8.19.2j(a)}},1O:B(a){F($.3d(a,8.19)>-1)},1w:B(b){8.19=$.3e(8.19,B(a){F(a==b?E:a)})},2a:B(){V(x i=8.19.1x-1;i>=0;i--){8.1q(8.19[i])}},1q:B(a,b){x c=$(a);b=b||$.X(a,w);A(!b){F}c.3f(8.2k(b));c[(8.C(b,\'1V\')?\'3g\':\'3h\')+\'3i\'](\'3j\');x d=8.C(b,\'27\');A(d){x e=b.R!=\'2l\'?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P());x f=8.C(b,\'28\');A(f==1||8.2c(e)%f==0){d.1r(a,[e])}}x g=b.R!=\'1s\'&&(b.I?b.1b.L()=b.13.L());A(g&&!b.1P){b.1P=1Q;A(8.1O(a)||8.C(b,\'25\')){8.1w(a);x h=8.C(b,\'26\');A(h){h.1r(a,[])}x i=8.C(b,\'23\');A(i){x j=8.C(b,\'1l\');b.Z.1l=i;8.1q(a,b);b.Z.1l=j}x k=8.C(b,\'22\');A(k){3k.3l=k}}b.1P=Q}1c A(b.R==\'1s\'){8.1w(a)}$.X(a,w,b)},2i:B(a,b,c){b=b||{};A(1p b==\'1R\'){x d=b;b={};b[d]=c}x e=$.X(a,w);A(e){8.1G(e.Z,b);1H(e.Z,b);8.2m(a,e);$.X(a,w,e);x f=K P();A((e.I&&e.If)){8.1N(a)}8.1q(a,e)}},1G:B(a,b){x c=Q;V(x n 1S b){A(n!=\'1u\'&&n.N(/[2n]2o/)){c=1Q;14}}A(c){V(x n 1S a){A(n.N(/[2n]2o[0-9]/)){a[n]=E}}}},2m:B(a,b){x c;x d=8.C(b,\'1Z\');x e=0;x f=E;V(x i=0;i<8.1n.1x;i++){A(8.1n[i][0]==d){f=8.1n[i][1];14}}A(f!=E){e=(d?f:0);c=K P()}1c{x g=(d?d.1r(a,[]):E);c=K P();e=(g?c.L()-g.L():0);8.1n.2j([d,e])}x h=8.C(b,\'1Y\');h=(h==E?-c.3m():h);b.I=8.C(b,\'1X\');A(b.I!=E){b.I=8.1I(h,8.1z(b.I,E));A(b.I&&e){b.I.1A(b.I.1J()+e)}}b.13=8.1I(h,8.1z(8.C(b,\'1W\'),c));A(e){b.13.1A(b.13.1J()+e)}b.11=8.2p(b)},3n:B(a){x b=$(a);A(!b.2h(8.1o)){F}8.1w(a);b.3o(8.1o).3p();$.3q(a,w)},3r:B(a){8.R(a,\'1s\')},3s:B(a){8.R(a,\'2l\')},3t:B(a){8.R(a,E)},R:B(a,b){x c=$.X(a,w);A(c){A(c.R==\'1s\'&&!b){c.z=c.2q;x d=(c.I?\'-\':\'+\');c[c.I?\'I\':\'13\']=8.1z(d+c.z[0]+\'y\'+d+c.z[1]+\'o\'+d+c.z[2]+\'w\'+d+c.z[3]+\'d\'+d+c.z[4]+\'h\'+d+c.z[5]+\'m\'+d+c.z[6]+\'s\');8.1N(a)}c.R=b;c.2q=(b==\'1s\'?c.z:E);$.X(a,w,c);8.1q(a,c)}},3u:B(a){x b=$.X(a,w);F(!b?E:(!b.R?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P())))},C:B(a,b){F(a.Z[b]!=E?a.Z[b]:$.G.1g[b])},1z:B(k,l){x m=B(a){x b=K P();b.2r(b.L()+a*15);F b};x n=B(a){a=a.3v();x b=K P();x c=b.18();x d=b.17();x e=b.T();x f=b.1M();x g=b.1L();x h=b.1K();x i=/([+-]?[0-9]+)\\s*(s|m|h|d|w|o|y)?/g;x j=i.2s(a);3w(j){3x(j[2]||\'s\'){1d\'s\':h+=1e(j[1],10);14;1d\'m\':g+=1e(j[1],10);14;1d\'h\':f+=1e(j[1],10);14;1d\'d\':e+=1e(j[1],10);14;1d\'w\':e+=1e(j[1],10)*7;14;1d\'o\':d+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14;1d\'y\':c+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14}j=i.2s(a)}F K P(c,d,e,f,g,h,0)};x o=(k==E?l:(1p k==\'1R\'?n(k):(1p k==\'3y\'?m(k):k)));A(o)o.1A(0);F o},1h:B(a,b){F 32-K P(a,b,32).T()},1T:B(a){F a},2k:B(c){x d=8.C(c,\'1v\');c.z=(c.R?c.z:8.1y(c,c.11,d,K P()));x e=Q;x f=0;x g=d;x h=$.1m({},c.11);V(x i=Y;i<=S;i++){e|=(c.11[i]==\'?\'&&c.z[i]>0);h[i]=(c.11[i]==\'?\'&&!e?E:c.11[i]);f+=(h[i]?1:0);g-=(c.z[i]>0?1:0)}x j=[Q,Q,Q,Q,Q,Q,Q];V(x i=S;i>=Y;i--){A(c.11[i]){A(c.z[i]){j[i]=1Q}1c{j[i]=g>0;g--}}}x k=8.C(c,\'21\');x l=8.C(c,\'1l\');x m=(k?8.C(c,\'1k\'):8.C(c,\'1j\'));x n=8.C(c,\'1u\')||8.1T;x o=8.C(c,\'1E\');x p=8.C(c,\'1F\')||\'\';x q=B(a){x b=$.G.C(c,\'1k\'+n(c.z[a]));F(h[a]?c.z[a]+(b?b[a]:m[a])+\' \':\'\')};x r=B(a){x b=$.G.C(c,\'1j\'+n(c.z[a]));F((!d&&h[a])||(d&&j[a])?\'<16 1t="3z"><16 1t="2t">\'+c.z[a]+\'<3A/>\'+(b?b[a]:m[a])+\'\':\'\')};F(l?8.2u(c,h,l,k,d,j):((k?\'<16 1t="1U 2t\'+(c.R?\' 2v\':\'\')+\'">\'+q(Y)+q(O)+q(W)+q(D)+(h[H]?8.J(c.z[H],2):\'\')+(h[M]?(h[H]?o:\'\')+8.J(c.z[M],2):\'\')+(h[S]?(h[H]||h[M]?o:\'\')+8.J(c.z[S],2):\'\'):\'<16 1t="1U 3B\'+(d||f)+(c.R?\' 2v\':\'\')+\'">\'+r(Y)+r(O)+r(W)+r(D)+r(H)+r(M)+r(S))+\'\'+(p?\'<16 1t="1U 3C">\'+p+\'\':\'\')))},2u:B(c,d,e,f,g,h){x j=8.C(c,(f?\'1k\':\'1j\'));x k=8.C(c,\'1u\')||8.1T;x l=B(a){F($.G.C(c,(f?\'1k\':\'1j\')+k(c.z[a]))||j)[a]};x m=B(a,b){F U.1C(a/b)%10};x o={3D:8.C(c,\'1F\'),3E:8.C(c,\'1E\'),3F:l(Y),3G:c.z[Y],3H:8.J(c.z[Y],2),3I:8.J(c.z[Y],3),3J:m(c.z[Y],1),3K:m(c.z[Y],10),3L:m(c.z[Y],1f),3M:m(c.z[Y],15),3N:l(O),3O:c.z[O],3P:8.J(c.z[O],2),3Q:8.J(c.z[O],3),3R:m(c.z[O],1),3S:m(c.z[O],10),3T:m(c.z[O],1f),3U:m(c.z[O],15),3V:l(W),3W:c.z[W],3X:8.J(c.z[W],2),3Y:8.J(c.z[W],3),3Z:m(c.z[W],1),40:m(c.z[W],10),41:m(c.z[W],1f),42:m(c.z[W],15),43:l(D),44:c.z[D],45:8.J(c.z[D],2),46:8.J(c.z[D],3),47:m(c.z[D],1),48:m(c.z[D],10),49:m(c.z[D],1f),4a:m(c.z[D],15),4b:l(H),4c:c.z[H],4d:8.J(c.z[H],2),4e:8.J(c.z[H],3),4f:m(c.z[H],1),4g:m(c.z[H],10),4h:m(c.z[H],1f),4i:m(c.z[H],15),4j:l(M),4k:c.z[M],4l:8.J(c.z[M],2),4m:8.J(c.z[M],3),4n:m(c.z[M],1),4o:m(c.z[M],10),4p:m(c.z[M],1f),4q:m(c.z[M],15),4r:l(S),4s:c.z[S],4t:8.J(c.z[S],2),4u:8.J(c.z[S],3),4v:m(c.z[S],1),4w:m(c.z[S],10),4x:m(c.z[S],1f),4y:m(c.z[S],15)};x p=e;V(x i=Y;i<=S;i++){x q=\'4z\'.4A(i);x r=K 2w(\'\\\\{\'+q+\'<\\\\}(.*)\\\\{\'+q+\'>\\\\}\',\'g\');p=p.2x(r,((!g&&d[i])||(g&&h[i])?\'$1\':\'\'))}$.2y(o,B(n,v){x a=K 2w(\'\\\\{\'+n+\'\\\\}\',\'g\');p=p.2x(a,v)});F p},J:B(a,b){a=\'\'+a;A(a.1x>=b){F a}a=\'4B\'+a;F a.4C(a.1x-b)},2p:B(a){x b=8.C(a,\'20\');x c=[];c[Y]=(b.N(\'y\')?\'?\':(b.N(\'Y\')?\'!\':E));c[O]=(b.N(\'o\')?\'?\':(b.N(\'O\')?\'!\':E));c[W]=(b.N(\'w\')?\'?\':(b.N(\'W\')?\'!\':E));c[D]=(b.N(\'d\')?\'?\':(b.N(\'D\')?\'!\':E));c[H]=(b.N(\'h\')?\'?\':(b.N(\'H\')?\'!\':E));c[M]=(b.N(\'m\')?\'?\':(b.N(\'M\')?\'!\':E));c[S]=(b.N(\'s\')?\'?\':(b.N(\'S\')?\'!\':E));F c},1y:B(c,d,e,f){c.1b=f;c.1b.1A(0);x g=K P(c.1b.L());A(c.I){A(f.L()c.13.L()){c.1b=f=g}}x h=[0,0,0,0,0,0,0];A(d[Y]||d[O]){x i=$.G.1h(f.18(),f.17());x j=$.G.1h(g.18(),g.17());x k=(g.T()==f.T()||(g.T()>=U.1B(i,j)&&f.T()>=U.1B(i,j)));x l=B(a){F(a.1M()*1a+a.1L())*1a+a.1K()};x m=U.4D(0,(g.18()-f.18())*12+g.17()-f.17()+((g.T()o){f.2z(o)}f.4E(f.18()+h[Y]);f.4F(f.17()+h[O]);A(n){f.2z(o)}}x p=U.1C((g.L()-f.L())/15);x q=B(a,b){h[a]=(d[a]?U.1C(p/b):0);p-=h[a]*b};q(W,2d);q(D,2e);q(H,2f);q(M,1a);q(S,1);A(p>0&&!c.I){x r=[1,12,4.4G,7,24,1a,1a];x s=S;x t=1;V(x u=S;u>=Y;u--){A(d[u]){A(h[s]>=t){h[s]=0;p=1}A(p>0){h[u]++;p=0;s=u;t=1}}t*=r[u]}}A(e){V(x u=Y;u<=S;u++){A(e&&h[u]){e--}1c A(!e){h[u]=0}}}F h}});B 1H(a,b){$.1m(a,b);V(x c 1S b){A(b[c]==E){a[c]=E}}F a}$.4H.G=B(a){x b=4I.29.4J.4K(4L,1);A(a==\'4M\'||a==\'4N\'){F $.G[\'2A\'+a+\'1i\'].1r($.G,[8[0]].2B(b))}F 8.2y(B(){A(1p a==\'1R\'){$.G[\'2A\'+a+\'1i\'].1r($.G,[8].2B(b))}1c{$.G.2g(8,a)}})};$.G=K 1i()})(4O);',62,299,'||||||||this|||||||||||||||||||||||||var||_periods|if|function|_get||null|return|countdown||_since|_minDigits|new|getTime||match||Date|false|_hold||getDate|Math|for||data||options||_show||_until|break|1000|span|getMonth|getFullYear|_timerTargets|60|_now|else|case|parseInt|100|_defaults|_getDaysInMonth|Countdown|labels|compactLabels|layout|extend|_serverSyncs|markerClassName|typeof|_updateCountdown|apply|pause|class|whichLabels|significant|_removeTarget|length|_calculatePeriods|_determineTime|setMilliseconds|min|floor|regional|timeSeparator|description|_resetExtraLabels|extendRemove|UTCDate|getMilliseconds|getSeconds|getMinutes|getHours|_addTarget|_hasTarget|_expiring|true|string|in|_normalLabels|countdown_row|isRTL|until|since|timezone|serverSync|format|compact|expiryUrl|expiryText||alwaysExpire|onExpiry|onTick|tickInterval|prototype|_updateTargets|setUTCDate|periodsToSeconds|604800|86400|3600|_attachCountdown|hasClass|_changeCountdown|push|_generateHTML|lap|_adjustSettings|Ll|abels|_determineShow|_savePeriods|setTime|exec|countdown_amount|_buildLayout|countdown_holding|RegExp|replace|each|setDate|_|concat|Years|Months|Weeks|Days|Hours|Minutes|Seconds|labels1|Year|Month|Week|Day|Hour|Minute|Second|dHMS|hasCountdown|_timer|setInterval|980|setDefaults|object|constructor|setUTCFullYear||setUTCMonth||setUTCHours|setUTCMinutes|abs|setUTCSeconds|setUTCMilliseconds|31557600|2629800|_settingsCountdown|all|addClass|inArray|map|html|add|remove|Class|countdown_rtl|window|location|getTimezoneOffset|_destroyCountdown|removeClass|empty|removeData|_pauseCountdown|_lapCountdown|_resumeCountdown|_getTimesCountdown|toLowerCase|while|switch|number|countdown_section|br|countdown_show|countdown_descr|desc|sep|yl|yn|ynn|ynnn|y1|y10|y100|y1000|ol|on|onn|onnn|o1|o10|o100|o1000|wl|wn|wnn|wnnn|w1|w10|w100|w1000|dl|dn|dnn|dnnn|d1|d10|d100|d1000|hl|hn|hnn|hnnn|h1|h10|h100|h1000|ml|mn|mnn|mnnn|m1|m10|m100|m1000|sl|sn|snn|snnn|s1|s10|s100|s1000|yowdhms|charAt|0000000000|substr|max|setFullYear|setMonth|3482|fn|Array|slice|call|arguments|getTimes|settings|jQuery'.split('|'),0,{}))
\ No newline at end of file
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/run.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/run.sh Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,2 @@
+cd ./build/;
+./blocks3d-wt.exe --docroot . --http-address 0.0.0.0 --http-port 8000
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/salt.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/salt.C Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,21 @@
+
+#include "salt.h"
+
+std::string generateSalt() {
+ /* Salt generation from glibc manual */
+ unsigned long seed[2];
+ char salt[] = "_1_........";
+ const char *const seedchars =
+ "./0123456789ABCDEFGHIJKLMNOPQRST"
+ "UVWXYZabcdefghijklmnopqrstuvwxyz";
+
+ /* Generate a (not very) random seed. */
+ seed[0] = time(NULL);
+ seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
+
+ /* Turn it into printable characters from `seedchars'. */
+ for (int i = 0; i < 8; i++)
+ salt[3+i] = seedchars[(seed[i/5] >> (i%5)*6) & 0x3f];
+
+ return salt;
+}
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/salt.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/salt.h Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,8 @@
+#ifndef SALT_H_
+#define SALT_H_
+
+#include
+
+std::string generateSalt();
+
+#endif // SALT_H_
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/work-time.C
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/work-time.C Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,58 @@
+
+#include "work-time.h"
+#include
+#include
+
+
+Worktime::Worktime(Wt::WContainerWidget *parent) :
+ WText(parent), stoped(false)
+{
+ wApp->require("/files/js/jquery.countdown.pack.js");
+ start_at = now();
+ stop_at = now(); // ??
+ render();
+}
+
+std::string Worktime::int2time(posix::time_duration secs)
+{
+ posix::seconds secs1(secs.total_seconds());
+ return to_simple_string(secs1);
+}
+
+void Worktime::stop()
+{
+ stoped = true;
+ stop_at = now();
+ //~ setId(generateSalt()); // switch off countdown
+ render();
+}
+
+void Worktime::render()
+{
+ if (!stoped)
+ {
+ doJavaScript("$('#" + id() + "').countdown({"
+ "since: -" + boost::lexical_cast(
+ spent().total_milliseconds()) + " / 1000,"
+ "compact: true"
+ "});");
+ }
+ else
+ {
+ doJavaScript("$('#" + id() + "').countdown('pause');");
+ }
+
+ setText(int2time(spent()));
+};
+
+posix::time_duration Worktime::spent()
+{
+ if (stoped)
+ {
+ return stop_at - start_at;
+ }
+ else
+ {
+ return now() - start_at;
+ }
+}
diff -r 7a770b1abe23 -r df3181ce15f2 blocks3d/wt/work-time.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/work-time.h Thu Sep 16 15:49:55 2010 +0400
@@ -0,0 +1,27 @@
+
+#ifndef WORKTIME_H_
+#define WORKTIME_H_
+
+#include
+#include
+
+#include
+namespace posix = boost::posix_time;
+
+class Worktime : public Wt::WText
+{
+public:
+ Worktime(Wt::WContainerWidget *parent=0);
+ void render();
+ void stop();
+ inline posix::ptime now() { return posix::microsec_clock::universal_time(); }
+ inline posix::time_duration spent();
+private:
+ posix::ptime start_at;
+ posix::ptime stop_at;
+ bool stoped;
+ std::string int2time(posix::time_duration secs);
+};
+
+
+#endif // WORKTIME_H_