Changeset 189 in t29-www for en


Ignore:
Timestamp:
Sep 5, 2010, 6:01:37 AM (13 years ago)
Author:
sven
Message:

Translation-System erweitert, offizieller Upload in Homepage.

  • editor.php ist AJAX-Backend, welches Mail aufsetzt (ziemlich spartanisch)
  • submit.php (ziemlich Quick & Dirty) ist Noscript-Alternative, die komplette Seite auf Text runtergestrippt bearbeitet und an einen dev.technikum29.de-Formmailer verschickt (ansonsten haette man hier noch ein Captcha-System einbauen muessen).
  • tools.js: Ladezeit - editor.js wird bei Aktivierung nachgeladen. Leider geht das mit dem viel groesseren editor.css nicht, weil es den schicken Button rendern muss.
Location:
en
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • en/dev/translation/editor.css

    r188 r189  
    8282#tr-editor.success { background-color: #ACDCA1; }
    8383#tr-editor.success .buttons { visibility:hidden; }
     84#tr-editor.error { background-color: #dca1a1; }
     85#tr-editor.error p { color: black; background-color: red; display: inline; }
    8486#tr-editor .response {
    8587        font-size: 154%;
     
    114116}
    115117
     118/* body.tr-enabled shows only .tr-enabled elements, and vice versa */
    116119body.tr-enabled  .tr-disabled, body.tr-disabled .tr-enabled { display: none; }
    117120body.tr-enabled  .tr-enabled, body.tr-disabled .tr-disabled { display: block; }
     121/* default value, if no body.tr-* present: same state as .tr-disabled! */
     122body .tr-enabled { display: none; }
     123body .tr-disabled { display: block; }
    118124
    119125#sidebar-tr .tr-disabled h3 { margin: 0; font-size: 100%; }
     
    148154        text-decoration: none;
    149155}
     156
     157/* For an optional message at the top */
     158#tr-topnotice {
     159        background-color: #ACDCA1;
     160        padding: 0.1em 1em; margin-bottom: 1em;
     161        -moz-box-shadow: 1px 0 8px #999999;
     162}
     163
     164body.tr-disabled #tr-topnotice { display: none; }
    150165
    151166/*
  • en/dev/translation/editor.js

    r188 r189  
    1414t29.tr.settings = {
    1515    disable_img_license_system: true, // when tr system enabled, disable img licenses for more cleareness
    16         editable_elements: function(){ return $("#content").find("p, ul, blockquote, h2, h3"); },
     16        editable_elements: function(){ return $("#content").find("p, ul, ol, blockquote, h2, h3"); },
    1717        infobox_default: "<b>Click</b> to contribute a better translation",
    1818        infobox_corrected: "<span class='thanks'>Thank you for your correction.</span> Click to improve your text again.",
    19         editorbox_heading: "Contribute a better translation"
     19        editorbox_heading: "Contribute a better translation",
     20        top_notice_text: "<h3>Thank you for improving this page</h3><p>Simply hover the text with your mouse and edit a paragraph by clicking on it.</p>"
    2021};
    2122
     
    3435        if(!t29.tr.is_enabled()) $("body").addClass("tr-disabled"); // prepare
    3536        t29.tr.sidebar = $("#sidebar-tr");
    36         t29.tr.sidebar.find(".tr-disabled a").click(function() {
    37                 t29.tr.set_enabled(true);
    38                 return false;
    39         }).attr('href', '#help_with_mistakes'); // href for nicer look
    40        
    4137        t29.tr.sidebar.find(".tr-enabled .button").click(t29.tr.call("set_enabled",false));
    4238       
     
    9692        } else {
    9793                // system powered off
    98                 // t29.tr.set_editing(false) already called.
    99                 // so we can safely remove any handlers
    100                 t29.tr.editables.unbind();
     94                t29.tr.set_editing(false); // for safety, just another time
     95                t29.tr.editables.unbind(); // safely remove *all* hovering handlers
     96                // remove any old trash:
     97                $(".tr-inspecting").removeClass("tr-inspecting");
     98                t29.tr.mouseout_editables(); // falls noch was uebrig ist
    10199        }
    102100        return true; // success
     
    108106 **/
    109107t29.tr.mouseover_editables = function() {
    110         if(t29.tr.is_editing()) return; // disable while editing
     108        if(!t29.tr.is_enabled() || t29.tr.is_editing()) return; // disable while editing
     109        if(t29.tr.current_editable) {
     110                // this is weird and should not be - cleanup missed!
     111                t29.tr.current_editable.removeClass("tr-inspecting");
     112        }
    111113        t29.tr.current_editable = $(this).addClass('tr-inspecting');
    112114
     
    224226                // stop editing
    225227                t29.tr.initial_editor = null;
    226                 old_editor.attr("contenteditable", "false").removeClass("tr-editing");
     228                //              v- falls es noch irgendeinen anderen Muell geben sollte
     229                old_editor.add(".tr-editing").attr("contenteditable", "false").removeClass("tr-editing");
    227230                t29.tr.editorbox.hide();
    228231        }
     
    252255        // button submitting
    253256        if(!t29.tr.is_really_editing()) {
    254                 alert("You didn't make any changes to the text. Where's the improvement? :-)");
    255                 return false;
     257                // funktioniert nicht zuverlaessig.
     258                //alert("You didn't make any changes to the text. Where's the improvement? :-)");
     259                //return false;
    256260        }
    257261       
     
    261265                success: t29.tr.submit_successful,
    262266                error: function(req, textStatus) {
    263                         alert("I'm sorry, submitting the text failed due to "+textStatus
    264                                 +"\nPlease mail your text to "+"ed.92mukinhcet@ved".split("").reverse().join(""));
    265                         t29.tr.editorbox.removeClass('loading');
     267                        t29.tr.editorbox.removeClass('loading').addClass('error');
     268                        t29.tr.editorbox.find('h3').html("Sending your improved text failed!");
     269                        t29.tr.editorbox.find('p').html("Please consult the <span class='button small red'>Help</span>")
     270                                .find('.button').click(t29.tr.help);
     271                        if(req.responseText)
     272                                t29.tr.editorbox.find('p').prepend("<b>"+req.responseText+"</b> ");
     273                        alert("Submitting your text failed!");
    266274                },
    267275                data: {
     
    269277                        page: location.href,
    270278                        node: "foobar", // t29.tr.editor XQUERY PATH
    271                         initial_text: t29.tr.initial_editor.html(),
    272                         new_text: t29.tr.editor.html()
     279                        initial_text: t29.tr.initial_editor.text().replace(/\s+/g,' '),
     280                        initial_html: t29.tr.initial_editor.html(),
     281                        new_text: t29.tr.editor.text().replace(/\s+/g,' '),
     282                        new_html: t29.tr.editor.html()
    273283                }
    274284        });
     
    323333        t29.tr.editorbox.find(".cancel").click(t29.tr.stop_editing);
    324334        t29.tr.editorbox.find(".submit").click(t29.tr.submit_editing);
     335        t29.tr.editorbox.find(".help").click(t29.tr.help);
    325336       
    326337        t29.tr.editorbox.css({
     
    329340                width: t29.tr.editor.width()
    330341        }).show();
     342};
     343
     344/**
     345 * Open a nice help window
     346 **/
     347 t29.tr.help = function() {
     348        window.open("http://dev.technikum29.de/wiki/%dcbersetzung/Help");
     349
    331350};
    332351
     
    353372}
    354373
     374t29.tr.display_top_notice = function() {
     375        $("<div id='tr-topnotice'/>").html(t29.tr.settings.top_notice_text).prependTo("#content");
     376};
     377
    355378// Master entry point: Load onload handler at startup.
    356379$(t29.tr.onload);
  • en/dev/translation/submit.php

    r187 r189  
    1 Thank you
     1<?php
     2/**
     3 * technikum29 translation system submission for AJAX calls.
     4 * September 2010, Quick and dirty
     5 **/
     6
     7function get($var, $default=false, $valids=null, $do_not_check_for_bad_input=false) {
     8        $value = isset($_POST[$var]) ? $_POST[$var] : $default;
     9        if(isset($valids) && !in_array($value, $valids)) $value = $default;
     10        if(preg_match('/<(\s*)(script|style)|php|javascript|on[a-z]=/i', $value)) {
     11                // bad content! Exit immediately.
     12                header("HTTP/1.1 400 Bad Request");
     13                print "Illegal value for '$var'. Please contact the staff.";
     14                exit();
     15        }
     16        return $value;
     17}
     18
     19$source = get("source", false, array('ajax'));
     20$page = get("page");
     21$node = get("node");
     22$initial_text = get("initial_text");
     23$initial_html = get("initial_html");
     24$new_text = get("new_text");
     25$new_html = get("new_html");
     26
     27// spamschutz
     28if(!$source) {
     29        header("HTTP/1.1 400 Bad Request");
     30        print "Only AJAX driven calls are allowed.";
     31        exit;
     32}
     33
     34// some intermediates
     35$pagename = preg_match("#/([^/]+?)(\.[a-z]+)?$#i", $page, $pageparts) ? $pageparts[1] : false;
     36
     37// setup mail
     38$to = "sven";
     39$to .= "@technikum29.de"; // spamschutz (svn!)
     40$subject = "t29 translation submission";
     41if($pagename) $subject .= " for $pagename";
     42$message = <<<HERE
     43This ist technikum29 translation system at /en/dev/translation/submit.php form mailer.
     44A user translated, using $source,
     45        Page: $page
     46        Node: $node
     47       
     48New Plain Text is:
     49
     50----------------------- START OF USER TEXT ------------------------------------
     51$new_text
     52------------------------ END OF USER TEXT -------------------------------------
     53
     54Versus old Plaintext was:
     55
     56----------------------- START OF OLD TEXT ------------------------------------
     57$initial_text
     58------------------------ END OF OLD TEXT -------------------------------------
     59
     60New HTML is:
     61
     62------------------------ START OF USER HTML -----------------------------------
     63$new_html
     64------------------------ END OF USER HTML -------------------------------------
     65
     66Old HTML was:
     67
     68------------------------ START OF OLD HTML -----------------------------------
     69$initial_html
     70------------------------ END OF OLD HTML -------------------------------------
     71
     72Something about the user:
     73
     74        Referer: $_SERVER[HTTP_REFERER]
     75        Agent:   $_SERVER[HTTP_USER_AGENT]
     76        IP:      $_SERVER[REMOTE_ADDR]
     77HERE;
     78
     79// Send mail right now
     80
     81if(mail($to, $subject, $message, "From: t29-translation-www"."@technikum29.de")) {
     82        // mail successfully sent
     83        print "Mail successfully sent :)";
     84} else {
     85        // error at mail sending!!!
     86        header("HTTP/1.1 500 Internal Server Error");
     87        print "I'm sorry, I could not mail your text to the developer team.";
     88}
     89
     90
  • en/inc/head.inc.shtm

    r187 r189  
    2222    <script type="text/javascript" src="/shared/js/common.js"></script>
    2323        <!-- translation system -->
    24         <script type="text/javascript" src="/en/dev/translation/editor.js"></script>
     24        <!--<script type="text/javascript" src="/en/dev/translation/editor.js"></script>-->
    2525        <link rel="stylesheet" type="text/css" href="/en/dev/translation/editor.css" />
    2626        <!-- translation end -->
  • en/inc/menu.inc.shtm

    r187 r189  
    8181                <p>This site was voluntarily trans&shy;lated by project collab&shy;orators.
    8282                   We'ld love to get your help!</p>
    83                 <a class="button white medium" href="/en/dev/translation/traditional.php?page=<!--#echo var="DOCUMENT_URI" -->"
     83                <a class="button white medium" href="/en/dev/translation/editor.php?page=<!--#echo var="DOCUMENT_URI" -->"
    8484                        title="Edit sentences directly inline!">Improve this page</a>
    8585        </div>
Note: See TracChangeset for help on using the changeset viewer.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License