rejetto forum

Software => Other languages => HFS ~ HTTP File Server => Español => Topic started by: Tharless on May 27, 2016, 04:27:19 PM

Title: Función Copiar
Post by: Tharless on May 27, 2016, 04:27:19 PM
Buenos días a todos,

Como lo había comentado en otro post, cuento con una modificación al tpl original donde incluí la función copiar, esto debido a la necesidad de utilizarlo. Adjunto el tpl para que todos puedan utilizarlo y de pronto si tienen mejoras puedan sugerirmelas y ayudarnos cada vez mas.

Espero poder contribuirles más y por fin sacar versión 3 que pienso yo que sería ayudar al HFS con el sc para realmente crearlo como servicio.

Un saludo desde Colombia. 8)
Title: Re: Función Copiar
Post by: LeoNeeson on May 28, 2016, 07:53:58 AM
Muy bueno!, gracias, lo voy a probar este fin de semana.
Saludos....

EDITO: Lo probé apenas un poco y me pareció un trabajo muy bueno (no tuve tiempo de probar si funciona bien, pero el 'concepto' es bueno). :) Si funciona bien, posiblemente el código sea "candidato" a ser agregado en la próxima versión, si es que no tiene ningún error y a Rejetto le gusta. A continuación voy a comentar en inglés y postear los cambios que trae tu nueva plantilla, para que los demás la vean más fácilmente y digan que les parece.



"Copy" function by Tharless.

The user Tharless added the "copy" function to the default template. Mainly, these are the changes (marked in red):
Quote
[+special:strings]
option.copy=1

[box actions]
   {.if|{.and|{.!option.copy.}|{.can copy.}.}| <button id='copyBtn' onclick='copyClicked()'>{.!Copy.}</button> .}
   </fieldset>

[ajax.copy|no log]
{.check session.}
{.set|dst|{.force ansi|{.postvar|dst.}.}.}
{.break|if={.not|{.and|{.can move.}|{.get|can delete.}|{.get|can upload|path={.^dst.}.}/and.}.} |result={.!forbidden.}.}
{.set|log|{.!Copying items to.} {.^dst.}.}
{.for each|fn|{.replace|:|{.no pipe||.}|{.force ansi|{.postvar|files.}.}.}|{:
   {.break|if={.is file protected|var=fn.}|result=forbidden.}
    {.set|x|{.force ansi|%folder%.}{.^fn.}.}
    {.set|y|{.^dst.}/{.^fn.}.}
    {.if not |{.exists|{.^x.}.}|{.^x.}: {.!not found.}|{:
        {.if|{.exists|{.^y.}.}|{.^y.}: {.!already exists.}|{:
            {.if|{.length|{.copy|{.^x.}|{.^y.}.}.} |{:
                {.set|log|{.chr|13.}{.^fn.}|mode=append.}
                {.move|{.^x.}.md5|{.^y.}.md5.}
                {.move|{.^x.}.comment|{.^y.}.comment.}
            :} | {:
                {.set|log|{.chr|13.}{.^fn.} (failed)|mode=append.}
                {.maybe utf8|{.^fn.}.}: {.!not copied.}
            :}/if.}
        :}/if.}
    :}.}
    ;
:}.}
{.add to log|{.^log.}.}

[special:alias]
can copy=and|{.get|can upload.}

function copyClicked() {
    ezprompt("{.!Enter the destination folder.}", {type:'text'}, function(s){
        ajax('copy', {dst:s, files:selectedFilesAsStr()}, function(res){
            var a = res.split(";");
            if (a.length < 2)
                return alert($.trim(res));
            var failed = 0;
            var ok = 0;
            var msg = "";
            for (var i=0; i<a.length-1; i++) {
                var s = $.trim(a);
                if (!s.length) {
                    ok++;
                    continue;
                }
                failed++;
                msg += s+"\n";
            }
            if (failed)
                msg = "{.!We met the following problems:.}\n"+msg;
            msg = (ok ? ok+" {.!files were copied..}\n" : "{.!No file was copied..}\n")+msg;
            alert(msg);
            if (ok) location = location; // reload
        });
    });
}//copyClicked

I didn't have enough time to thoroughly test it, but it seems to be interesting (I haven't tested it yet). If this works well and Rejetto like it (and finds it useful), maybe this can be added as default in the next version. Anyone can test it, and report back if finds any error (or if has a better syntax).
Title: Re: Función Copiar
Post by: LeoNeeson on May 28, 2016, 09:50:48 AM
Lo probé usando una carpeta real, y me dice "forbidden" (prohibido), luego de ingresar la carpeta de destino donde copiar un archivo. Seguro que estoy haciendo algo mal, o quizás sólo funcione con "carpetas virtuales", y no "reales"? (o haya algún otro problema en el código) :-\

Igualmente buen trabajo! (http://i.imgur.com/ah8Mtea.gif)

I've tested it using a 'real folder' (not 'virtual folder'), and it says "forbidden" after enter the destination, when trying to copy a file. Maybe I doing something wrong, or there is an error in the code. :-\

PD: Estaría bien que si la carpeta no existe, se crease una carpeta nueva.
PS: It would be nice, if the destination folder doesn't exists, make automatically a new folder.
Title: Re: Función Copiar
Post by: Tharless on May 28, 2016, 01:32:03 PM
Hola Leo,

De hecho me funciona solo con carpetas reales, te publico capturas...

Creo que de pronto el error es la ruta indicada... observa como la escribo en la captura...

Me confirmas por favor. ;D
Title: Re: Función Copiar
Post by: LeoNeeson on May 29, 2016, 09:47:28 AM
Los 'screenshots' que subiste son muy pequeños (448x252px) como para entender lo que dice (tuve que hacerle un zoom de 800x para ver algo :P) y apenas pude ver que la carpeta la escribes así:

Code: [Select]
/NombreDeCarpeta/
Igualmente me sigue dando el mismo error: "forbidden". :(
Title: Re: Función Copiar
Post by: Tharless on May 29, 2016, 01:04:37 PM
Puedo subir algún tipo de vídeo?
Title: Re: Función Copiar
Post by: Tharless on May 29, 2016, 02:06:37 PM
Hola Leo,

Mira el error debe ser por lo siguiente: Estuve leyendo los comandos del HFS y existe el copy, pero para ese comando hay que colocar la ruta completa, es decir, en mi caso yo realicé la prueba con una carpeta en el root osea "/prueba/"; para otra prueba debes escribir la ruta completa ej: si el archivo a donde lo quieres copiar está así: "/prueba/abc/[carpeta destino]".

Es lo mismo como si fuera a mover un archivo cualquiera "en teoría como está en el wiki".
Title: Re: Función Copiar
Post by: LeoNeeson on May 30, 2016, 05:17:13 AM
Probe de mil maneras y es igual. Seguro que hay que tener configurado el HFS de cierta forma para que funcione. Seria bueno si alguien del foro revisa esto y nos comenta como solucionarlo.
Title: Re: Función Copiar
Post by: Tharless on May 31, 2016, 12:02:42 AM
Te sirve el ini del HFS?
Title: Re: Función Copiar
Post by: LeoNeeson on May 31, 2016, 05:30:52 AM
@Tharless: Sí, podría ser, otra opción no queda ya que ahi están todas las configuraciones (pero igual se me hace extraño el error). Si lo subes lo pruebo, pero ahora que veo (por los screenshots que subiste), tu utilizas Windows 7, y yo estoy utilizando Windows XP.

¿Quizás no funcione tu macro con el XP? (ahora mismo no tengo ningun Windows 7 instalado para probarlo, sino lo haría). En caso de confirmarse esto, sería bueno que funcione también con Windows XP. Quizás Rejetto si lee y entiende esto pueda confirmarlo, porque él también utiliza el XP.

@bmartino1: Have you tested the "copy" function? Does it work for you? I ask you, because it doesn't work here (when I try to copy something, it says "forbidden")
Title: Re: Función Copiar
Post by: bmartino1 on May 31, 2016, 02:15:14 PM
haven't had time, will download and try over the weekend, it on my todo list along with CJs lubuntu issue