Permalink
Browse files

Begin using webpack

  • Loading branch information...
r04r committed Sep 3, 2016
1 parent c44ba1c commit 28d7ff3ea7a56d22f9ad8cbcd533a5ac44228ea6
Showing with 489 additions and 178 deletions.
  1. +1 −0 .babelrc
  2. +5 −1 .gitignore
  3. +2 −1 includes/header.php
  4. +22 −68 includes/template.php
  5. +21 −29 javascript/extras.js
  6. +82 −53 javascript/main.js
  7. +1 −0 javascript/mobile.js
  8. +241 −0 javascript/shortcut.js
  9. +29 −0 package.json
  10. +9 −26 post.php
  11. +76 −0 webpack.config.js
View
@@ -0,0 +1 @@
{ "presets": [ "es2015" ] }
View
@@ -7,4 +7,8 @@ db.log
/composer.phar
/phpunit.phar
/vendor
/.php_cs.cache
/.php_cs.cache
/bin
/node_modules/
/includes/stats.json
*.tmp
View
@@ -44,6 +44,7 @@ function ipCIDRCheck($IP, $CIDR)
}
$_start_time = microtime(); //Prepare our neat xx seconds to load thingy at the bottom of the page.
$assetFiles = json_decode(file_get_contents(dirname(__FILE__) . '/stats.json'));
require_once 'vendor/autoload.php';
require_once 'includes/config.php';
require_once 'includes/database.class.php';
@@ -277,7 +278,7 @@ function error_handler($errno, $errstr, $errfile, $errline)
return;
}
if ($errno == E_NOTICE || $errno == E_USER_NOTICE) {
return; // Just a notice. Feh.
return; // Just a notice. Feh.
}
switch ($errno) {
case E_WARNING:
View
@@ -31,44 +31,24 @@
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<meta name="robots" content="noarchive" />
<?php if (MOBILE_MODE) {
?><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /><?php
?><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /><?php
} ?>
<meta name="description" content="Minichan; annoyingly elitist." />
<meta name="keywords" content="minichan, bbs, board, anonymous, free, debate, discuss, argue, drama, loldrama, youarenowbrowsingmanually" />
<title><?php echo strip_tags($page_title).''.SITE_TITLE ?></title>
<link rel="icon" type="image/gif" href="<?php echo STATIC_DOMAIN; ?>favicon.gif" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'style/layout.css' ?>?21" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo ($custom_stylesheet) ? htmlspecialchars($custom_stylesheet) : (STATIC_DOMAIN.'style/'.$stylesheet.'.css?3') ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'javascript/highlight-styles/vs.css' ?>" />
<?php if (MOBILE_MODE) {
?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'style/mobile.css' ?>?x1" />
<?php
} ?>
<?php /* <link rel="stylesheet" type="text/css" href="<?php echo STATIC_DOMAIN; ?>style/april.css?13"> */ ?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel="icon" type="image/gif" href="<?php echo STATIC_DOMAIN; ?>favicon.gif?<?php echo $assetFiles->hash ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'bin/main.css?' . $assetFiles->hash ?>" />
<?php if(MOBILE_MODE) { ?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'bin/mobile.css?' . $assetFiles->hash ?>" />
<?php } ?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo ($custom_stylesheet) ? htmlspecialchars($custom_stylesheet) : (STATIC_DOMAIN.'style/'.$stylesheet.'.css?'.$assetFiles->hash) ?>" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo STATIC_DOMAIN.'javascript/highlight-styles/vs.css?'.$assetFiles->hash ?>" />
<script type="text/javascript">var IMGUR_CLIENT_ID = "<?php echo IMGUR_CLIENT_ID; ?>";</script>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN; ?>javascript/main.js?x15"></script>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN; ?>javascript/extras.js?x11"></script>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN; ?>javascript/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<?php if ($administrator && false) {
?><script type="text/javascript" src="<?php echo STATIC_DOMAIN;
?>javascript/scrollBar.js"></script><?php
} ?>
<?php if (MOBILE_MODE && false) {
?><script type="text/javascript" src="<?php echo STATIC_DOMAIN;
?>javascript/textarea.js"></script><?php
} ?>
<?php if (false && $administrator) {
?><script type="text/javascript" src="<?php echo STATIC_DOMAIN;
?>javascript/inlineEdit.js"></script><?php
} ?>
<?php if (false) {
?><script type="text/javascript" src="<?php echo STATIC_DOMAIN;
?>javascript/snowflake.js?5"></script><?php
} ?>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN; ?>javascript/highlight.pack.js"></script>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN.'bin/main.js?' . $assetFiles->hash ?>"></script>
<?php if(MOBILE_MODE) { ?>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN.'bin/mobile.js?' . $assetFiles->hash ?>"></script>
<?php } ?>
<?php
if (BREAK_OUT_FRAME) {
echo "\t";
@@ -83,39 +63,13 @@
echo "</script>\n";
}
if (false) {
?>
<script type="text/javascript" src="<?php echo DOMAIN;
?>javascript/fool.js"></script>
<script>
$(document).ready(function() {
$.fool({
fallingScrollbar: Math.random()>0.9, // Want the scrollbar to fall over?
rick: Math.random()>0.9, // The synonymous Rick Astley video, hidden off-screen
hiddenVideos: Math.random()>0.9, // Show some wonderfully annoying videos
vanishingElements: false, // Hide random elements as they interact
questionTime: Math.random()>0.9, // Sing Spongebob with your browser!
upsideDown: Math.random()>0.9, // Flip the page upside down!
h4xx0r: Math.random()>0.9, // Make the page 100% editable
wonky: Math.random()>0.9, // Make the page a little bit crooked
flash: Math.random()>0.9, // Makes the site flash on and off
crashAndBurn: false, // Runs an endless loop. This will kill your browser!
shutter: false, // Forces a shutter on the screen
unclickable: false, // Makes the page unclickable
});
});
</script>
<?php
}
echo $additional_head;
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php echo GOOGLE_ANALYTICS_ID; ?>']);
_gaq.push(['_setDomainName', '<?php echo GOOGLE_ANALYTICS_DOMAIN; ?>']);
_gaq.push(['_setCustomVar', 1, 'ID', '<?php echo $_SESSION['UID']; ?>', 2]);
_gaq.push(['_setCustomVar', 1, 'ID', '<?php echo $_SESSION['UID']; ?>', 2]);
_gaq.push(['_trackPageview'<?php if ($analytics_track_url) {
echo ", '".str_replace("'", '"', $analytics_track_url)."'";
}?>]);
@@ -141,11 +95,11 @@
echo '>';
if ($administrator && false) {
?>
<script type="text/javascript">
<script type="text/javascript">
var toolbarConfig = {title:"Minichan",link:"http://minichan.org/topic/6296",slogan:"Get all the latest drama you've come to love, direct to your browser",hide:"hideMCToolbar_",slide:true};
document.write("<script type=\"text/javascript\" src=\"/javascript/chrome_toolbar.js?"+Math.random()+"\"></s"+"cript>");
document.write("<script type=\"text/javascript\" src=\"/javascript/chrome_toolbar.js?"+Math.random()+"\"></s"+"cript>");
</script>
<?php
}
@@ -161,7 +115,7 @@
);
?>
<h1 class="top_text" id="logo">
<?php
<?php
if ($administrator || allowed('manage_defcon')) {
if (DEFCON < 5) {
$additional = ' - <a href="'.DOMAIN.'defcon" title="Manage defcon status.">DEFCON</a> '.DEFCON;
@@ -304,10 +258,10 @@ function humanize_bytes($size)
<div style='position: absolute; top: 0; right: 0;'>
<a href='javascript:confirm("Spread the word to your facebook friends? (This will post a link on their walls)")'><img src="//minichan.org/img/spread.png" /></a>
</div>
<?php
<?php
} ?>
<!--
<!--
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1" height="1">
<param name="movie" value="http://breadfish.de/img/breadfish.swf" id="toonURL1"><param name="quality" value="high"><embed src="http://breadfish.de/img/breadfish.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1" height="1" id="toonURL2"></embed></object>
-->
@@ -319,11 +273,11 @@ function humanize_bytes($size)
$(document).ready(function() {
var w = $(window).width();
var h = $(window).height();
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
setInterval(function() {
var elem = $("<div style='width:1px;height:1px;background-color:black;position:fixed;cursor:default'></div>");
elem.css('left', getRandomInt(0, w) + 'px');
View
@@ -1,20 +1,23 @@
import { shortcut } from './shortcut.js';
window.shortcut = shortcut;
$(function() {
var youtubeEmbedHtml = '<div style="display: none; width:560px" class="video wrapper c"><iframe width="560" height="315" src="https://www.youtube.com/embed/{vid}?autoplay=1&start={start}" frameborder="0" allowfullscreen></iframe></div>';
var vimeoEmbedHtml = '<div style="display: none;" class="video wrapper c"><object width="512" height="294"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="https://vimeo.com/moogaloop.swf?clip_id={vid}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;fullscreen=1&amp;autoplay=1" /><embed src="https://vimeo.com/moogaloop.swf?clip_id={vid}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;fullscreen=1&amp;autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="512" height="294"></embed></object></div>';
var vidmeEmbedHtml = '<div style="display: none; width: 640px" class="video wrapper c"><iframe src="https://vid.me/e/{vid}?autoplay=1" width="640" height="360" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen scrolling="no"></iframe></div>';
function transformVideoLink(vid, start, html) {
var $this = $(this);
var $play = $("<a href='#'>[play]</a>");
var $video = $(html.replace(/\{vid\}/g, vid).replace(/\{start\}/g, start));
var active = false;
$play.click(function(e) {
e.preventDefault();
if(active) return;
active = true;
if($video.is(':visible')) {
$play.text('[play]');
$video.slideUp(function() {
@@ -29,11 +32,11 @@ $(function() {
});
}
});
$this.after($play);
$this.after(" ");
}
// This can probably do a lot more effecient...
function getTimeFromYTUrl(elem) {
var parts = elem.search.substring(1).split('&');
@@ -45,26 +48,26 @@ $(function() {
break;
}
}
if(time == null) {
var match = /^#t=([0-9ms]+)/.exec(elem.hash);
if(match) time = match[1];
}
if(time == null) return 0;
if(time.match(/^\d*$/)) return time;
var regexp = /([0-9]+|[a-z]+)/g;
var match = regexp.exec(time);
var actual = 0;
var carry = null;
var weights = {
'd': 86400,
'h': 3600,
'm': 60,
's': 1
};
while(match != null) {
if(!isNaN(match[0])) {
carry = match[0];
@@ -75,13 +78,13 @@ $(function() {
carry = null;
}
}
match = regexp.exec(time);
}
return actual;
}
$("div.body a").each(function() {
var $this = $(this);
if(this.hostname.match(/(www\.)?youtube(-nocookie)?.com/)) {
@@ -115,17 +118,6 @@ $(function() {
});
});
var shortcut={'all_shortcuts':{},'add':function(shortcut_combination,callback,opt){var default_options={'type':'keydown','propagate':false,'disable_in_input':false,'target':document,'keycode':false}
if(!opt)opt=default_options;else{for(var dfo in default_options){if(typeof opt[dfo]=='undefined')opt[dfo]=default_options[dfo];}}
var ele=opt.target;if(typeof opt.target=='string')ele=document.getElementById(opt.target);var ths=this;shortcut_combination=shortcut_combination.toLowerCase();var func=function(e){e=e||window.event;if(opt['disable_in_input']){var element;if(e.target)element=e.target;else if(e.srcElement)element=e.srcElement;if(element.nodeType==3)element=element.parentNode;if(element.tagName=='INPUT'||element.tagName=='TEXTAREA')return;}
if(e.keyCode)code=e.keyCode;else if(e.which)code=e.which;var character=String.fromCharCode(code).toLowerCase();if(code==188)character=",";if(code==190)character=".";var keys=shortcut_combination.split("+");var kp=0;var shift_nums={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"}
var special_keys={'esc':27,'escape':27,'tab':9,'space':32,'return':13,'enter':13,'backspace':8,'scrolllock':145,'scroll_lock':145,'scroll':145,'capslock':20,'caps_lock':20,'caps':20,'numlock':144,'num_lock':144,'num':144,'pause':19,'break':19,'insert':45,'home':36,'delete':46,'end':35,'pageup':33,'page_up':33,'pu':33,'pagedown':34,'page_down':34,'pd':34,'left':37,'up':38,'right':39,'down':40,'f1':112,'f2':113,'f3':114,'f4':115,'f5':116,'f6':117,'f7':118,'f8':119,'f9':120,'f10':121,'f11':122,'f12':123}
var modifiers={shift:{wanted:false,pressed:false},ctrl:{wanted:false,pressed:false},alt:{wanted:false,pressed:false},meta:{wanted:false,pressed:false}};if(e.ctrlKey)modifiers.ctrl.pressed=true;if(e.shiftKey)modifiers.shift.pressed=true;if(e.altKey)modifiers.alt.pressed=true;if(e.metaKey)modifiers.meta.pressed=true;for(var i=0;k=keys[i],i<keys.length;i++){if(k=='ctrl'||k=='control'){kp++;modifiers.ctrl.wanted=true;}else if(k=='shift'){kp++;modifiers.shift.wanted=true;}else if(k=='alt'){kp++;modifiers.alt.wanted=true;}else if(k=='meta'){kp++;modifiers.meta.wanted=true;}else if(k.length>1){if(special_keys[k]==code)kp++;}else if(opt['keycode']){if(opt['keycode']==code)kp++;}else{if(character==k)kp++;else{if(shift_nums[character]&&e.shiftKey){character=shift_nums[character];if(character==k)kp++;}}}}
if(kp==keys.length&&modifiers.ctrl.pressed==modifiers.ctrl.wanted&&modifiers.shift.pressed==modifiers.shift.wanted&&modifiers.alt.pressed==modifiers.alt.wanted&&modifiers.meta.pressed==modifiers.meta.wanted){callback(e);if(!opt['propagate']){e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation){e.stopPropagation();e.preventDefault();}
return false;}}}
this.all_shortcuts[shortcut_combination]={'callback':func,'target':ele,'event':opt['type']};if(ele.addEventListener)ele.addEventListener(opt['type'],func,false);else if(ele.attachEvent)ele.attachEvent('on'+opt['type'],func);else ele['on'+opt['type']]=func;},'remove':function(shortcut_combination){shortcut_combination=shortcut_combination.toLowerCase();var binding=this.all_shortcuts[shortcut_combination];delete(this.all_shortcuts[shortcut_combination])
if(!binding)return;var type=binding['event'];var ele=binding['target'];var callback=binding['callback'];if(ele.detachEvent)ele.detachEvent('on'+type,callback);else if(ele.removeEventListener)ele.removeEventListener(type,callback,false);else ele['on'+type]=false;}}
$(function() {
shortcut.add("Ctrl+B", function() {
window.location = "/bumps";
@@ -138,10 +130,10 @@ $(function() {
function createMarkupEditor() {
var $this = $(this);
var $bar = $("<span />");
$this.before($bar);
function createButton(html, cb) {
var $elem = $("<h3 />");
$elem.css('display', 'inline-block');
@@ -156,7 +148,7 @@ function createMarkupEditor() {
});
$bar.append($elem);
}
function createBB(html, tag) {
createButton('['+html+']', function() {
wrapText($this, '['+tag+']', '[/'+tag+']');
@@ -170,7 +162,7 @@ function createMarkupEditor() {
target: $this[0]
});
}
createBB('<strong>b</strong>', 'b');
createBB('<em>i</em>', 'i');
createBB('<u>u</u>', 'u');
@@ -221,4 +213,4 @@ function setSelectionRange(input, selectionStart, selectionEnd) {
range.moveStart('character', selectionStart);
range.select();
}
}
}
Oops, something went wrong.

0 comments on commit 28d7ff3

Please sign in to comment.