Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Source Dialog #163

Closed
wants to merge 14 commits into from
Closed

Export Source Dialog #163

wants to merge 14 commits into from

Conversation

uliska
Copy link
Collaborator

@uliska uliska commented Jun 24, 2013

This pull request isn't meant to be merged, but a request for review.
Before merging I would clean up the history to reduce the number of commits, and I still have a few things to do.

But I would really like to get some thorough testing now.

Overview of changes (see also #152, #156 and #159 ):

  • unified exporting/formatted copying/printing to one Dialog, accessible with File->Export As
  • The only additional action is File->Export with previous settings
  • Greatly extend the available export options:
    • export selection/document
    • generate CSS file
    • generate document body or standalone document
    • export to clipboard/file/printer
    • style items inline, by css or by external css
    • export as plain text HTML or as rich text
    • export to HTML, PDF or ODT files (odt unfortunately only with inline styles)
      (a wish would be PNG export (for screenshots etc.) - maybe through the poppler library?)

And any valid combinations.

Testing is needed for:

  • the quality of the actual HTML output
  • application logic in the dialog
    • does it allow illegal combinations of options
      or prevent legal ones?
    • is it possible to navigate to a dead-lock or similar problems?
    • do the results always correspond to the expectations?
  • Does saving the settings always work correctly?

What is still unfinished:

  • I can't right now test with a real printer, therefore the printer settings dialog is still a sketch
  • Line numbers are always styled with a css, regardless of the style setting.
    This css has no definition (because I don't know how to inject a new TextFormat in the tokenizer mechanism)
  • PDF export and printing don't respect the font selection.
    This will be solved with the solution of the previous issue
    (need a CSS for the <pre> tag)

And a screenshot:
frescobaldi-export-dialog-test

@uliska
Copy link
Collaborator Author

uliska commented Jun 25, 2013

Update:

  • fixed font selection for pdf/printer output
  • fixed linenumber formatting

@uliska
Copy link
Collaborator Author

uliska commented Jun 25, 2013

Reports:

  • export to file overwrites without notice
    Is this acceptable or should I perform a check
  • when exporting "with previous settings" file names aren't respected (i.e. there is an empty filename which causes an error).
    Should I remember the last filename or apply the default filename
    (default = document's name with appropriate extension)?
  • Not all options are initialized correctly on startup of the dialog.
  • When exporting to printer/pdf the formatting of the line numbers is only partially respected:
    padding, margin and border properties don't take effect.
    Ideas?

@uliska
Copy link
Collaborator Author

uliska commented Jun 25, 2013

Question:

When exporting to toher formats than printer or pdf the export doesn't contain any font information.
Should we add an option to use the document's font?

While it is generally a good idea not to use hardcoded fonts in html output it might come in handy when creating snippets that should work standalone, i.e. not fit themeselves nicely in an existing design.

@uliska uliska mentioned this pull request Jul 6, 2013
@uliska
Copy link
Collaborator Author

uliska commented Jul 8, 2013

<bump />

Apart from testing I definitely need feedback on the question of the printer set up (bottom right 'cell' of the dialog).
When calling a printer dialog, how can I restrict it not to show options that are already displayed in my dialog (e.g. color mode), and I didn't manage to set it up so the results of the printer dialog are propagated through the main dialog to the actual printer.

@wbsoft
Copy link
Collaborator

wbsoft commented Jul 13, 2013

Sorry: I'm very busy, that's why I didn't yet manage to look at this! I just checked it out and will test the coming few days!

@uliska
Copy link
Collaborator Author

uliska commented Jul 13, 2013

If I know that now it's ok to wait. Next week I'll be away and won't have time for any serious work, but probably for some discussion.

I know it's not ready to be merged, but I wasn't really able to continue without some feedback. Particularly on the open 'printer' issue, but also on the several issues I have already reported myself.

Basically it works pretty good now. If you look at our LilyPond blog you'll notice I'm using it quite heavily ;-)

@wbsoft
Copy link
Collaborator

wbsoft commented Jul 14, 2013

I think the dialog could be simplified by moving settings like leading zeroes, preferred stylesheet handling to a Preferences page. We could then make a menu action File->Export Formatted Source Text... (or, shorter, Export Source...) that opens the dialog.

The dialog could have a combobox chooser for the main types (Html, PDF, ODF Text, PNG image).
Then just some simple to understand settings (e.g. which color scheme, font whether or not to number lines, use selection or full document (greyed out when there is no selection).

Then buttons: Cancel, Preview, Save As..., Copy to Clipboard
And some Drag squares to drag the export as a file, or as copied text.

In the Edit menu the command Copy as colored Html can remain as-is (using the HTML stylesheet handling from the preferences page).

This way the action Export with previous settings (which is somewhat unclear) can be removed. The dialog simply should remember its state.

Will checkback later and I now have somewhat more time... :)

@wbsoft
Copy link
Collaborator

wbsoft commented Jul 17, 2013

I think I could merge this pull request and then re-add the old Print Source option. Then just add the dialog and re-work it so it is more comprehensible.

Applied updates:
- Insert line break before first style in css for export
- export colored (styled) HTML (body only)
- copy styled HTML
- export CSS file
- copy as (inline) styled HTML code
- export (inline) styled HTML (body only)

- Refactor copy source commands

Improve interface:
- suggest "lilypond.css" as filename
- use current dir as default or
- user's home dir if current file isn't saved

Integrate html_document and html_selection
- HTML is now always generated from a selection.
  When exporting the whole document the selection
  is simply expanded to the document

HTML-export: Refactor HTML getter method
- Process incoming LilyPond source line by line (instead of token by token).
  This Will be used for further refinements of output
- Combine consecutive elements
  Consecutive elements, i.e. tokens of the same class,
  separated by spaces (e.g. "c d e f") are now wrapped
  in one single <span> element.

- Handle block comments correctly
  Block comments were rendered to HTML very tokenized so far.
  This wasn't good HTML style and sometimes caused Web editors
  to scramble the results by purging whitespace.

  Now block comments are rendered as class="lilypond-comment"
  on a line-by-line basis. While still being slightly redundant
  this will allow to easily copy&paste single lines from the result.
Move highlight2html.py into export module

start unifying the interface to the export functions
(only one function for the content and one light wrapper
for the whole document. Behaviour isn't set by function
arguments but by properties of the options object)

Fix colorize.py th reflect the modifications

Add dummy for the new dialog
- Add "external css" option
  exports html source code with reference to an external style sheet.
  Only makes sense with
  - document="full"
  - format="html"
- pad first line
  When exporting a selection the first line is prepended
  by an appropriate number of " " so it starts at the
  original position in the line

- Empty clipboard on cancel
Export options are now stored with the global QSettings object.
They are persistent throughout the session,
can be saved explicitely (from the "Export source" dialog) or
implicitely (Checkbox in Preferences->General)

The Dialog itself is a mere dummy yet. At least it shows
disabling of the "Save" button, Cancel and OK work too
(Cancel clears the clipboard)

The export options can't be edited in this intermediate state.
Default values can be set in export/__init__.py,
but they will be overwritten through the Settings.
- Merge routines for printing and exporting to pdf.
  Printing now uses the highlight2html approach like exporting

- Add export to ODT files

TODO: PDF/Printer settings in dialog
- prepend a line number at the beginning of lines
  Configurable number of digits (will be changed later)

  For now I manually enter <span class="lilypond-linenumber"> element around
  the number, without having a corresponding style sheet.

  Should better be a new token class

- Separate 'format' setting
  'format' is now only the html-plain/richtext differenct
  'filetype' is used for html, pdf or odt generation
   Having only 'format' caused issues when exporting to clipboard but 'format=pdf' was set

- Work towards correct font for printout
  (will only be solved much later ...)
- Add elements.
- Start testing interaction with Settings
- Define settings variables (copy) in dialog
  The application logic in the dialog should work
  on a local copy of the export options.
- Map options to widgets
  Use dictionaries to map options to widgets.
  Options are now correctly read from and written to Settings.
- Implement slots WIP
  Bind all widgets to handlers
  Try to handle all depending updates
  (enabling widgets, propagating options)
- Add file dialog
- Add Print/PDF export options
  (Mainly finished)
- Tooltips for most widgets
- Print and PDF-export respect document font
  When using Highlight2Html class for printing
  (instead of the former highlighter.py)
  the font wasn't respected anymore.
  Concretely the <pre> tag caused some different
  font setting to be used.
  Actually the font isn't used at all in HTML export,
  which is generally good.
  But maybe we add an option for that
  (which would then be auto-set for printing)
  The (slightly hacky?) solution is to conditionally
  inject an explicit <pre> CSS class when exporting to PDF or printer.
- Correctly format linenumbers
  Linenumbers now have a separate textformat (in Highlight2Html)
  so the css will correctly be used with inline as well as css formatting
- Improve printer setup dialog (start work)
  In order to use the printer dialog from the export dialog
  I think I have to use one QPrinter object in mainwindow and exportDialog
- Remove "Print source" action
  Print source has been merged into "export source"
- Update File menu mnemonics
  This isn't related to source-export.
  Not all have been set, but significantly more than before
The content is now wrapped in a <pre class="lilypond"> tag.
This should allow to override any styles on existing websites
(our WordPress theme introduced a larger line-height, thus
tearing apart the linenumbers styling).

Currently this includes a hard-coded line-height of 120%,
but this should be made configurable
pre.lilypond is now exported as an empty style class.
This can be used to style the whole <pre> block that is
output with the "lilypond" class.
But setting it to a concrete style is the responsibility of the
actual web design.
@uliska
Copy link
Collaborator Author

uliska commented Sep 18, 2013

As a first step to pick up this work I collected all comments in the different places and created a list of todo tasks (Wilbert: You receive an invitation in parallel but are not bound to participate there).

What I now think is appropriate is having one ComboBox for the main decision what the user actually wants to do. This will have entries like Clipboard (HTML Source) or PDF File.

Depending on this selection all irrelevant options aren't greyed out but hidden completely. I think with this I can make the dialog much simpler.

There is one thing I didn't understand from your comments, though: What do you mean by 'Drag squares'?

@uliska
Copy link
Collaborator Author

uliska commented Oct 8, 2013

I'm closing this now because the branch seems to have become unmergeable anyway. I'm feeling better if I have it privately.
As soon as I'll have developed enough I'll open a new one.

@uliska uliska closed this Oct 8, 2013
@wbsoft
Copy link
Collaborator

wbsoft commented Oct 9, 2013

I like to add/keep the functionality but the dialog needs some work to become user friendly, and I think we should not remove the old print source action.

Shall I try to merge the internal formatted source export functionality in a sane way? Then only the dialog is left over.

@uliska
Copy link
Collaborator Author

uliska commented Oct 9, 2013

I had already decided to restart this from scratch, creating a new branch and go through the old commits one by one, seeing what and how to reuse.

It would be nice if you incorporate the internal functionality. That's probably faster and more reliable. I would then have a clean base to restart the dialog from scratch.

@wbsoft
Copy link
Collaborator

wbsoft commented Oct 9, 2013

Yes. Do you make a pull request for the core functionality or shall I pick the commits myself?

@uliska
Copy link
Collaborator Author

uliska commented Oct 9, 2013

It's probably easier if you inspect the commits yourself, trying to cherry-pick them one by one.

@wbsoft
Copy link
Collaborator

wbsoft commented Oct 9, 2013

Great!

@wbsoft
Copy link
Collaborator

wbsoft commented Oct 9, 2013

I was under the impression that I merged parts of this already but it seems not the case. I.e. the improvements of the HTML output (combine consecutive classes etc.) I'm sorry for that. The pull request was very large and you asked for testing, that has caused the delays (but also that I was very busy those days). If you had first done only the improved html generation (and tested) it would certainly have been included. In smaller steps (smaller commits and pull requests).

@uliska
Copy link
Collaborator Author

uliska commented Oct 9, 2013

I know. You actually did comment on the GUI quite long ago, and if I had had the time then I would have been able to pick up and maybe finish it ...

@wbsoft
Copy link
Collaborator

wbsoft commented Oct 9, 2013

Btw, combining consecutive token classes in HTML will be delayed a bit, because there is a wish for nested highlighting stuff, for example a LilyPond chord syntax that has a certain background color during the whole chord.

So nested highlighting colors will be implemented first, then we''l continue optimizing the HTML output... :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants