Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-02-27 21:24:18 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-03-02 06:32:18 (GMT)
commite8e215f382f762513226c9e88f278da1945567ee (patch)
treecb68982dcb3f06bd1111f7ad3f61b2d28dbb68bc
parent5651224fe4b7ae316f1df682ff7eef3b773dd8a5 (diff)
...
-rw-r--r--GUI_Components/Publish_Pane.py43
-rw-r--r--Processing/Package_Creator.py25
-rw-r--r--book.py19
-rw-r--r--library.py14
4 files changed, 36 insertions, 65 deletions
diff --git a/GUI_Components/Publish_Pane.py b/GUI_Components/Publish_Pane.py
deleted file mode 100644
index 1d5b1e6..0000000
--- a/GUI_Components/Publish_Pane.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright (C) IBM Corporation 2008
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-from GUI_Components.Pane import Pane
-from GUI_Components.Compound_Widgets.Publish_View import Publish_View
-from Processing.IO_Manager import *
-from gettext import gettext as _
-
-"""
-This pane is used when the user decides to package up articles in themes for distribution
-"""
-class Publish_Pane(Pane):
-
- def __init__(self):
- Pane.__init__(self)
- self.toolbar = gtk.Toolbar()
-
- self.name = _("Publish")
-
- self.panel = Publish_View()
- self.panel.show()
-
- self.toolbar = gtk.Toolbar()
-
- def get_source_article(self):
- return self.source
-
- def set_source_article(self, article):
- self.source = article
-
- def get_working_article(self):
- return self.working
-
- def set_working_article(self, article):
- theme = article.article_theme
- title = article.article_title
- if theme != None and title != None:
- IO_Manager().save_article(article)
- self.working = article
- self.panel.populate_themes()
- self.panel.export_message.set_text(_("Select the theme you want, choose the articles you wish to include in the package and click 'Publish'."))
diff --git a/Processing/Package_Creator.py b/Processing/Package_Creator.py
index abbfa84..dad218e 100644
--- a/Processing/Package_Creator.py
+++ b/Processing/Package_Creator.py
@@ -1,9 +1,9 @@
# Copyright (C) IBM Corporation 2008
import os, platform, zipfile, shutil, re
-from IO_Manager import IO_Manager
-from NewtifulSoup import NewtifulStoneSoup as BeautifulStoneSoup
+from sugar.activity.activity import get_bundle_path, get_activity_root
+from NewtifulSoup import NewtifulStoneSoup as BeautifulStoneSoup
class Package_Creator:
"""
@author: Matthew Bailey
@@ -16,19 +16,22 @@ class Package_Creator:
"""
Copy articles from library into new content theme (themename) and package up (filename).
"""
- def __init__(self, articlestocopy, themename, filename, package_type, caller=None):
+ def __init__(self, articlestocopy, themename, filename, caller=None):
"""
Grab file's parent directory and create temporary directory structure for content
"""
- self.currentdir = os.path.split(__file__)[0]
+ self.root = os.path.join(get_activity_root(), 'tmp', 'publish')
+ shutil.rmtree(self.root, True)
+ os.makedirs(self.root)
+
self.make_directories(themename)
- if package_type == 'xol':
- self.info_file(themename)
- self.index_redirect(themename, package_type)
+
+ self.info_file(themename)
+ self.index_redirect(themename)
self.dita_management(articlestocopy, themename)
- self.copy_stylesheets(themename)
+ self.copy_stylesheets()
self.create_bundle(themename, filename)
running_on = platform.system()
@@ -46,11 +49,13 @@ class Package_Creator:
"""
self.remove_directories(themename)
- def copy_stylesheets(self, themename):
+ def copy_stylesheets(self):
"""
Copies the XSL and CSS stylesheets into the slicecontent folder
@param themename: the name of the theme that is being exported
"""
+ for i in glob(os.path.join(get_bundle_path(), 'Stylesheets', '*.xsl')):
+
themeloc = themename.replace(" ", "_")
shutil.copyfile('%s/../Stylesheets/ditastylesheet.xsl' % self.currentdir, '%s/%s/slicecontent/ditastylesheet.xsl' % (IO_Manager().workingDir, themeloc))
shutil.copyfile('%s/../Stylesheets/mapstylesheet.xsl' % self.currentdir, '%s/%s/slicecontent/mapstylesheet.xsl' % (IO_Manager().workingDir, themeloc))
@@ -226,4 +231,4 @@ class Package_Creator:
"""
fullpath = '%s/%s' % (IO_Manager().workingDir, path)
for each in os.listdir(fullpath):
- zip.write(fullpath + each, path + each) \ No newline at end of file
+ zip.write(fullpath + each, path + each)
diff --git a/book.py b/book.py
index 33ea2c2..3e4d94c 100644
--- a/book.py
+++ b/book.py
@@ -46,13 +46,7 @@ class Book(gobject.GObject):
if self._article and self._article.article_title == title:
return
- if self._article:
- # save current copy of article
- self.find_by_uuid(self._article.uid)['title'] = \
- self._article.article_title
- contents = Article_Builder(self.root).get_dita_from_article(
- self._article)
- self._save(self._article.uid, contents)
+ self.sync()
if title is None:
return
@@ -77,6 +71,17 @@ class Book(gobject.GObject):
article = gobject.property(type=object,
getter=get_article, setter=set_article)
+ # save current article
+ def sync(self):
+ if not self._article:
+ return
+
+ self.find_by_uuid(self._article.uid)['title'] = \
+ self._article.article_title
+ contents = Article_Builder(self.root).get_dita_from_article(
+ self._article)
+ self._save(self._article.uid, contents)
+
def create(self, title, content):
uid = str(uuid.uuid1())
content = net.image_handler(self.root, uid, content)
diff --git a/library.py b/library.py
index 37be603..cd2a875 100644
--- a/library.py
+++ b/library.py
@@ -14,6 +14,7 @@
import gtk
from threading import Timer
+from datetime import datetime
from gettext import gettext as _
from sugar.graphics.toolbutton import ToolButton
@@ -23,11 +24,12 @@ from sugar.graphics.toolcombobox import ToolComboBox
from sugar.graphics.icon import Icon
import sugar.graphics.style as style
+import net
+import book
from GUI_Components.Compound_Widgets.toolbar import WidgetItem
from GUI_Components.Compound_Widgets.bookview import BookView
from GUI_Components.Compound_Widgets.Reading_View import Reading_View
-import book
-import net
+from Processing.Package_Creator import Package_Creator
class View(gtk.EventBox):
def sync(self):
@@ -189,12 +191,14 @@ class Toolbar(gtk.Toolbar):
self.connect('map', self._map_cb)
+ def _publish_clicked_cb(self):
+ book.custom.sync()
+ Package_Creator(book.custom.article,
+ datetime.strftime(datetime.now(), '%F %T'))
+
def _map_cb(self, widget):
self.searchentry.grab_focus()
- def _publish_clicked_cb(self):
- pass
-
def _search_activate_cb(self, widget):
self.searchbutton.emit("clicked")