Advertisement
metalx1000

Comic to HTML convert script v2

Mar 10th, 2015
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.81 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #title           :Comic to HTML
  4. #description     :Converts Comic Books to a very simple HTML format
  5. #author            :Kris Occhipinti
  6. #site            :http://filmsbykris.com
  7. #date            :Tue Jun  3 12:23:23 EDT 2014
  8. #version         :3    
  9. #usage             :comic2html file.cbr
  10. #notes           :To convert a bunch of files 'for i in *;do comic2html "$i";done'
  11. #License :GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  12.  
  13. dir="$PWD/html/"
  14. d="$(echo "$1"|cut -d\. -f1)"
  15. output_dir="$dir$d"
  16. mkdir -p "$output_dir"
  17.  
  18. if [[ "$1" == *.cbr ]]
  19. then
  20.         cp "$@" "$output_dir/x.rar"
  21.         unrar e "$output_dir/x.rar" "$output_dir/"
  22.          rm "$output_dir/x.rar"
  23. else
  24.         cp "$@" "$output_dir/x.zip"
  25.         unzip "$output_dir/x.zip" -d "$output_dir/"
  26.         rm "$output_dir/x.zip"
  27. fi
  28.  
  29. ls "$output_dir" > "$output_dir/list.php"
  30. sed -i '/jpg/!d' "$output_dir/list.php"
  31.  
  32. cat << EOF > "$output_dir/index.html"
  33. <html>
  34. <head>
  35.   <style>
  36.     #header {
  37.       position: fixed;
  38.       background-color: white;
  39.       width: 100%;
  40.     }
  41.  
  42.     #content {
  43.       margin-top: 10px;
  44.       width: 100%;
  45.     }
  46.    
  47.     img{
  48.       width: 100%;
  49.     }
  50.  
  51.     *{
  52.       margin: 0;
  53.       padding: 0;
  54.     }
  55.     button{
  56.       margin: 0;
  57.       padding: 0;
  58.       display: inline-block;
  59.       height: 50px;
  60.       width: 49%;
  61.       white-space: nowrap;
  62.     }
  63.   </style>
  64.   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  65.   <script>
  66.     var pages=[];
  67.  
  68.     \$(document).ready(function(){
  69.      \$.get("list.php", function(data) {
  70.         var list = data.split('\n');
  71.         for(var i=0;i<list.length;i++){
  72.           pages.push(list[i]);
  73.         };
  74.         \$("#main_img").attr("src", pages[0]);
  75.         \$("#load_img").attr("src", pages[1]);
  76.         \$("#page_total").html(list.length);
  77.  
  78.      });
  79.  
  80.  
  81.       \$(".change").click(function(){
  82.         var x = +\$("#page").val();
  83.         var val=\$(this).attr("val");
  84.         x+=+val;
  85.         \$("#main_img").attr("src", pages[x]);
  86.         \$("#load_img").attr("src", pages[x+1]);
  87.         window.scrollTo(0,0);
  88.         \$("#page").val(x);
  89.       });
  90.  
  91.         \$("#page").change(function(){
  92.             var x=\$("#page").val();
  93.             console.log("Jump to page #" + x);
  94.             \$("#main_img").attr("src", pages[x]);
  95.             \$("#load_img").attr("src", pages[x+1]);
  96.         });
  97.  
  98.     });
  99.  
  100.   </script>
  101.  
  102. <body>
  103.   <div id="header">
  104.     <a>Page #<input type="number" id="page" value="0"></a>
  105.     <a>--Number of Pages: <span id="page_total"></span></a>
  106.   </div>
  107.   <br>
  108.   <div id="content">
  109.     <img id="main_img"><br>
  110.     <img id="load_img" style="display:none">
  111.     <button class="change" val="-1" >Prev</button>
  112.     <button class="change" val="1" >Next</button>
  113.   </div>
  114. </body>
  115. </html>
  116.  
  117. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement