利用者・トーク:Sobek

提供: wiki
移動先: 案内検索

I am new to wikis and CSS! Keep that in mind, please. :)


Taking a deep look at the following resources should help me to get into this wiki stuff rather soon
http://meta.wikimedia.org/wiki/Help:Editing,
http://meta.wikimedia.org/wiki/Help:Cascading_style_sheets, and
http://meta.wikimedia.org/wiki/Help:Contents

http://mediawiki.blender.org/index.php/Meta/customStyles.css and
http://mediawiki.blender.org/index.php/MediaWiki:Common.css
are the CSS code pages across the wiki

This column-approach is intended to be a fix for http://mediawiki.blender.org/index.php/Manual/Python_Scripting because you cannot select the python code without the line numbering! Unfortunalety, http://meta.wikimedia.org/wiki/Help:Table will not work good enough here. Leaving it to you to delete the line numbering.
With the solution presented here you can copy and paste the python code right away :)

001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032

######################################################
#
# Demo Script for Blender 2.3 Guide
#
###################################################S68
# This script generates polygons. It is quite useless
# since you can do polygons with ADD->Mesh->Circle
# but it is a nice complete script example, and the
# polygons are 'filled'
######################################################

######################################################
# Importing modules
######################################################

import Blender
from Blender import NMesh
from Blender.BGL import *
from Blender.Draw import *

import math
from math import *

# Polygon Parameters
T_NumberOfSides = Create(3)
T_Radius = Create(1.0)

# Events
EVENT_NOEVENT = 1
EVENT_DRAW = 2
EVENT_EXIT = 3


added a colored background for the line numbering. Do you think this is more appealing then a colored background for the python code?


problems I have faced so far with => possible solutions:

  • many #'s in one line are converted to numbers
    =>use /nowiki command, this also fixes problem with br command which was the introduction of an empty line at the very beginning of the table
  • should python code be in tables with a dashed border? pre command turns whole commands into text, that equals no more columns
    => YES it should! See http://mediawiki.blender.org/index.php/Meta/Templates however only one column is intended with this template, so no line numbering!
  • working with existing classes (columnHalf and columnThird) won't work, because this will introduce empty new lines in the python code if the code is long enough



So I am calling for:

  • introduction of new classes, like "numberColumn" and "scriptColumn" Maybe numberColumn could be like 10 % and script column 90 % of width? on the other hand number column could probably be ok with fixed value if the wiki is changed to be scaleable to screen, latter would be better option (suggested by BeBraw and oxigen)
    => maybe call them "columnNumber" and "columnScript" to be consistent with other column names. Isn't a percentual width better then a fixed width?!


Alternative solution by using numbered list offered by wiki

Here's another way to do the same thing.

  1. ######################################################
  2. #
  3. # Demo Script for Blender 2.3 Guide
  4. #
  5. ###################################################S68
  6. # This script generates polygons. It is quite useless
  7. # since you can do polygons with ADD->Mesh->Circle
  8. # but it is a nice complete script example, and the
  9. # polygons are 'filled'
  10. ######################################################
  11. #
  12. ######################################################
  13. # Importing modules
  14. ######################################################
  15. #
  16. import Blender
  17. from Blender import NMesh
  18. from Blender.BGL import *
  19. from Blender.Draw import *
  20. #
  21. import math
  22. from math import *
  23. #
  24. # Polygon Parameters
  25. T_NumberOfSides = Create(3)
  26. T_Radius = Create(1.0)
  27. #
  28. # Events
  29. EVENT_NOEVENT = 1
  30. EVENT_DRAW = 2
  31. EVENT_EXIT = 3

The problem with this solution is that it does not handle empty lines. Perhaps there's reasonable solution available for that? Also it does not support numbering such as 0001,0002,0003 that might be nice considering layout and readability.

--BeBraw 20:29, 23 August 2006 (CEST)


CSS code used in blenderpython.org

Joe mentioned on the docboard mailinglist:
"Timmeh (tim wakeham) has implemented this in blenderpython.org, you could try emailling him about how he did it  :)"

for instance:
http://wiki.blenderpython.org/index.php/BPyIntro/Creating_Geometry_with_Blender_Python
I have tried to recreate it here, but I failed miserable

Sobek 13:31, 25 August 2006 (CEST)

blenderpython.org Solution

I recieved an email regarding the implementation of proper scripting display for python in the blender wiki. The BPyWiki actually handles this with a custom extension that I wrote specifically for the wiki.

As far as I know there is no way you can do the line numbers automatically for every case using wiki templates and wikiscript. I have tried using just templates many times and have never quite succeeded, one of the difficulties, as BeBraw described above is the lack of support for new lines, which is not an issue for the pysnippet extension that BPyWiki uses.

I will paste the code for the pysnippet extension below, however, server access is required to install it, as it requires an entry in LocalSettings.php file.

[edit] For some reason this wiki screws up php code big time, so you can see the extension at [edit again] nope don't bother wiki doesn't seem to like php at all, even my extension has a fit over it. Ok try pastebin, http://pastebin.com/778930

The syntax highlight function is not necessary but I posted for completeness. I haven't completely implemented this feature on the BPyWiki, mostly because my server is currently taking issue to php writing files regardless of permissions. I'm sure there is a better way around this with pipes and popen functions, but my knowledge of linux is not developed enough to understand how this works.

Once the extension is installed by adding the line -

include_once('extensions/pysnippet.php');

to the LocalSettings.php file, it's a simple matter of using pysnippet tags.

Example

<pysnippet>
import Blender

...
...
...

Blender.Redraw()
</pysnippet>

You can also use the line parameter to start the line numbers at a certain number, as per http://wiki.blenderpython.org/index.php/BPyIntro/Creating_Geometry_with_Blender_Python in the line by line walk-thru of the script.

eg.

<pysnippet line=3 >
...
...

Blender.Redraw()
</pysnippet>

The stylesheet is visible at http://wiki.blenderpython.org/index.php/MediaWiki:Bpywiki.css

If you need further assistance with the set up of the extension or further implementation, let me know, I've developed a fair bit of experience modifying wiki to make it work how *I* want.

--timmeh 17:56, 29 August 2006 (CEST)