Created the site generate dialog
authorHarishankar <v.harishankar@gmail.com>
Mon, 29 Nov 2010 17:07:19 +0000 (22:37 +0530)
committerHarishankar <v.harishankar@gmail.com>
Mon, 29 Nov 2010 17:07:19 +0000 (22:37 +0530)
Created the site generation dialog. Still to implement the actual
site generation.

generate_dialog.py [new file with mode: 0644]
generate_dialog.ui [new file with mode: 0644]
main_window.py
main_window.ui
ui_generate_dialog.py [new file with mode: 0644]
ui_main_window.py

diff --git a/generate_dialog.py b/generate_dialog.py
new file mode 100644 (file)
index 0000000..0d7bbed
--- /dev/null
@@ -0,0 +1,13 @@
+# BiaWeb Website content manager (c) 2010 V.Harishankar
+# Generate site dialog
+
+import PyQt4
+import ui_generate_dialog
+
+class GenerateDialog (PyQt4.QtGui.QDialog, ui_generate_dialog.Ui_SiteGenerateDialog):
+       def __init__ (self, master, currentdb):
+               PyQt4.QtGui.QDialog.__init__ (self, master)
+               self.setupUi (self)
+
+               # set the database
+               self.current_db = currentdb
diff --git a/generate_dialog.ui b/generate_dialog.ui
new file mode 100644 (file)
index 0000000..21a3928
--- /dev/null
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SiteGenerateDialog</class>
+ <widget class="QDialog" name="SiteGenerateDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>618</width>
+    <height>537</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>618</width>
+    <height>537</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>618</width>
+    <height>537</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Generate Website</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_2">
+   <item row="0" column="0" colspan="3">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; color:#005500;&quot;&gt;Important Information&lt;/span&gt;&lt;/p&gt;
+&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This will generate your website in the destination directory specified in the site configuration dialog. The entire directory tree will be re-created from scratch and any manual changes you made to the generated files will be gone!&lt;/p&gt;
+&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; &lt;/p&gt;
+&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;You need to re-copy additional files/folders you require in the destination folder (e.g. image files or directories) every time you generate the site. Specify additional files/folders to copy below.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="3">
+    <widget class="QTabWidget" name="tabWidget">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="tab">
+      <attribute name="title">
+       <string>Files</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_3">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Additional files to add to destination</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QPushButton" name="addfile">
+         <property name="text">
+          <string>&amp;Add file</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="2">
+        <widget class="QPushButton" name="removefile">
+         <property name="text">
+          <string>&amp;Remove</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" colspan="3">
+        <widget class="QTreeWidget" name="additional_files">
+         <column>
+          <property name="text">
+           <string>Source file</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Destination (relative to dest-dir)</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="tab_2">
+      <attribute name="title">
+       <string>Folders</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_4">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string>Additional folders to add to destination</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QPushButton" name="addfolder">
+         <property name="text">
+          <string>&amp;Add folder</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="2">
+        <widget class="QPushButton" name="removefolder">
+         <property name="text">
+          <string>&amp;Remove</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0" colspan="3">
+        <widget class="QTreeWidget" name="additional_folders">
+         <column>
+          <property name="text">
+           <string>Source folder</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Destination (relative to dest-dir)</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Search index type</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QRadioButton" name="fulltextindex">
+        <property name="text">
+         <string>Full text index</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QRadioButton" name="keywordindex">
+        <property name="text">
+         <string>Keyword index</string>
+        </property>
+        <property name="checked">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <widget class="QPushButton" name="generate_site">
+     <property name="text">
+      <string>&amp;Generate site</string>
+     </property>
+     <property name="default">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="2">
+    <widget class="QPushButton" name="close">
+     <property name="text">
+      <string>&amp;Close</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>tabWidget</tabstop>
+  <tabstop>addfile</tabstop>
+  <tabstop>removefile</tabstop>
+  <tabstop>additional_files</tabstop>
+  <tabstop>addfolder</tabstop>
+  <tabstop>removefolder</tabstop>
+  <tabstop>additional_folders</tabstop>
+  <tabstop>fulltextindex</tabstop>
+  <tabstop>keywordindex</tabstop>
+  <tabstop>generate_site</tabstop>
+  <tabstop>close</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>close</sender>
+   <signal>clicked()</signal>
+   <receiver>SiteGenerateDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>502</x>
+     <y>516</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>239</x>
+     <y>501</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 6b7f31a..bf22310 100644 (file)
@@ -9,6 +9,7 @@ import site_configuration_dialog as scd
 import category_dialog as catd
 import article_dialog as artd
 import templates_dialog as tpld
+import generate_dialog as gend
 import biaweb_db
 
 class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
@@ -362,6 +363,16 @@ class MainWindow (PyQt4.QtGui.QMainWindow, ui_main_window.Ui_MainWindow):
                                else:
                                        PyQt4.QtGui.QMessageBox.critical (self, "Error", "System or SQLite 3 error in creating database")
 
+       # when generate site menu is triggered
+       def onGenerateSite (self):
+               if self.current_db is None:
+                       PyQt4.QtGui.QMessageBox.critical (self, "Error",
+                                                               "Cannot generate site. You need to create or open a website first")
+               else:
+                       # run the generate site dialog
+                       gendlg = gend.GenerateDialog (self, self.current_db)
+                       gendlg.exec_ ()
+
        # file quit is clicked
        def onFileQuit (self):
                sys.exit (0)
index bbdfa1f..36b25cd 100644 (file)
       <string>&amp;Export web</string>
      </property>
      <addaction name="action_Generate_Site"/>
-     <addaction name="actionGenerate_Search_Index"/>
     </widget>
     <addaction name="actionNew_site"/>
     <addaction name="action_Open_site"/>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>action_Generate_Site</sender>
+   <signal>triggered()</signal>
+   <receiver>MainWindow</receiver>
+   <slot>onGenerateSite()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>398</x>
+     <y>258</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>onFileNew()</slot>
   <slot>onCategoryItemActivated()</slot>
   <slot>onArticleItemActivated()</slot>
   <slot>onTemplates()</slot>
+  <slot>onGenerateSite()</slot>
  </slots>
 </ui>
diff --git a/ui_generate_dialog.py b/ui_generate_dialog.py
new file mode 100644 (file)
index 0000000..a14ac37
--- /dev/null
@@ -0,0 +1,124 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'generate_dialog.ui'
+#
+# Created: Mon Nov 29 22:36:32 2010
+#      by: PyQt4 UI code generator 4.7.4
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_SiteGenerateDialog(object):
+    def setupUi(self, SiteGenerateDialog):
+        SiteGenerateDialog.setObjectName("SiteGenerateDialog")
+        SiteGenerateDialog.resize(618, 537)
+        SiteGenerateDialog.setMinimumSize(QtCore.QSize(618, 537))
+        SiteGenerateDialog.setMaximumSize(QtCore.QSize(618, 537))
+        self.gridLayout_2 = QtGui.QGridLayout(SiteGenerateDialog)
+        self.gridLayout_2.setObjectName("gridLayout_2")
+        self.label = QtGui.QLabel(SiteGenerateDialog)
+        self.label.setWordWrap(True)
+        self.label.setObjectName("label")
+        self.gridLayout_2.addWidget(self.label, 0, 0, 1, 3)
+        self.tabWidget = QtGui.QTabWidget(SiteGenerateDialog)
+        self.tabWidget.setObjectName("tabWidget")
+        self.tab = QtGui.QWidget()
+        self.tab.setObjectName("tab")
+        self.gridLayout_3 = QtGui.QGridLayout(self.tab)
+        self.gridLayout_3.setObjectName("gridLayout_3")
+        self.label_2 = QtGui.QLabel(self.tab)
+        self.label_2.setObjectName("label_2")
+        self.gridLayout_3.addWidget(self.label_2, 0, 0, 1, 1)
+        self.addfile = QtGui.QPushButton(self.tab)
+        self.addfile.setObjectName("addfile")
+        self.gridLayout_3.addWidget(self.addfile, 0, 1, 1, 1)
+        self.removefile = QtGui.QPushButton(self.tab)
+        self.removefile.setObjectName("removefile")
+        self.gridLayout_3.addWidget(self.removefile, 0, 2, 1, 1)
+        self.additional_files = QtGui.QTreeWidget(self.tab)
+        self.additional_files.setObjectName("additional_files")
+        self.gridLayout_3.addWidget(self.additional_files, 1, 0, 1, 3)
+        self.tabWidget.addTab(self.tab, "")
+        self.tab_2 = QtGui.QWidget()
+        self.tab_2.setObjectName("tab_2")
+        self.gridLayout_4 = QtGui.QGridLayout(self.tab_2)
+        self.gridLayout_4.setObjectName("gridLayout_4")
+        self.label_3 = QtGui.QLabel(self.tab_2)
+        self.label_3.setObjectName("label_3")
+        self.gridLayout_4.addWidget(self.label_3, 0, 0, 1, 1)
+        self.addfolder = QtGui.QPushButton(self.tab_2)
+        self.addfolder.setObjectName("addfolder")
+        self.gridLayout_4.addWidget(self.addfolder, 0, 1, 1, 1)
+        self.removefolder = QtGui.QPushButton(self.tab_2)
+        self.removefolder.setObjectName("removefolder")
+        self.gridLayout_4.addWidget(self.removefolder, 0, 2, 1, 1)
+        self.additional_folders = QtGui.QTreeWidget(self.tab_2)
+        self.additional_folders.setObjectName("additional_folders")
+        self.gridLayout_4.addWidget(self.additional_folders, 1, 0, 1, 3)
+        self.tabWidget.addTab(self.tab_2, "")
+        self.gridLayout_2.addWidget(self.tabWidget, 1, 0, 1, 3)
+        self.groupBox = QtGui.QGroupBox(SiteGenerateDialog)
+        self.groupBox.setObjectName("groupBox")
+        self.gridLayout = QtGui.QGridLayout(self.groupBox)
+        self.gridLayout.setObjectName("gridLayout")
+        self.fulltextindex = QtGui.QRadioButton(self.groupBox)
+        self.fulltextindex.setChecked(True)
+        self.fulltextindex.setObjectName("fulltextindex")
+        self.gridLayout.addWidget(self.fulltextindex, 0, 0, 1, 1)
+        self.keywordindex = QtGui.QRadioButton(self.groupBox)
+        self.keywordindex.setChecked(False)
+        self.keywordindex.setObjectName("keywordindex")
+        self.gridLayout.addWidget(self.keywordindex, 0, 1, 1, 1)
+        self.gridLayout_2.addWidget(self.groupBox, 2, 0, 1, 1)
+        self.generate_site = QtGui.QPushButton(SiteGenerateDialog)
+        self.generate_site.setDefault(True)
+        self.generate_site.setObjectName("generate_site")
+        self.gridLayout_2.addWidget(self.generate_site, 3, 1, 1, 1)
+        self.close = QtGui.QPushButton(SiteGenerateDialog)
+        self.close.setObjectName("close")
+        self.gridLayout_2.addWidget(self.close, 3, 2, 1, 1)
+
+        self.retranslateUi(SiteGenerateDialog)
+        self.tabWidget.setCurrentIndex(0)
+        QtCore.QObject.connect(self.close, QtCore.SIGNAL("clicked()"), SiteGenerateDialog.reject)
+        QtCore.QMetaObject.connectSlotsByName(SiteGenerateDialog)
+        SiteGenerateDialog.setTabOrder(self.tabWidget, self.addfile)
+        SiteGenerateDialog.setTabOrder(self.addfile, self.removefile)
+        SiteGenerateDialog.setTabOrder(self.removefile, self.additional_files)
+        SiteGenerateDialog.setTabOrder(self.additional_files, self.addfolder)
+        SiteGenerateDialog.setTabOrder(self.addfolder, self.removefolder)
+        SiteGenerateDialog.setTabOrder(self.removefolder, self.additional_folders)
+        SiteGenerateDialog.setTabOrder(self.additional_folders, self.fulltextindex)
+        SiteGenerateDialog.setTabOrder(self.fulltextindex, self.keywordindex)
+        SiteGenerateDialog.setTabOrder(self.keywordindex, self.generate_site)
+        SiteGenerateDialog.setTabOrder(self.generate_site, self.close)
+
+    def retranslateUi(self, SiteGenerateDialog):
+        SiteGenerateDialog.setWindowTitle(QtGui.QApplication.translate("SiteGenerateDialog", "Generate Website", None, QtGui.QApplication.UnicodeUTF8))
+        self.label.setText(QtGui.QApplication.translate("SiteGenerateDialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
+"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
+"p, li { white-space: pre-wrap; }\n"
+"</style></head><body style=\" font-family:\'Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
+"<p align=\"justify\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600; color:#005500;\">Important Information</span></p>\n"
+"<p align=\"justify\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This will generate your website in the destination directory specified in the site configuration dialog. The entire directory tree will be re-created from scratch and any manual changes you made to the generated files will be gone!</p>\n"
+"<p align=\"justify\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> </p>\n"
+"<p align=\"justify\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">You need to re-copy additional files/folders you require in the destination folder (e.g. image files or directories) every time you generate the site. Specify additional files/folders to copy below.</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
+        self.label_2.setText(QtGui.QApplication.translate("SiteGenerateDialog", "Additional files to add to destination", None, QtGui.QApplication.UnicodeUTF8))
+        self.addfile.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Add file", None, QtGui.QApplication.UnicodeUTF8))
+        self.removefile.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Remove", None, QtGui.QApplication.UnicodeUTF8))
+        self.additional_files.headerItem().setText(0, QtGui.QApplication.translate("SiteGenerateDialog", "Source file", None, QtGui.QApplication.UnicodeUTF8))
+        self.additional_files.headerItem().setText(1, QtGui.QApplication.translate("SiteGenerateDialog", "Destination (relative to dest-dir)", None, QtGui.QApplication.UnicodeUTF8))
+        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("SiteGenerateDialog", "Files", None, QtGui.QApplication.UnicodeUTF8))
+        self.label_3.setText(QtGui.QApplication.translate("SiteGenerateDialog", "Additional folders to add to destination", None, QtGui.QApplication.UnicodeUTF8))
+        self.addfolder.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Add folder", None, QtGui.QApplication.UnicodeUTF8))
+        self.removefolder.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Remove", None, QtGui.QApplication.UnicodeUTF8))
+        self.additional_folders.headerItem().setText(0, QtGui.QApplication.translate("SiteGenerateDialog", "Source folder", None, QtGui.QApplication.UnicodeUTF8))
+        self.additional_folders.headerItem().setText(1, QtGui.QApplication.translate("SiteGenerateDialog", "Destination (relative to dest-dir)", None, QtGui.QApplication.UnicodeUTF8))
+        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("SiteGenerateDialog", "Folders", None, QtGui.QApplication.UnicodeUTF8))
+        self.groupBox.setTitle(QtGui.QApplication.translate("SiteGenerateDialog", "Search index type", None, QtGui.QApplication.UnicodeUTF8))
+        self.fulltextindex.setText(QtGui.QApplication.translate("SiteGenerateDialog", "Full text index", None, QtGui.QApplication.UnicodeUTF8))
+        self.keywordindex.setText(QtGui.QApplication.translate("SiteGenerateDialog", "Keyword index", None, QtGui.QApplication.UnicodeUTF8))
+        self.generate_site.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Generate site", None, QtGui.QApplication.UnicodeUTF8))
+        self.close.setText(QtGui.QApplication.translate("SiteGenerateDialog", "&Close", None, QtGui.QApplication.UnicodeUTF8))
+
index 80a6898..d754224 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'main_window.ui'
 #
-# Created: Mon Nov 29 13:18:40 2010
+# Created: Mon Nov 29 22:29:43 2010
 #      by: PyQt4 UI code generator 4.7.4
 #
 # WARNING! All changes made in this file will be lost!
@@ -108,7 +108,6 @@ class Ui_MainWindow(object):
         self.menu_Content.addAction(self.action_EditCategory)
         self.menu_Content.addAction(self.action_RemoveCategory)
         self.menu_Export_web.addAction(self.action_Generate_Site)
-        self.menu_Export_web.addAction(self.actionGenerate_Search_Index)
         self.menu_File_2.addAction(self.actionNew_site)
         self.menu_File_2.addAction(self.action_Open_site)
         self.menu_File_2.addSeparator()
@@ -138,6 +137,7 @@ class Ui_MainWindow(object):
         QtCore.QObject.connect(self.categories, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onCategoryItemActivated)
         QtCore.QObject.connect(self.articles, QtCore.SIGNAL("itemActivated(QTreeWidgetItem*,int)"), MainWindow.onArticleItemActivated)
         QtCore.QObject.connect(self.actionTemplates, QtCore.SIGNAL("triggered()"), MainWindow.onTemplates)
+        QtCore.QObject.connect(self.action_Generate_Site, QtCore.SIGNAL("triggered()"), MainWindow.onGenerateSite)
         QtCore.QMetaObject.connectSlotsByName(MainWindow)
         MainWindow.setTabOrder(self.categories, self.articles)