[Logilogi-svn] SF.net SVN: logilogi: [280] plugins/manta_pdf_export
Status: Beta
Brought to you by:
wybow
|
From: <maa...@us...> - 2007-05-13 09:00:26
|
Revision: 280
http://logilogi.svn.sourceforge.net/logilogi/?rev=280&view=rev
Author: maartengeraedts
Date: 2007-05-13 02:00:24 -0700 (Sun, 13 May 2007)
Log Message:
-----------
Now with the files
Added Paths:
-----------
plugins/manta_pdf_export/README
plugins/manta_pdf_export/Rakefile
plugins/manta_pdf_export/app/
plugins/manta_pdf_export/app/controllers/
plugins/manta_pdf_export/app/controllers/logi_controller.rb
plugins/manta_pdf_export/app/models/
plugins/manta_pdf_export/app/models/logi_version.rb
plugins/manta_pdf_export/init.rb
plugins/manta_pdf_export/install.rb
plugins/manta_pdf_export/lib/
plugins/manta_pdf_export/lib/manta_pdf_export.rb
plugins/manta_pdf_export/tasks/
plugins/manta_pdf_export/tasks/manta_pdf_export_tasks.rake
plugins/manta_pdf_export/test/
plugins/manta_pdf_export/test/manta_pdf_export_test.rb
plugins/manta_pdf_export/uninstall.rb
Added: plugins/manta_pdf_export/README
===================================================================
--- plugins/manta_pdf_export/README (rev 0)
+++ plugins/manta_pdf_export/README 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,10 @@
+MantaPdfExport
+==============
+
+Depends on http://ruby-pdf.rubyforge.org/pdf-writer/
+
+Todo's:
+- Adding extra tab from plugin isnt working yet (wybo?)
+- A very basic parser must be made, so that the pdf document also shows bold tags and headers and such
+- Filename is now generated as '{current date} {title}.pdf' where title is untitled if no title exists (And the title exists if there is a header tag in the beginning if I readed the regular expression correctly)
+
Added: plugins/manta_pdf_export/Rakefile
===================================================================
--- plugins/manta_pdf_export/Rakefile (rev 0)
+++ plugins/manta_pdf_export/Rakefile 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the manta_pdf_export plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the manta_pdf_export plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'MantaPdfExport'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
Added: plugins/manta_pdf_export/app/controllers/logi_controller.rb
===================================================================
--- plugins/manta_pdf_export/app/controllers/logi_controller.rb (rev 0)
+++ plugins/manta_pdf_export/app/controllers/logi_controller.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,58 @@
+#--#
+# Copyright: (c) 2006, 2007 The LogiLogi Foundation <fou...@lo...>
+#
+# License:
+# This file is part of the LogiLogi program. LogiLogi is free software. You
+# can run/distribute/modify LogiLogi under the terms of the Affero General
+# Public License version 1 or any later version. The Affero GPL states that
+# running a modified version or a derivative work also requires you to make
+# the sourcecode of that work available to everyone that can interact with
+# it. We chose the Affero GPL to ensure that LogiLogi remains open and libre
+# (doc/LICENSE.txt contains the full text of the legally binding license).
+#++#
+
+class LogiController < ApplicationController
+ layout 'main'
+ ### Bodies
+
+ #tabs_body :pdf_export_plugin_tabs
+
+ def pdf_export_plugin_tabs
+ if @additional_tabs
+ active = params[:action].to_sym
+ actions = [['pdf',{:action => :pdf}]]
+ render_to_string(:partial => 'logi_tabs',
+ :locals => {
+ :actions => actions,
+ :active => active
+ })
+ end
+ end
+
+ def get_logi_version
+ @logi_version = Context.current.link.volatile_to_logi_version
+ return @logi_version
+ end
+
+ # This needs updating to a sensible filename
+ def get_pdf_filename
+ @logi_version = get_logi_version
+ now = Time.now
+
+ title = @logi_version.logi.current_title
+ if(title.nil?)
+ title = ' Untitled'
+ else
+ title = ' ' + title
+ end
+ return now.strftime("%Y-%m-%d") + title + '.pdf'
+ end
+
+ def pdf
+ @logi_version = get_logi_version
+ if(!@logi_version.nil?)
+ send_data @logi_version.to_pdf, :filename => get_pdf_filename,
+ :type => "application/pdf"
+ end
+ end
+end
Added: plugins/manta_pdf_export/app/models/logi_version.rb
===================================================================
--- plugins/manta_pdf_export/app/models/logi_version.rb (rev 0)
+++ plugins/manta_pdf_export/app/models/logi_version.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,26 @@
+class LogiVersion < ActiveRecord::Base
+
+ # This needs updating
+ # The pdf library supports basic tags like <b> and <i>
+ # and things like font and fontsizes, which can be combined
+ # to create bigger headers and quotes.
+ def textile_to_pdf_body
+ return linkless_textile
+ end
+
+ def to_pdf
+ body = textile_to_pdf_body
+
+ # A4, portrait
+ _pdf = PDF::Writer.new
+ _pdf.select_font "Times-Roman"
+
+ # Only print a header if it exists
+ if (self.logi.current_title?)
+ _pdf.text self.logi.current_title + "\n\n", :font_size => 30, :justification => :center
+ end
+ _pdf.text body, :font_size => 12, :justification => :full
+
+ return _pdf.render
+ end
+end
Added: plugins/manta_pdf_export/init.rb
===================================================================
--- plugins/manta_pdf_export/init.rb (rev 0)
+++ plugins/manta_pdf_export/init.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,3 @@
+# Include hook code here
+require 'manta_pdf_export'
+require 'pdf/writer'
Added: plugins/manta_pdf_export/install.rb
===================================================================
--- plugins/manta_pdf_export/install.rb (rev 0)
+++ plugins/manta_pdf_export/install.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1 @@
+# Install hook code here
Added: plugins/manta_pdf_export/lib/manta_pdf_export.rb
===================================================================
--- plugins/manta_pdf_export/lib/manta_pdf_export.rb (rev 0)
+++ plugins/manta_pdf_export/lib/manta_pdf_export.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1 @@
+# MantaPdfExport
\ No newline at end of file
Added: plugins/manta_pdf_export/tasks/manta_pdf_export_tasks.rake
===================================================================
--- plugins/manta_pdf_export/tasks/manta_pdf_export_tasks.rake (rev 0)
+++ plugins/manta_pdf_export/tasks/manta_pdf_export_tasks.rake 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :manta_pdf_export do
+# # Task goes here
+# end
\ No newline at end of file
Added: plugins/manta_pdf_export/test/manta_pdf_export_test.rb
===================================================================
--- plugins/manta_pdf_export/test/manta_pdf_export_test.rb (rev 0)
+++ plugins/manta_pdf_export/test/manta_pdf_export_test.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1,8 @@
+require 'test/unit'
+
+class MantaPdfExportTest < Test::Unit::TestCase
+ # Replace this with your real tests.
+ def test_this_plugin
+ flunk
+ end
+end
Added: plugins/manta_pdf_export/uninstall.rb
===================================================================
--- plugins/manta_pdf_export/uninstall.rb (rev 0)
+++ plugins/manta_pdf_export/uninstall.rb 2007-05-13 09:00:24 UTC (rev 280)
@@ -0,0 +1 @@
+# Uninstall hook code here
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|