Skip to content

Commit

Permalink
Merge branch 'feature/style'
Browse files Browse the repository at this point in the history
  • Loading branch information
makotokw committed Dec 26, 2016
2 parents 19d8998 + 222a563 commit b25429d
Show file tree
Hide file tree
Showing 24 changed files with 1,704 additions and 1,143 deletions.
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "makotokw/wp-gfm",
"authors": [
{
"name": "Makoto Kawasaki",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3",
"michelf/php-markdown": "1.6.*@dev"
},
"autoload": {
"psr-0": {
"": "src/"
}
}
"name": "makotokw/wp-gfm",
"license": "MIT",
"authors": [
{
"name": "Makoto Kawasaki",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3",
"michelf/php-markdown": "1.7.*@dev"
},
"autoload": {
"psr-0": {
"Gfm\\Markdown\\": "src/"
}
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 36 additions & 5 deletions css/markdown.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/* line 2, ../sass/_typography.scss */
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4, .markdown-content h5, .markdown-content h6 {
clear: none;
outline: none;
}
/* line 7, ../sass/_typography.scss */
.markdown-content .footnotes hr {
margin-bottom: 4px;
}
/* line 10, ../sass/_typography.scss */
.markdown-content .footnotes ol {
padding: 0;
margin: 0 0 0 20px;
font-size: .8em;
}

/* line 1, ../sass/_toc.scss */
.wp-gfm-toc-content {
background-color: #fefefe;
border: 1px solid #ddd;
Expand All @@ -22,67 +26,94 @@
display: table;
}

/* line 13, ../sass/_toc.scss */
.wp-gfm-toc-content > ul {
margin-top: 15px;
}
/* line 16, ../sass/_toc.scss */
.wp-gfm-toc-content ul {
padding: 0;
margin: 0 0 0 20px;
}
/* line 20, ../sass/_toc.scss */
.wp-gfm-toc-content li {
margin: 0;
font-size: 12px;
}
/* line 23, ../sass/_toc.scss */
.wp-gfm-toc-content li li {
margin-left: 1.5em;
font-size: 10px;
}
/* line 28, ../sass/_toc.scss */
.wp-gfm-toc-content a {
color: #333;
text-decoration: none;
}
/* line 31, ../sass/_toc.scss */
.wp-gfm-toc-content a:hover {
text-decoration: underline;
}
/* line 35, ../sass/_toc.scss */
.wp-gfm-toc-content.right {
float: right;
margin-left: 12px;
margin-right: 0;
width: auto;
}
/* line 42, ../sass/_toc.scss */
.wp-gfm-toc-content.left {
float: left;
margin-right: 12px;
margin-left: 0;
width: auto;
}

.wp-gfm-ad {
/* line 1, ../sass/_footer.scss */
.wp-gfm-footer {
margin: 5px 0;
clear: both;
}

/* line 5, ../sass/_footer.scss */
.wp-gfm-ad {
display: inline;
float: right;
font-size: 12px;
text-align: right;
clear: both;
}
/* line 10, ../sass/_footer.scss */
.wp-gfm-ad .wp-gfm-powered-by {
color: #999;
color: #767676;
}
/* line 13, ../sass/_footer.scss */
.wp-gfm-ad img {
margin: 0;
}
/* line 16, ../sass/_footer.scss */
.wp-gfm-ad a {
font-weight: bold;
}

/* line 1, ../sass/_embed.scss */
.markdown-file {
position: relative;
border: 1px solid #dedede;
border-radius: 3px;
margin: 1em 0;
}
/* line 7, ../sass/_embed.scss */
.markdown-file .markdown-body {
padding: 20px;
}
/* line 11, ../sass/_embed.scss */
.markdown-file .markdown-meta {
clear: both;
display: block;
padding: 9px 10px 10px;
margin: 0;
font-size: 14px;
line-height: 17px;
background-color: #f5f5f5;
border: 1px solid #d8d8d8;
border-bottom: 0;
border-top: 1px solid #dedede;
}
36 changes: 20 additions & 16 deletions markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
License: MIT
*/

class WP_GFM
{
class WP_GFM {
const NAME = 'WP_GFM';
const VERSION = '0.8';
const DEFAULT_RENDER_URL = 'https://api.github.com/markdown/raw';

// google-code-prettify: https://code.google.com/p/google-code-prettify/
const FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY = '<pre class="prettyprint lang-{{lang}}" title="{{title}}">{{codeblock}}</pre>';

public $agent = '';
public $url = '';
public $agent = '';
public $url = '';
public $has_converter = false;
public $gfm_options = array();
public $gfm_options = array();
public $ad_html = '';

static function get_instance() {
static $plugin = null;
Expand Down Expand Up @@ -53,6 +53,8 @@ private function __construct() {
} else {
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_styles' ) );
}

$this->ad_html = '<div class="wp-gfm-ad"><span class="wp-gfm-powered-by">Markdown with by <img alt="❤" src="https://s.w.org/images/core/emoji/72x72/2764.png" width="10" height="10" scale="0"> <a href="https://github.com/makotokw/wp-gfm" target="_blank">wp-gfm</a></span></div>';
}

function wp_enqueue_styles() {
Expand Down Expand Up @@ -237,6 +239,12 @@ function shortcode_markdown( /** @noinspection PhpUnusedParameterInspection */ $
return $content;
}

/**
* @param $use_gfm
* @param $atts
* @param $content
* @return string
*/
function shortcode_embed( $use_gfm, $atts, /** @noinspection PhpUnusedParameterInspection */ $content ) {
/**
* @var string $url
Expand All @@ -260,15 +268,10 @@ function shortcode_embed( $use_gfm, $atts, /** @noinspection PhpUnusedParameterI
$url = '<a href="' . $url . '">' . $url . '</a>';
}

if ( $use_gfm ) {
return '<div class="markdown-file">'
. $this->shortcode_gfm( $atts, $body )
. '<div <div class="markdown-meta">' . $url . '</div></div>';
} else {
return '<div class="markdown-file">'
. $this->shortcode_markdown( $atts, $body )
. '<div <div class="markdown-meta">' . $url . '</div></div>';
}
return '<div class="markdown-file">'
. ($use_gfm ? $this->shortcode_gfm( $atts, $body ) : $this->shortcode_markdown( $atts, $body ))
. '<div class="markdown-meta">' . $url . $this->ad_html . '</div>'
. '</div>';
}
return '';
}
Expand Down Expand Up @@ -302,7 +305,7 @@ function the_content( $content ) {

function the_content_ad( $context ) {
if ( strpos( $context, '<div class="markdown-body markdown-content">' ) !== false ) {
return $context . '<div class="wp-gfm-ad"><span class="wp-gfm-powered-by">Markdown with by <a href="https://github.com/makotokw/wp-gfm" target="_blank">wp-gfm</a></span></div>';
return $context . '<div class="wp-gfm-footer">' . $this->ad_html . '</div>';
}
return $context;
}
Expand Down Expand Up @@ -357,7 +360,8 @@ function admin_quicktags() {
<script type="text/javascript">
(function ($) {
if (typeof(QTags) != 'undefined') {
$.each(['markdown', 'gfm'], function (index, c) {
var ids = ['markdown', 'gfm'];
$.each(ids, function (index, c) {
QTags.addButton(c, '[' + c + ']', '[' + c + ']', '[/' + c + ']');
});
}
Expand Down
8 changes: 4 additions & 4 deletions sass/_embed.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.markdown-file {
position: relative;
border: 1px solid #dedede;
border: 1px solid $border-color;
border-radius: 3px;
margin: 1em 0;

Expand All @@ -9,13 +9,13 @@
}

.markdown-meta {
clear: both;
display: block;
padding: 9px 10px 10px;
margin: 0;
font-size: 14px;
line-height: 17px;
background-color: #f5f5f5;
border: 1px solid #d8d8d8;
border-bottom: 0;
background-color: $meta-bg-color;
border-top: 1px solid $border-color;
}
}
17 changes: 13 additions & 4 deletions sass/_footer.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
.wp-gfm-ad {
.wp-gfm-footer {
margin: 5px 0;
clear: both;
}
.wp-gfm-ad {
display: inline;
float: right;
font-size: 12px;
text-align: right;
clear: both;

.wp-gfm-powered-by {
color: #999;
color: #767676;
}
img {
margin: 0;
}
a {
font-weight: bold;
}
}
3 changes: 3 additions & 0 deletions sass/_vars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$border-color: #dedede;
$bg-color: #fff;
$meta-bg-color: #f5f5f5;
1 change: 1 addition & 0 deletions sass/markdown.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import 'vars';
@import 'typography';
@import 'toc';
@import 'footer';
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';
require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit9facfe8654e0f473520ec5a6fb803482::getLoader();
12 changes: 7 additions & 5 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class ClassLoader

private $useIncludePath = false;
private $classMap = array();

private $classMapAuthoritative = false;
private $missingClasses = array();

public function getPrefixes()
{
Expand Down Expand Up @@ -322,20 +322,20 @@ public function findFile($class)
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative) {
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}

$file = $this->findFileWithExtension($class, '.php');

// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}

if ($file === null) {
if (false === $file) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
$this->missingClasses[$class] = true;
}

return $file;
Expand Down Expand Up @@ -399,6 +399,8 @@ private function findFileWithExtension($class, $ext)
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}

return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Copyright (c) 2015 Nils Adermann, Jordi Boggiano
Copyright (c) 2016 Nils Adermann, Jordi Boggiano

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit b25429d

Please sign in to comment.