Drupal integration

Notes about creating a publishing platform with Scribus and Drupal (DRAFT)

Requirements

 * running Drupal6
 * external connection to Mysql database or a shell

Drupal backend
Articles are prepared to publish within the complete workflow system. The workflow system is build with help of: CCK, Views2, Workflow and Diff modules.

Done

 * workflow (from Draft state to Published state), revisioning included
 * input format -- html, with help of BueEditor and custom button set
 * a special dashboard for listing articles in different states (Views2), includes a tab with articles prepared for publishing
 * char counter integrated with node edit form -- counts chars almost the same as Scribus!

ToDo

 * Drupal module that allows you to create article presets (i.e. main article, editorial etc.) and informs if your article pass the layout

Scribus backend
Articles are fetched by a simple python script and converted to html readable by Scribus.

ToDo

 * script works outside Scribus. As a proof of concept we can create a similar script which imports articles directly to Scribus, unfortunately, text formatting is lost in this case...

Possible extensions

 * use of markdown syntax

Proof of concept script

 * 1) !/usr/bin/env python
 * 2) -*- coding utf-8 -*-

import os import re import MySQLdb

host="www.yourhosthere.info" user="user" passwd="password" db="database"
 * 1) database info

def htmlhead: header = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  	""" return header

def htmlfoot: footer = """	""" return footer

print "Scribus/Drupal brigde\n\nby mariusz slonina \n\n"

try: print 'Connecting to the database...\n' db = MySQLdb.connect(host, user,passwd,db) print 'Connected;)\n' except MySQLdb.Error, e:	print "Error %d: %s\n" % (e.args[0], e.args[1])	print "Aborting...;(\n" sys.exit(1) cursor = db.cursor cursor.execute("your select goes here")
 * 1) connect to database
 * 1) create a cursor
 * 1) # execute SQL statement
 * 1) cursor.execute("select nr.nid, nr.vid, nr.title, nr.body, pf.value from node_revisions nr
 * 2) inner join workflow_node wn on wn.nid = nr.nid
 * 3) inner join node n on n.vid = nr.vid
 * 4) inner join profile_values pf on n.uid = pf.uid
 * 5) where wn.sid = 6 and pf.fid = 4")

print "Fetching articles...\n" result = cursor.fetchall
 * 1) # get the result set as a tuple

for record in result: nid = str(record[0]) titleID = "title_nid_" + str(record[0]) bodyID = "body_nid_" + str(record[0]) authorID = "author_nid_" + str(record[0]) file_name = titleID + ".html"

title_text = str(record[2]) body_text = str(record[3]) author_text = str(record[4])

#split body and add tags for proper import to Scribus temp = re.split("\n\s*\n",body_text) length = len(temp) i = 0 text = '' st = '' for i in range(length): subtemp = re.split("\n",temp[i].strip) j = 0 jl = len(subtemp) for j in range(jl): if not j == jl - 1: st = st + subtemp[j].strip + ' \n' else: st = st + subtemp[j].strip text = text + ' ' + st.strip + ' \n' st = '' print titleID + ":: " + title_text + " -- " + author_text

f = open(file_name,"w") header = htmlhead f.write(header) f.write(' '+author_text+': '+title_text+' \n') f.write(text) footer = htmlfoot f.write(footer)

f.close

print "Finishing...\n" db.close print "You can import Your articles to Scribus\nHave a nice day!\n"