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

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

allpy

changeset 62:df3181ce15f2

committing hg merge
author boris (netbook) <bnagaev@gmail.com>
date Thu, 16 Sep 2010 15:49:55 +0400
parents 7a770b1abe23 d38863e21ada
children 90767fa9bff9
files .hgignore
diffstat 18 files changed, 655 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.geany	Thu Sep 16 15:49:55 2010 +0400
     1.3 @@ -0,0 +1,29 @@
     1.4 +
     1.5 +[indentation]
     1.6 +indent_width=2
     1.7 +indent_type=1
     1.8 +indent_hard_tab_width=2
     1.9 +detect_indent=true
    1.10 +indent_mode=2
    1.11 +
    1.12 +[project]
    1.13 +name=malakite-blocks3d-wt
    1.14 +base_path=/home/boris/my-code/Blocks3D/malakite-blocks3d-wt
    1.15 +make_in_base_path=false
    1.16 +description=
    1.17 +run_cmd=
    1.18 +
    1.19 +[files]
    1.20 +current_page=10
    1.21 +FILE_NAME_0=141;None;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt.pro;0
    1.22 +FILE_NAME_1=124;C;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/config.h;0
    1.23 +FILE_NAME_2=479;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/config.C;0
    1.24 +FILE_NAME_3=451;C++;0;16;0;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt.C;0
    1.25 +FILE_NAME_4=1072;C;0;16;0;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt-widget.h;0
    1.26 +FILE_NAME_5=3752;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/blocks3d-wt-widget.C;0
    1.27 +FILE_NAME_6=44;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/salt.C;0
    1.28 +FILE_NAME_7=419;C;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/work-time.h;0
    1.29 +FILE_NAME_8=24;C++;0;16;1;1;1;/home/boris/my-code/Blocks3D/malakite-blocks3d-wt/work-time.C;0
    1.30 +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
    1.31 +FILE_NAME_10=1229;None;0;16;0;1;1;/home/boris/helps/hg.txt;0
    1.32 +FILE_NAME_11=0;None;0;16;0;1;1;/home/boris/helps/LINUX.txt;0
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgtags	Thu Sep 16 15:49:55 2010 +0400
     2.3 @@ -0,0 +1,1 @@
     2.4 +c51ef42eb5e5c2c98dac3c99271777905fb4da76 first run
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/blocks3d/wt/blocks3d-wt-widget.C	Thu Sep 16 15:49:55 2010 +0400
     3.3 @@ -0,0 +1,298 @@
     3.4 +
     3.5 +#include "config.h"
     3.6 +#include "blocks3d-wt-widget.h"
     3.7 +#include "salt.h"
     3.8 +
     3.9 +#include <Wt/WText>
    3.10 +#include <Wt/WBreak>
    3.11 +#include <Wt/WTable>
    3.12 +#include <Wt/WLabel>
    3.13 +#include <Wt/WDoubleValidator>
    3.14 +#include <Wt/WIntValidator>
    3.15 +#include <Wt/WMessageBox>
    3.16 +#include <Wt/WAnchor>
    3.17 +#include <Wt/WFileResource>
    3.18 +
    3.19 +#include <fstream>
    3.20 +#include <iostream>
    3.21 +#include <boost/format.hpp>
    3.22 +#include <stdlib.h>
    3.23 +
    3.24 +Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget *parent) :
    3.25 +	Wt::WContainerWidget(parent)
    3.26 +{
    3.27 +	Wt::WText* head = new Wt::WText("Blocks3D", this); 
    3.28 +	head->setStyleClass("header");
    3.29 +	
    3.30 +	alignment_upload = new Wt::WFileUpload();
    3.31 +	alignment_textarea = new Wt::WTextArea();
    3.32 +	alignment_textarea->setColumns(60);
    3.33 +	alignment_textarea->setRows(20);
    3.34 +	conformity_upload = new Wt::WFileUpload();
    3.35 +	conformity_textarea = new Wt::WTextArea();
    3.36 +	conformity_textarea->setColumns(40);
    3.37 +	conformity_textarea->setRows(20);
    3.38 +	
    3.39 +	Wt::WLabel *alignment_label = new Wt::WLabel("Alignment:");
    3.40 +	alignment_label->setBuddy(alignment_textarea);
    3.41 +	
    3.42 +	Wt::WLabel *conformity_label = new Wt::WLabel("Confiomity file:");
    3.43 +	conformity_label->setBuddy(alignment_textarea);
    3.44 +	 
    3.45 +	new Wt::WBreak(this);
    3.46 +	Wt::WTable *table = new Wt::WTable(this);
    3.47 +	
    3.48 +	table->elementAt(0, 0)->addWidget(alignment_label);
    3.49 +	table->elementAt(1, 0)->addWidget(alignment_textarea);
    3.50 +	table->elementAt(2, 0)->addWidget(alignment_upload);
    3.51 +	
    3.52 +	table->elementAt(0, 1)->addWidget(conformity_label);
    3.53 +	table->elementAt(1, 1)->addWidget(conformity_textarea);
    3.54 +	table->elementAt(2, 1)->addWidget(conformity_upload);
    3.55 +	
    3.56 +	new Wt::WBreak(this);
    3.57 +	delta_input = new Wt::WLineEdit(Malakite::defaults::delta, this);
    3.58 +	delta_validator = new Wt::WDoubleValidator(0.0, 10.0); // FIXME: not to allow empty
    3.59 +	delta_validator->setMandatory(true);
    3.60 +	delta_input->setValidator(delta_validator);	
    3.61 +	Wt::WLabel *delta_label = new Wt::WLabel("Distance spreading", this);
    3.62 +	delta_label->setBuddy(delta_input);
    3.63 +	
    3.64 +	new Wt::WBreak(this);
    3.65 +	min_block_width_input = new Wt::WLineEdit(Malakite::defaults::min_block_width, this);
    3.66 +	min_block_width_validator = new Wt::WIntValidator(3, 9999);
    3.67 +	min_block_width_validator->setMandatory(true);
    3.68 +	min_block_width_input->setValidator(min_block_width_validator);	
    3.69 +	Wt::WLabel *min_block_width_label = new Wt::WLabel("Min block width", this);
    3.70 +	min_block_width_label->setBuddy(min_block_width_input);
    3.71 +	
    3.72 +	new Wt::WBreak(this);
    3.73 +	timeout_input = new Wt::WLineEdit(Malakite::defaults::timeout, this);
    3.74 +	timeout_validator = new Wt::WIntValidator(-1, 30*24*3600);
    3.75 +	timeout_validator->setMandatory(true);
    3.76 +	timeout_input->setValidator(timeout_validator);	
    3.77 +	Wt::WLabel *timeout_label = new Wt::WLabel(
    3.78 +		"Bron-Kerbosh (couple cores) timeout", this);
    3.79 +	timeout_label->setBuddy(timeout_input);
    3.80 +	
    3.81 +	new Wt::WBreak(this);
    3.82 +	timeout2_input = new Wt::WLineEdit(Malakite::defaults::timeout2, this);
    3.83 +	timeout2_validator = new Wt::WIntValidator(-1, 30*24*3600);
    3.84 +	timeout2_validator->setMandatory(true);
    3.85 +	timeout2_input->setValidator(timeout2_validator);	
    3.86 +	Wt::WLabel *timeout2_label = new Wt::WLabel(
    3.87 +		"Bron-Kerbosh (blocks) timeout", this);
    3.88 +	timeout2_label->setBuddy(timeout2_input);
    3.89 +	
    3.90 +	
    3.91 +	new Wt::WBreak(this);
    3.92 +	Wt::WPushButton *go_button = new Wt::WPushButton("Run", this);
    3.93 +	
    3.94 +	new Wt::WBreak(this);
    3.95 +	results_panel = new Wt::WContainerWidget(this);
    3.96 +	
    3.97 +	go_button->clicked().connect(this, &Blocks3DWidget::go_button_click);
    3.98 +	alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded);
    3.99 +	conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded);
   3.100 +	alignment_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
   3.101 +	conformity_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
   3.102 +	
   3.103 +	alignment_upload->changed().connect(alignment_upload, &Wt::WFileUpload::upload);
   3.104 +	conformity_upload->changed().connect(conformity_upload, &Wt::WFileUpload::upload);
   3.105 +	
   3.106 +	timer = new Wt::WTimer(this);
   3.107 +	timer->timeout().connect(this, &Blocks3DWidget::timeout);
   3.108 +	timer->setInterval(Malakite::refresh_period);
   3.109 +}
   3.110 +
   3.111 +void Blocks3DWidget::go_button_click()
   3.112 +{
   3.113 +	try_to_run();
   3.114 +}
   3.115 +
   3.116 +void Blocks3DWidget::fileTooLarge()
   3.117 +{
   3.118 +	Wt::WMessageBox::show("Error", "File too large", Wt::Ok);		
   3.119 +}
   3.120 +
   3.121 +void Blocks3DWidget::textarea_from_file(Wt::WTextArea* ta, const char* file)
   3.122 +{
   3.123 +	std::string temp("");
   3.124 +	std::string total("");
   3.125 +	std::ifstream uploaded_file;
   3.126 +
   3.127 +	uploaded_file.open(file);
   3.128 +	if (!uploaded_file) 
   3.129 +	{
   3.130 +		return;
   3.131 +	}
   3.132 +	while (uploaded_file >> temp) 
   3.133 +	{
   3.134 +		total += temp + "\n";
   3.135 +	}
   3.136 +	uploaded_file.close();
   3.137 +	
   3.138 +	ta->setText(total);
   3.139 +	
   3.140 +	new Wt::WBreak(results_panel);
   3.141 +	new Wt::WText("Upload finished", results_panel); 
   3.142 +}
   3.143 +
   3.144 +void Blocks3DWidget::alignment_uploaded()
   3.145 +{
   3.146 +	textarea_from_file(alignment_textarea, 
   3.147 +		alignment_upload->spoolFileName().c_str());
   3.148 +}
   3.149 +
   3.150 +void Blocks3DWidget::conformity_uploaded()
   3.151 +{
   3.152 +	textarea_from_file(conformity_textarea, 
   3.153 +		conformity_upload->spoolFileName().c_str());
   3.154 +}
   3.155 +
   3.156 +void Blocks3DWidget::try_to_run()
   3.157 +{
   3.158 +	std::string alignment = alignment_textarea->text().toUTF8();
   3.159 +	std::string conformity = conformity_textarea->text().toUTF8();
   3.160 +	if (alignment.empty())
   3.161 +	{
   3.162 +		new Wt::WBreak(results_panel);
   3.163 +		new Wt::WText("No alignment provided", results_panel); 
   3.164 +		return;
   3.165 +	}
   3.166 +	if (delta_input->validate() != Wt::WValidator::Valid)
   3.167 +	{
   3.168 +		new Wt::WBreak(results_panel);
   3.169 +		new Wt::WText("Enter delta parameter", results_panel); 
   3.170 +		return;
   3.171 +	}
   3.172 +	if (min_block_width_input->validate() != Wt::WValidator::Valid)
   3.173 +	{
   3.174 +		new Wt::WBreak(results_panel);
   3.175 +		new Wt::WText("Enter min block width parameter", results_panel); 
   3.176 +		return;
   3.177 +	}
   3.178 +	if (timeout_input->validate() != Wt::WValidator::Valid)
   3.179 +	{
   3.180 +		new Wt::WBreak(results_panel);
   3.181 +		new Wt::WText("Enter timeout parameter", results_panel); 
   3.182 +		return;
   3.183 +	}
   3.184 +	if (timeout2_input->validate() != Wt::WValidator::Valid)
   3.185 +	{
   3.186 +		new Wt::WBreak(results_panel);
   3.187 +		new Wt::WText("Enter timeout2 parameter", results_panel); 
   3.188 +		return;
   3.189 +	}
   3.190 +	
   3.191 +	std::string r = generateSalt();
   3.192 +	
   3.193 +	tempfile_alignment = 
   3.194 +	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_alignment);
   3.195 +	tempfile_conformity = 
   3.196 +	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_conformity);
   3.197 +	tempfile_html = 
   3.198 +	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_html);
   3.199 +	tempfile_check = 
   3.200 +	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_check);
   3.201 +	tempfile_sh = 
   3.202 +	str(boost::format("%s/%s_%s") % Malakite::temp_path % r % Malakite::tempfile_sh);
   3.203 +	
   3.204 +	std::ofstream alignment_file;
   3.205 +	alignment_file.open(tempfile_alignment.c_str());
   3.206 +	alignment_file << alignment;
   3.207 +	alignment_file.close();
   3.208 +	
   3.209 +	if (!conformity.empty())
   3.210 +	{
   3.211 +		std::ofstream conformity_file;
   3.212 +		conformity_file.open(tempfile_conformity.c_str());
   3.213 +		conformity_file << conformity;
   3.214 +		conformity_file.close();
   3.215 +	}
   3.216 +	
   3.217 +	std::string conformity_option = "";
   3.218 +	if (!conformity.empty())
   3.219 +	{
   3.220 +		conformity_option = str(boost::format("-c %s") % tempfile_conformity);
   3.221 +	}
   3.222 +	
   3.223 +	std::string cmd = str(
   3.224 +	boost::format("cd %s ; "
   3.225 +	"%s %s -i %s %s -H %s -d %s -m %s -t %s -T %s; "
   3.226 +	"echo 'f' > %s;") 
   3.227 +	% Malakite::temp_path
   3.228 +	% Malakite::python_path % Malakite::blocks3d_path 
   3.229 +	% tempfile_alignment 
   3.230 +	% conformity_option 
   3.231 +	% tempfile_html 
   3.232 +	% delta_input->text().toUTF8() % min_block_width_input->text().toUTF8()	
   3.233 +	% timeout_input->text().toUTF8() % timeout2_input->text().toUTF8()
   3.234 +	% tempfile_check 
   3.235 +	);	
   3.236 +	
   3.237 +	std::cout << cmd << std::endl;
   3.238 +	
   3.239 +	std::ofstream tempfile_sh_file;
   3.240 +	tempfile_sh_file.open(tempfile_sh.c_str());
   3.241 +	tempfile_sh_file << cmd;
   3.242 +	tempfile_sh_file.close();
   3.243 +	
   3.244 +	// security???
   3.245 +	system(str(boost::format("sh %s &") % tempfile_sh.c_str()).c_str());
   3.246 +	new Wt::WBreak(results_panel);
   3.247 +	new Wt::WText("Task start", results_panel);	
   3.248 +	
   3.249 +	new Wt::WBreak(results_panel);
   3.250 +	new Wt::WText("Time elapsed: ", results_panel);	
   3.251 +	worktime = new Worktime(results_panel);
   3.252 +	
   3.253 +	timer->start();
   3.254 +	
   3.255 +}
   3.256 +
   3.257 +void Blocks3DWidget::timeout()
   3.258 +{
   3.259 +	worktime->render();
   3.260 +	// FIXME: check status of task
   3.261 +	std::ifstream check_file;
   3.262 +	check_file.open(tempfile_check.c_str());
   3.263 +	if (!check_file) 
   3.264 +	{
   3.265 +		return;
   3.266 +	}
   3.267 +	check_file.close();
   3.268 +	
   3.269 +	timer->stop();
   3.270 +	worktime->stop();
   3.271 +	
   3.272 +	std::ifstream tempfile_html_file;
   3.273 +	tempfile_html_file.open(tempfile_html.c_str());
   3.274 +	if (!tempfile_html_file) 
   3.275 +	{
   3.276 +		//~ Wt::WMessageBox::show("Ok", "Ok", Wt::Ok);		
   3.277 +		new Wt::WBreak(results_panel);
   3.278 +		new Wt::WText("Task failed. Please contact developer", results_panel); 
   3.279 +		return; 
   3.280 +	}
   3.281 +	tempfile_html_file.close();
   3.282 +	
   3.283 +	new Wt::WBreak(results_panel);
   3.284 +	new Wt::WText("Task finished", results_panel); 
   3.285 +	
   3.286 +	new Wt::WText(" | ", results_panel); 
   3.287 +	Wt::WFileResource* html_view = 
   3.288 +	new Wt::WFileResource("text/html", tempfile_html, this);	
   3.289 +	Wt::WAnchor* a_view = new Wt::WAnchor(html_view, "View", results_panel);
   3.290 +	a_view->setTarget(Wt::TargetNewWindow);
   3.291 +	
   3.292 +	new Wt::WText(" | ", results_panel); 
   3.293 +	Wt::WFileResource* html_download = 
   3.294 +	new Wt::WFileResource("application/html", tempfile_html, this);	
   3.295 +	new Wt::WAnchor(html_download, "Download", results_panel);
   3.296 +	
   3.297 +	// FIXME Anchor
   3.298 +	
   3.299 +}
   3.300 +
   3.301 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/blocks3d/wt/blocks3d-wt-widget.h	Thu Sep 16 15:49:55 2010 +0400
     4.3 @@ -0,0 +1,60 @@
     4.4 +#ifndef MALAKITE_BLOCKS3D_WIDGET_H_
     4.5 +#define MALAKITE_BLOCKS3D_WIDGET_H_
     4.6 +
     4.7 +#include "config.h"
     4.8 +#include "work-time.h"
     4.9 +
    4.10 +#include <Wt/WPanel>
    4.11 +#include <Wt/WString>
    4.12 +#include <Wt/WHBoxLayout>
    4.13 +#include <Wt/WVBoxLayout>
    4.14 +#include <Wt/WImage>
    4.15 +
    4.16 +#include <Wt/WContainerWidget>
    4.17 +#include <Wt/WFileUpload>
    4.18 +#include <Wt/WTextArea>
    4.19 +#include <Wt/WPushButton>
    4.20 +#include <Wt/WLineEdit>
    4.21 +#include <Wt/WTimer>
    4.22 +
    4.23 +class Blocks3DWidget : public Wt::WContainerWidget
    4.24 +{
    4.25 +public:
    4.26 +  Blocks3DWidget(Wt::WContainerWidget *parent=0);
    4.27 +private:
    4.28 +  Wt::WFileUpload* alignment_upload;
    4.29 +  Wt::WTextArea* alignment_textarea;
    4.30 +  Wt::WFileUpload* conformity_upload;
    4.31 +  Wt::WTextArea* conformity_textarea;
    4.32 +  
    4.33 +  Wt::WLineEdit* delta_input;
    4.34 +  Wt::WLineEdit* min_block_width_input;
    4.35 +  Wt::WLineEdit* timeout_input;
    4.36 +  Wt::WLineEdit* timeout2_input;
    4.37 +  
    4.38 +  Wt::WDoubleValidator *delta_validator;
    4.39 +  Wt::WIntValidator *min_block_width_validator;
    4.40 +  Wt::WIntValidator *timeout_validator;
    4.41 +  Wt::WIntValidator *timeout2_validator;
    4.42 +  
    4.43 +  Wt::WContainerWidget* results_panel;
    4.44 +  Wt::WTimer* timer;
    4.45 +  Worktime* worktime;
    4.46 +  
    4.47 +  std::string tempfile_alignment;
    4.48 +  std::string tempfile_conformity;
    4.49 +  std::string tempfile_html;
    4.50 +  std::string tempfile_check;
    4.51 +  std::string tempfile_sh;
    4.52 +  
    4.53 +  void textarea_from_file(Wt::WTextArea* ta, const char* file);
    4.54 +  void go_button_click();
    4.55 +  void alignment_uploaded();
    4.56 +  void conformity_uploaded();
    4.57 +  void fileTooLarge();
    4.58 +  void try_to_run();
    4.59 +  void timeout();
    4.60 +  //~ void execute();
    4.61 +};
    4.62 +
    4.63 +#endif // MALAKITE_BLOCKS3D_WIDGET_H_
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/blocks3d/wt/blocks3d-wt.C	Thu Sep 16 15:49:55 2010 +0400
     5.3 @@ -0,0 +1,46 @@
     5.4 +
     5.5 +#include "config.h"
     5.6 +#include "blocks3d-wt-widget.h"
     5.7 +
     5.8 +#include <Wt/WEnvironment>
     5.9 +#include <Wt/WApplication>
    5.10 +#include <Wt/WServer>
    5.11 +
    5.12 +
    5.13 +class Blocks3DApplication : public Wt::WApplication
    5.14 +{
    5.15 +public:
    5.16 +  Blocks3DApplication(const Wt::WEnvironment& env);
    5.17 +private:
    5.18 +  Blocks3DWidget* blocks3d_widget;
    5.19 +};
    5.20 +
    5.21 +Blocks3DApplication::Blocks3DApplication(const Wt::WEnvironment& env) : 
    5.22 +  Wt::WApplication(env)
    5.23 +{
    5.24 +  useStyleSheet("/files/css/1.css");
    5.25 +  blocks3d_widget = new Blocks3DWidget(root());
    5.26 +}
    5.27 +
    5.28 +
    5.29 +
    5.30 +
    5.31 +Wt::WApplication* createApplication(const Wt::WEnvironment& env)
    5.32 +{
    5.33 +  return new Blocks3DApplication(env);
    5.34 +}
    5.35 +
    5.36 +int main(int argc, char **argv)
    5.37 +{
    5.38 +  Wt::WServer server(argv[0]);
    5.39 +  server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
    5.40 +  
    5.41 +  server.addEntryPoint(Wt::Application, createApplication, Malakite::main_url);
    5.42 +  
    5.43 +  if (server.start()) {
    5.44 +    Wt::WServer::waitForShutdown();
    5.45 +    server.stop();
    5.46 +  }
    5.47 +}
    5.48 +
    5.49 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/blocks3d/wt/blocks3d-wt.pro	Thu Sep 16 15:49:55 2010 +0400
     6.3 @@ -0,0 +1,15 @@
     6.4 +TARGET = blocks3d-wt.exe
     6.5 +
     6.6 +SOURCES += config.C
     6.7 +SOURCES += salt.C
     6.8 +SOURCES += blocks3d-wt.C
     6.9 +SOURCES += blocks3d-wt-widget.C
    6.10 +SOURCES += work-time.C
    6.11 +
    6.12 +CONFIG += debug
    6.13 +CONFIG += precompile_header
    6.14 +
    6.15 +
    6.16 +INCLUDEPATH = /usr/local/include/Wt/
    6.17 +
    6.18 +LIBS += -lwthttp -lwt
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/blocks3d/wt/compile.sh	Thu Sep 16 15:49:55 2010 +0400
     7.3 @@ -0,0 +1,5 @@
     7.4 +cd build;
     7.5 +qmake ../blocks3d-wt.pro && make VERBOSE=0
     7.6 +#~ cmake .. && make VERBOSE=1
     7.7 +
     7.8 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/blocks3d/wt/compile_and_run.sh	Thu Sep 16 15:49:55 2010 +0400
     8.3 @@ -0,0 +1,1 @@
     8.4 +./compile.sh && ./run.sh
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/blocks3d/wt/config.C	Thu Sep 16 15:49:55 2010 +0400
     9.3 @@ -0,0 +1,35 @@
     9.4 +
     9.5 +#include "config.h"
     9.6 +#include <boost/format.hpp>
     9.7 +#include <string>
     9.8 +
     9.9 +
    9.10 +namespace Malakite
    9.11 +{
    9.12 +
    9.13 +const char* python_path = "python";
    9.14 +const char* blocks3d_path = "/home/boris/my-code/Blocks3D/Blocks3D_v5/Blocks3D.py";
    9.15 +const char* temp_path = "/tmp";
    9.16 +
    9.17 +const char* main_url = "/";
    9.18 +
    9.19 +const char* tempfile_alignment = "in_aln.fasta";
    9.20 +const char* tempfile_conformity = "in_conf.fasta";
    9.21 +const char* tempfile_html = "out.html";
    9.22 +const char* tempfile_check = "check.lock";
    9.23 +const char* tempfile_sh = "run.sh";
    9.24 +
    9.25 +namespace defaults
    9.26 +{
    9.27 +
    9.28 +const char* delta = "2.0";
    9.29 +const char* min_block_width = "3";
    9.30 +const char* timeout = "10";
    9.31 +const char* timeout2 = "10";
    9.32 +
    9.33 +}
    9.34 +
    9.35 +
    9.36 +
    9.37 +}
    9.38 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/blocks3d/wt/config.h	Thu Sep 16 15:49:55 2010 +0400
    10.3 @@ -0,0 +1,34 @@
    10.4 +#ifndef MALAKITE_BLOCKS3D_CONFIG_H_
    10.5 +#define MALAKITE_BLOCKS3D_CONFIG_H_
    10.6 +
    10.7 +namespace Malakite
    10.8 +{
    10.9 +
   10.10 +const int refresh_period = 5*1000;
   10.11 +
   10.12 +
   10.13 +extern const char* python_path;
   10.14 +extern const char* blocks3d_path;
   10.15 +extern const char* temp_path;
   10.16 +
   10.17 +extern const char* main_url;
   10.18 +
   10.19 +extern const char* tempfile_alignment;
   10.20 +extern const char* tempfile_conformity;
   10.21 +extern const char* tempfile_html;
   10.22 +extern const char* tempfile_check;
   10.23 +extern const char* tempfile_sh;
   10.24 +
   10.25 +namespace defaults
   10.26 +{
   10.27 +
   10.28 +extern const char* delta;
   10.29 +extern const char* min_block_width;
   10.30 +extern const char* timeout;
   10.31 +extern const char* timeout2;
   10.32 +
   10.33 +}
   10.34 +
   10.35 +}
   10.36 +
   10.37 +#endif // MALAKITE_BLOCKS3D_CONFIG_H_s
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/blocks3d/wt/debug.sh	Thu Sep 16 15:49:55 2010 +0400
    11.3 @@ -0,0 +1,3 @@
    11.4 +cd ./build/; 
    11.5 +gdb --args ./blocks3d-wt.exe  -- run  --docroot . --http-address 0.0.0.0 --http-port 8000
    11.6 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/blocks3d/wt/files/css/1.css	Thu Sep 16 15:49:55 2010 +0400
    12.3 @@ -0,0 +1,5 @@
    12.4 +
    12.5 +.header {
    12.6 +	font-size: 250%;
    12.7 +	font-weight: bold;
    12.8 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/blocks3d/wt/files/js/jquery.countdown.pack.js	Thu Sep 16 15:49:55 2010 +0400
    13.3 @@ -0,0 +1,7 @@
    13.4 +/* http://keith-wood.name/countdown.html
    13.5 +   Countdown for jQuery v1.5.8.
    13.6 +   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
    13.7 +   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
    13.8 +   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
    13.9 +   Please attribute the author if you use it. */
   13.10 +eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?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.I.L():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.I<f)||(e.13&&e.13>f)){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]+\'</16><3A/>\'+(b?b[a]:m[a])+\'</16>\':\'\')};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))+\'</16>\'+(p?\'<16 1t="1U 3C">\'+p+\'</16>\':\'\')))},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.I.L()){c.1b=f=g}1c{f=c.I}}1c{g.2r(c.13.L());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()<f.T()&&!k)||(k&&l(g)<l(f))?-1:0));h[Y]=(d[Y]?U.1C(m/12):0);h[O]=(d[O]?m-h[Y]*12:0);f=K P(f.L());x n=(f.T()==i);x o=$.G.1h(f.18()+h[Y],f.17()+h[O]);A(f.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,{}))
   13.11 \ No newline at end of file
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/blocks3d/wt/run.sh	Thu Sep 16 15:49:55 2010 +0400
    14.3 @@ -0,0 +1,2 @@
    14.4 +cd ./build/; 
    14.5 +./blocks3d-wt.exe  --docroot . --http-address 0.0.0.0 --http-port 8000
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/blocks3d/wt/salt.C	Thu Sep 16 15:49:55 2010 +0400
    15.3 @@ -0,0 +1,21 @@
    15.4 +
    15.5 +#include "salt.h"
    15.6 +
    15.7 +std::string generateSalt() {
    15.8 +	/* Salt generation from glibc manual */
    15.9 +	unsigned long seed[2];
   15.10 +	char salt[] = "_1_........";
   15.11 +	const char *const seedchars =
   15.12 +		"./0123456789ABCDEFGHIJKLMNOPQRST"
   15.13 +		"UVWXYZabcdefghijklmnopqrstuvwxyz";
   15.14 +	 
   15.15 +	/* Generate a (not very) random seed. */
   15.16 +	seed[0] = time(NULL);
   15.17 +	seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
   15.18 +	 
   15.19 +	/* Turn it into printable characters from `seedchars'. */
   15.20 +	for (int i = 0; i < 8; i++)
   15.21 +		salt[3+i] = seedchars[(seed[i/5] >> (i%5)*6) & 0x3f];
   15.22 +
   15.23 +	return salt;
   15.24 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/blocks3d/wt/salt.h	Thu Sep 16 15:49:55 2010 +0400
    16.3 @@ -0,0 +1,8 @@
    16.4 +#ifndef SALT_H_
    16.5 +#define SALT_H_
    16.6 +
    16.7 +#include <string>
    16.8 +
    16.9 +std::string generateSalt();
   16.10 +
   16.11 +#endif // SALT_H_
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/blocks3d/wt/work-time.C	Thu Sep 16 15:49:55 2010 +0400
    17.3 @@ -0,0 +1,58 @@
    17.4 +
    17.5 +#include "work-time.h"
    17.6 +#include <boost/lexical_cast.hpp>
    17.7 +#include <Wt/WApplication>
    17.8 +
    17.9 +
   17.10 +Worktime::Worktime(Wt::WContainerWidget *parent) : 
   17.11 +	WText(parent), stoped(false)
   17.12 +{
   17.13 +	wApp->require("/files/js/jquery.countdown.pack.js");
   17.14 +	start_at = now();	
   17.15 +	stop_at = now(); // ??	
   17.16 +	render();
   17.17 +}
   17.18 +
   17.19 +std::string Worktime::int2time(posix::time_duration secs)
   17.20 +{
   17.21 +	posix::seconds secs1(secs.total_seconds());
   17.22 +	return to_simple_string(secs1);
   17.23 +}
   17.24 +
   17.25 +void Worktime::stop()
   17.26 +{
   17.27 +	stoped = true;
   17.28 +	stop_at = now();
   17.29 +	//~ setId(generateSalt()); // switch off countdown
   17.30 +	render();
   17.31 +}
   17.32 +
   17.33 +void Worktime::render()
   17.34 +{
   17.35 +	if (!stoped)
   17.36 +	{
   17.37 +		doJavaScript("$('#" + id() + "').countdown({"
   17.38 +		"since: -" + boost::lexical_cast<std::string>(
   17.39 +			spent().total_milliseconds()) + " / 1000,"
   17.40 +		"compact: true"
   17.41 +		"});");
   17.42 +	}
   17.43 +	else
   17.44 +	{
   17.45 +		doJavaScript("$('#" + id() + "').countdown('pause');");
   17.46 +	}
   17.47 +	
   17.48 +	setText(int2time(spent()));
   17.49 +};
   17.50 +
   17.51 +posix::time_duration Worktime::spent()
   17.52 +{
   17.53 +	if (stoped)
   17.54 +	{
   17.55 +		return stop_at - start_at;
   17.56 +	}
   17.57 +	else
   17.58 +	{
   17.59 +		return now() - start_at;
   17.60 +	}
   17.61 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/blocks3d/wt/work-time.h	Thu Sep 16 15:49:55 2010 +0400
    18.3 @@ -0,0 +1,27 @@
    18.4 +
    18.5 +#ifndef WORKTIME_H_
    18.6 +#define WORKTIME_H_
    18.7 +
    18.8 +#include <Wt/WContainerWidget>
    18.9 +#include <Wt/WText>
   18.10 +
   18.11 +#include <boost/date_time/posix_time/posix_time.hpp>
   18.12 +namespace posix = boost::posix_time;
   18.13 +
   18.14 +class Worktime : public Wt::WText
   18.15 +{
   18.16 +public:
   18.17 +	Worktime(Wt::WContainerWidget *parent=0);
   18.18 +	void render();
   18.19 +	void stop();
   18.20 +	inline posix::ptime now() { return posix::microsec_clock::universal_time(); }
   18.21 +	inline posix::time_duration spent(); 
   18.22 +private:
   18.23 +	posix::ptime start_at;
   18.24 +	posix::ptime stop_at;
   18.25 +	bool stoped;
   18.26 +	std::string int2time(posix::time_duration secs);
   18.27 +};
   18.28 +
   18.29 +
   18.30 +#endif // WORKTIME_H_