Changeset 2541

Show
Ignore:
Timestamp:
02/24/10 21:31:33 (5 months ago)
Author:
JensDiemer
Message:
  • new: markup help pages
  • new: page list
Location:
branches/0.9/pylucid_project
Files:
11 added
8 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/models/pagecontent.py

    r2477 r2541  
    44    PyLucid models 
    55    ~~~~~~~~~~~~~~ 
    6      
     6 
    77    Last commit info: 
    88    ~~~~~~~~~~~~~~~~~ 
     
    4343    """ 
    4444    A normal CMS Page with text content. 
    45      
     45 
    4646    signals connection is in pylucid_project.apps.pylucid.models.__init__ 
    4747 
     
    6161    MARKUP_REST = 5 
    6262 
    63     MARKUP_CHOICES = ( 
    64         (MARKUP_CREOLE      , u'Creole wiki markup'), 
    65         (MARKUP_HTML        , u'html'), 
    66         (MARKUP_HTML_EDITOR , u'html + JS-Editor'), 
    67         (MARKUP_TINYTEXTILE , u'textile'), 
    68         (MARKUP_TEXTILE     , u'Textile (original)'), 
    69         (MARKUP_MARKDOWN    , u'Markdown'), 
    70         (MARKUP_REST        , u'ReStructuredText'), 
     63    MARKUP_DATA = ( 
     64        # [0] = markup ID (e.g. database integer field) 
     65        # [1] = lowcase, ASCII-only, no spaces (e.g. for filename) 
     66        # [2] = verbose name (used e.g. in select input form) 
     67        (MARKUP_CREOLE, u"creole", u'Creole wiki markup'), 
     68        (MARKUP_HTML, u"html", u'html'), 
     69        (MARKUP_HTML_EDITOR, u"htmleditor", u'html + JS-Editor'), 
     70        (MARKUP_TINYTEXTILE, u"tinytextile", u'tinytextile'), 
     71        (MARKUP_TEXTILE, u"textile", u'Textile (original)'), 
     72        (MARKUP_MARKDOWN, u"markdown", u'Markdown'), 
     73        (MARKUP_REST, u"rest", u'ReStructuredText'), 
    7174    ) 
     75    # For djanfo choice form field: 
     76    MARKUP_CHOICES = [(data[0], data[2]) for data in MARKUP_DATA] 
     77 
     78    # For easy "get name by id": 
    7279    MARKUP_DICT = dict(MARKUP_CHOICES) 
     80 
     81    # for mapping the ID with short name 
     82    MARKUP_SHORT_DICT = dict([(data[0], data[1]) for data in MARKUP_DATA]) 
     83 
    7384    #-------------------------------------------------------------------------- 
    7485 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/admin_urls.py

    r2477 r2541  
    2424from admin_views.page_order import page_order 
    2525from admin_views.tag_list import tag_list 
     26from admin_views.page_list import page_list 
     27from admin_views.markup_help import markup_help 
    2628from admin_views.translate_page import translate_page 
    2729 
     
    3537    url(r'^translate/(?P<pagemeta_id>\d+?)/$', translate_page, name='PageAdmin-translate'), 
    3638    url(r'^tag_list/$', tag_list, name='PageAdmin-tag_list'), 
     39    url(r'^page_list/$', page_list, name='PageAdmin-page_list'), 
     40    url(r'^markup_help/$', markup_help, name='PageAdmin-markup_help'), 
    3741    url(r'^bulk_editor/$', bulk_editor, name='PageAdmin-bulk_editor'), 
    3842) 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/admin_views/edit_page.py

    r2494 r2541  
    6464        "template_name": "page_admin/edit_content_page.html", 
    6565        "abort_url": pagecontent.get_absolute_url(), 
     66        "pagecontent": pagecontent, 
     67 
     68        "markup_id_str": str(pagecontent.markup), 
    6669 
    6770        "all_forms": all_forms, # For display the form error list from all existing forms. 
     
    7073        "pagemeta_form":pagemeta_form, 
    7174        "pagecontent_form": pagecontent_form, 
    72  
    73         "pagelinklist_url": "#TODO", 
    7475    }) 
    7576    return context 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/forms.py

    r2512 r2541  
    110110        exclude = ("pagemeta",) 
    111111 
     112def _markup_choices(*id_filter): 
     113    choices = [entry for entry in PageContent.MARKUP_CHOICES if entry[0] in id_filter] 
     114    return choices 
     115 
    112116 
    113117class ConvertMarkupForm(forms.ModelForm): 
    114118    # Use only supported markups for converting choice field 
    115     MARKUP_CHOICES = [entry for entry in PageContent.MARKUP_CHOICES 
    116         if entry[0] in ( 
    117             PageContent.MARKUP_CREOLE, PageContent.MARKUP_HTML, PageContent.MARKUP_HTML_EDITOR 
    118         ) 
    119     ] 
    120     dest_markup = forms.IntegerField( 
    121         widget=forms.Select(choices=MARKUP_CHOICES), 
     119    MARKUP_CHOICES = _markup_choices( 
     120        PageContent.MARKUP_CREOLE, PageContent.MARKUP_HTML, PageContent.MARKUP_HTML_EDITOR 
     121    ) 
     122    dest_markup = forms.ChoiceField( 
     123        choices=MARKUP_CHOICES, 
    122124        help_text=_("convert the current page content to this new markup"), 
    123125    ) 
     
    125127        help_text=_("Display original html and a html diff."), 
    126128    ) 
     129    def clean_markup(self): 
     130        return int(self.cleaned_data['markup']) 
    127131    class Meta: 
    128132        model = PageContent 
    129133        fields = ('content',) 
     134 
     135 
     136class SelectMarkupForm(forms.Form): 
     137    """ for page list admin view """ 
     138    markup = forms.ChoiceField( 
     139        choices=PageContent.MARKUP_CHOICES, 
     140        help_text=_("switch to other markup format"), 
     141    ) 
     142 
     143 
     144class SelectMarkupHelpForm(forms.Form): 
     145    """ 
     146    For markup help admin view 
     147    There ist no help page for html code 
     148    """ 
     149    MARKUP_CHOICES = _markup_choices( 
     150            PageContent.MARKUP_CREOLE, 
     151            PageContent.MARKUP_TINYTEXTILE, 
     152            PageContent.MARKUP_TEXTILE, 
     153            PageContent.MARKUP_MARKDOWN, 
     154            PageContent.MARKUP_REST, 
     155    ) 
     156    markup = forms.ChoiceField( 
     157        choices=MARKUP_CHOICES, 
     158        help_text=_("switch to other markup help"), 
     159    ) 
     160    def clean_markup(self): 
     161        return int(self.cleaned_data['markup']) 
     162 
     163 
     164#    class Meta: 
     165#        model = PageContent 
     166#        fields = ('markup',) 
    130167 
    131168 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/templates/page_admin/edit_inline_form.html

    r2525 r2541  
    2424jQuery(document).ready(function($) { 
    2525    log("edit_inline_form.html ready."); 
    26       
     26 
    2727    $("#ajax_preview").show(); // unhide ajax preview button 
    28     
     28 
    2929    $("#edit_page_form").change(function() { 
    3030        log("edit page form change"); 
     
    4141        $("#edit_page_form").before('<h2 class="ajax_msg">{% trans "submit" %}...</h2>'); 
    4242    }); 
    43      
     43 
    4444    // $(window).bind('beforeunload', function() { 
    4545    // ^ this doesn't work! 
     
    4747        log("beforeunload evend called. textarea_changed:" + textarea_changed); 
    4848        if (textarea_changed == true) { 
    49             return "{% trans "Textarea has been changed! Changes are not saved if you leave." %}";  
     49            return "{% trans "Textarea has been changed! Changes are not saved if you leave." %}"; 
    5050        } 
    5151    } 
    52     
     52 
    5353    // from media/PyLucid/pylucid_js_tools.js 
    5454    // pylucid_ajax_form_view('#edit_page_form'); 
    5555    replace_openinwindow_links(); 
    56      
     56 
    5757    var preview_div = $("#edit_page_preview"); 
    58      
     58 
    5959    $("#ajax_preview").click(function() { 
    6060        log("ajax preview clicked"); 
     
    6262        $("#edit_page_preview").html('<h2 class="ajax_msg">{% trans "loading" %}...</h2>'); 
    6363        $("#preview_fieldset").slideDown(); 
    64      
     64 
    6565        var content = $("#id_content")[0].value; 
    66      
     66 
    6767        var url = encodeURI("{{ preview_url }}"); 
    6868        log("post:" + url); 
    6969        log("content:" + content); 
    70          
     70 
    7171        $.post(url, { "content": content, "preview": true }, function(form_html){ 
    7272            preview_div.html(form_html); 
     
    7474    }); 
    7575    $("#submit_preview").hide(); 
    76      
     76 
    7777    $("#abort_button").click(function() { 
    7878        {% comment %} 
     
    8282        self.location.href='{{ abort_url }}'; 
    8383    }); 
    84      
     84 
    8585    activate_resize_textarea_buttons(); 
    8686}); 
     
    9797    {% trans 'Edit the CMS page' %} '<strong>{{ pagemeta.get_title|escape }}</strong>' 
    9898</legend> 
    99 <form action="{{ form_url }}" method="post" id="edit_page_form">    
     99<form action="{{ form_url }}" method="post" id="edit_page_form"> 
    100100 <div class="helper_buttons"> 
    101101     <input type="submit" name="save" value="{% trans 'save' %}" /> 
     
    105105     </button> 
    106106     <input type="button" id="abort_button" name="abort" value="{% trans 'abort' %}" /> 
    107      <a href="{{ pagelinklist_url }}" class="openinwindow" title="{% trans 'List of all pages for creating links' %}"> 
     107     <a href="{% url PageAdmin-page_list %}?markup={{ pagecontent.markup }}" class="openinwindow" title="{% trans 'List of all pages for creating links' %}"> 
    108108         <button type="button" class="button">{% trans 'page list' %}</button> 
    109109     </a> 
     
    111111         <button type="button" class="button">{% trans 'tag list' %}</button> 
    112112     </a> 
     113 
     114     {% if markup_id_str in "26" %} 
     115     <a href="{% url PageAdmin-markup_help %}?markup={{ pagecontent.markup }}" class="openinwindow" title="{% trans 'Markup help' %}"> 
     116         <button type="button" class="button">{% trans 'markup help' %}</button> 
     117     </a> 
     118     {% endif %} 
     119 
    113120     <button type="button" class="button resize_textarea" id="bigger_id_content" title="{% trans 'makes the textarea bigger' %}"> 
    114121         + 
     
    117124         - 
    118125     </button> 
    119  </div>    
     126 </div> 
    120127{% with edit_page_form as form %} 
    121128    {% include "admin/pylucid/includes/pylucid_formset.html" %} 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/templates/page_admin/includes/edit_content_page_buttons.html

    r2449 r2541  
    88    {% endif %} 
    99    <input type="submit" id="preview" name="preview" value="{% trans 'markup preview' %}" /> 
    10     <a href="{{ pagelinklist_url }}" class="openinwindow" title="{% trans 'List of all pages for creating links' %}"> 
     10    <a href="{% url PageAdmin-page_list %}?markup={{ pagecontent.markup }}" class="openinwindow" title="{% trans 'List of all pages for creating links' %}"> 
    1111        <button type="button" class="button">{% trans 'page list' %}</button> 
    1212    </a> 
     
    1414        <button type="button" class="button">{% trans 'tag list' %}</button> 
    1515    </a> 
     16 
     17     {% if markup_id_str in "26" %} 
     18     <a href="{% url PageAdmin-markup_help %}?markup={{ pagecontent.markup }}" class="openinwindow" title="{% trans 'Markup help' %}"> 
     19         <button type="button" class="button">{% trans 'markup help' %}</button> 
     20     </a> 
     21     {% endif %} 
     22 
    1623    <button type="button" class="button resize_textarea" id="bigger_id_content" title="{% trans 'makes the textarea bigger' %}"> 
    1724        + 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/templates/page_admin/tag_list_popup.html

    r2517 r2541  
    11{% extends "admin/base_site.html" %} 
     2 
     3{% block extrahead %} 
     4<style type="text/css"> 
     5.example_link { 
     6    padding: 0px; 
     7    margin: 0px; 
     8    min-width: 400px; 
     9    width: 100%; 
     10    border: 0px!important; 
     11} 
     12tr { 
     13    background-color: #ffffff; 
     14} 
     15tr:hover { 
     16    background-color: #e0e0e0; 
     17} 
     18 
     19</style> 
     20<script type="text/javascript"> 
     21jQuery(document).ready(function($) { 
     22        $('.example_tag').each(function() { 
     23                // 'resize' every input field 
     24        var len = $(this).val().length; 
     25        $(this).attr("size", len); 
     26        $(this).attr("maxlength", len); 
     27        }); 
     28        $('.example_tag').hover(function() { 
     29                $(this).select(); 
     30        }); 
     31}); 
     32</script> 
     33{% endblock extrahead %} 
    234 
    335{% block content %} 
     
    1446    <td title="for copy&amp;paste into your cms page" class="nowrap"> 
    1547        {% if lucid_tag.fallback_example %} 
    16             <i title="The plugin has no example in source code!">{{ lucid_tag.fallback_example }}</i> 
     48            <input type="text" class="example_tag" title="automatic generated example" value='{{ lucid_tag.fallback_example }}'></input><br /> 
    1749        {% else %} 
    18             {% if lucid_tag.examples %} 
    19                 {{ lucid_tag.examples|join:"<br />" }} 
    20             {% endif %} 
     50            {% for example in lucid_tag.examples %} 
     51                <input type="text" class="example_tag" value='{{ example }}'></input><br /> 
     52            {% endfor %} 
    2153        {% endif %} 
    2254    </td> 
  • branches/0.9/pylucid_project/pylucid_plugins/page_admin/views.py

    r2477 r2541  
    7070        "preview_html": preview_html, 
    7171 
    72         "pagelinklist_url": "#TODO", #FIXME ;) 
    73         "taglist_url": "#TODO", #FIXME ;) 
     72        "markup_id_str": str(pagecontent.markup), 
    7473 
    7574        "edit_page_form": edit_page_form,