Plugin Directory

Changeset 2525059


Ignore:
Timestamp:
05/03/2021 02:41:34 AM (5 years ago)
Author:
lrdb
Message:

fixed folder embeding (as github modified code)
fixed broken internal links (removed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • embed-githubin/trunk/githubin.php

    r2483268 r2525059  
    2020        $atts["cachetime"]=1*3600; //(1hora por defecto de cacheo)
    2121   
    22     $myserverip='127.0.0.1'; //if you want to recaching with a cron task avoiding cache time waiting.
     22    $myserverip='1.1.1.1'; //if you want to recaching with a cron task avoiding cache time waiting put here your server ip.
    2323    if( isset($atts["id"]) && !id_outdated_githubin($atts["id"],(int)$atts["cachetime"] ) && $_SERVER['REMOTE_ADDR']!=$myserverip ) //si tiene id lo leemos del contenido cacheado que hemos generado , solo si no es myserverip
    2424    {   //cron recaching if server ip:  */15 * * * * curl https://url
     
    5353        if(isset($atts["border"]) && ( $atts["border"]=="true" || $atts["border"]=="radius" ))
    5454        {
    55             $border_var="border: 1px solid #EAEAEA;";//"true";//"true" si queremos borde.
     55            $border_var="border: 1px solid #363a3d;";//"true";//"true" si queremos borde.
    5656            if($atts["border"]=="radius")
    5757                $border_var.="border-radius: 10px;";
     
    149149                $content_githubin=preg_replace('/<!DOCTYPE[\s\S]*?<article/imu','<article',$content_githubin);
    150150             break;
    151              case 'folder':
    152                 $content_githubin=preg_replace('/<!DOCTYPE[\s\S]*?<div class=\"list files-list\"/imu','<div class="list files-list"',$content_githubin);
    153                 $content_githubin=preg_replace('/<\/div>[\s]*<footer class=/imu','<footer class',$content_githubin);    //quitamos el último </div> ya que empezamos desde el segundo div no desde el primero.
     151             case 'folder': //actualizado 2021/05/02
     152                $content_githubin="<style>.Box-row{display:flex;}</style>".$content_githubin;//añadimos estilo
     153                $content_githubin=preg_replace('/<!DOCTYPE[\s\S]*?<div class=\"js-details-container Details\">/imu','<div>',$content_githubin);
     154                //$content_githubin=preg_replace('<div role=\"columnheader\">[\s\S]*?<\/div>','',$content_githubin); //quitamos columnas absurdas
     155                $content_githubin=preg_replace('/<\/div>[\s]*<\/div>[\s]*<\/div>[\s]*<\/div>[\s]*<\/main>[\s\S]*/imu','',$content_githubin);//desde </div></div></div></div></main> hasta el fin
     156                $content_githubin=preg_replace('/<\/div>[\s]*<\/include-fragment>/imu','</div>',$content_githubin); //quitamos un include-fragment que sobraba
     157                $content_githubin=preg_replace('/<time-ago[\s\S]*?<\/time-ago>/imu','',$content_githubin); //quitamos los time-ago
     158                $content_githubin=preg_replace('/<a data-pjax=[\s\S]*?<\/a>/imu','',$content_githubin); //quitamos los <a data-pjax
     159                $content_githubin=preg_replace('/<a style=\"opacity:0;\"[\s\S]*?<\/a>/imu','',$content_githubin);//quitamos contenido invisible (que ocupa espacio)
    154160             break;
    155161             case 'file':
     
    170176                while( preg_match( '/Updated <relative-time[\s\S]*?<\/relative-time>/imu', $content_githubin) )
    171177                    $content_githubin=preg_replace('/Updated <relative-time[\s\S]*?<\/relative-time>/imu','',$content_githubin);
     178                //quitamos los poll-include-fragment para que no tenga links rotos internamente (2021-05-02)
     179                while( preg_match( '/<poll-include-fragment[\s\S]*?<\/poll-include-fragment>/imu', $content_githubin) )
     180                    $content_githubin=preg_replace('/<poll-include-fragment[\s\S]*?<\/poll-include-fragment>/imu','',$content_githubin);
    172181             break;
    173182         }
     
    288297       
    289298       
    290         $content_githubin='<div style=" '.$style_var.$bgcolor_var.$fgcolor_var.$border_var.'
     299        $content_githubin='<div class="embed_github" style=" '.$style_var.$bgcolor_var.$fgcolor_var.$border_var.'
    291300         padding:8px;">'.$content_githubin.'</div>';
    292301         
Note: See TracChangeset for help on using the changeset viewer.