Drupal integration

From Scribus Wiki
Jump to navigation Jump to search

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


  • 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.


  • 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!


  • 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.


  • 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

#!/usr/bin/env python
#-*- coding utf-8 -*-

import os
import re
import MySQLdb

#database info

def htmlhead():
	header = """<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	return header

def htmlfoot():
	footer = """
	return footer

print "Scribus/Drupal brigde\n\nby mariusz slonina <mariusz.slonina@gmail.com>\n\n"

#connect to database
	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"
# create a cursor
cursor = db.cursor()
# # execute SQL statement
cursor.execute("your select goes here")
#cursor.execute("select nr.nid, nr.vid, nr.title, nr.body, pf.value from node_revisions nr
#inner join workflow_node wn on wn.nid = nr.nid
#inner join node n on n.vid = nr.vid 
#inner join profile_values pf on n.uid = pf.uid 
#where wn.sid = 6 and pf.fid = 4")

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

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 <p></p> 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() + '<br />\n'
				st = st + subtemp[j].strip()
		text = text + '<p>' + st.strip() + '</p>\n'
		st = ''
	print titleID + ":: " + title_text + " -- " + author_text

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


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