bigwhoop / trumpet
此包已被废弃,不再维护。未建议替代包。
PHP演示工具
0.1.4
2015-05-13 16:49 UTC
Requires
- php: >=5.6
- intervention/image: ~2.2
- michelf/php-markdown: ~1.5.0
- mnapoli/php-di: ~4.0
- monolog/monolog: ~1.13
- nikic/php-parser: ~1.3
- symfony/yaml: ~2.6
- voodoophp/handlebars: ~2
Requires (Dev)
- phpunit/phpunit: ~4
README
PHP开发者的演示工具。
快速指南
composer global require bigwhoop/trumpet
mkdir ~/Presentations && cd ~/Presentations
trumpet
功能
- 在浏览器中运行
- 使用yaml作为元数据
- 使用markdown(额外)作为幻灯片
- 支持交互元素,如
- 运行示例代码
- 嵌入文本文件(HTML、CSS等)
- 动态嵌入PHP代码(整个文件、类、方法、函数、行)
- 自动调整大小、裁剪等嵌入图片
- 来自维基百科的总结引用
- ...
- 可定制主题(使用Twig)
安装
composer global require bigwhoop/trumpet
确保~/.composer/vendor/bin
文件夹包含在您的PATH
环境变量中。这篇博客文章应该会帮到您。
使用
默认情况下,trumpet使用PHP内置的web服务器。只需运行
trumpet
来启动它。您应该会看到类似这样的内容
λ trumpet
2015-05-02 22:25:48 [INFO] Starting webserver on localhost:8075 ...
所以打开您的浏览器,前往https://:8075/。
trumpet总是使用启动它的目录来定位演示文稿。
工作区
建议为所有演示文稿创建一个新文件夹。
mkdir ~/Presentations
cd ~/Presentations
主题
您可以下载或创建自定义主题。trumpet将在当前工作目录中查找.theme
目录。
演示文稿
trumpet演示文稿存储在扩展名为.trumpet
的文件中。以下是一个示例
title: Our test presentation
subtitle: An optional sub-title
date: 2015-05-20
authors:
- Max Microwave, Some Company Lts., @themax
- name: Freddy Frypan
email: freddy@example.org
twitter: freddy
company: Another Company
website: www.example.org
skype: freedy.frypan
slides: |
# This is a title, it's on its own page
## This is a subtitle, it will create a new slide
This is some example text.
### And this is a sub-subtitle
And some more text. Yay.
## A new slide?
Yep, like I told you. Titles and subtitles always create a new slide.
- These are
- bullet points.
幻灯片
- 幻灯片使用Markdown(额外)编写。
- 一级标题将单独显示在幻灯片上。
- 二级标题将强制创建新幻灯片。
命令
在您的slides
标记中,可以使用命令使演示文稿动态化。
代码命令
将PHP代码包含到您的幻灯片中。也许在未来,将支持其他编程语言。
假设我们有一个名为Number.php
的文件,位于~/presentations/Number.php
<?php
namespace My\Library;
class Number
{
private $value = 0;
public function __construct($value) { $this->value = $value; }
public function getValue() { return $this->value; }
public function add(Number $n)
{
return new Number($this->value + $n->getValue());
}
}
$n1 = new Number(5);
$n2 = $n1->add(new Number(3));
echo "5 + 3 = {$n2->getValue()}";
function add($a, $b) {
return $a + $b;
}
文件
命令
!code Number.php
输出
<?php
namespace My\Library;
class Number
{
private $value = 0;
public function __construct($value) { $this->value = $value; }
public function getValue() { return $this->value; }
public function add(Number $n)
{
return new Number($this->value + $n->getValue());
}
}
$n1 = new Number(5);
$n2 = $n1->add(new Number(3));
echo "5 + 3 = {$n2->getValue()}";
function add($a, $b) {
return $a + $b;
}
类
命令
!code Number.php class My\Library\Number
输出
class Number
{
private $value = 0;
public function __construct($value)
{
$this->value = $value;
}
public function getValue()
{
return $this->value;
}
public function add(Number $n)
{
return new Number($this->value + $n->getValue());
}
}
方法
命令
!code Number.php method My\Library\Number add
输出
public function add(\My\Library\Number $n)
{
return new Number($this->value + $n->getValue());
}
函数
命令
!code Number.php function My\Library\add
输出
function add($a, $b)
{
return $a + $b;
}
行
命令
!code Number.php line 2
!code Number.php line 18-20
输出
namespace My\Library;
$n1 = new Number(5);
$n2 = $n1->add(new Number(3));
echo "5 + 3 = {$n2->getValue()}";
文件摘要
命令
!code Number.php abstract
输出
CLASSES (1)
My\Library\Number
__construct()
getValue()
add()
FUNCTIONS (1)
My\Library\add
执行命令
执行PHP文件。
命令
# See "Code Command" for the contents of the Number.php file
!exec Number.php
输出
5 + 3 = 8
图片命令
在幻灯片中包含图片,并可选地调整大小。
!image image.jpg 500x400 # Resizes image while keeping its ratio
!image image.jpg 500x0 # Resizes image while keeping its ratio so that the width is 500px
!image image.jpg 0x400 # Resizes image while keeping its ratio so that the height is 400px
!image image.jpg 0x400 # Resizes image while keeping its ratio so that the height is 400px
!image image.jpg 500x400 stretch
!image image.jpg 500x400 fit
!image image.jpg 500x400 crop
包含命令
将文件内容一对一复制到幻灯片中。这允许你将示例代码(CSS、JS)或单个幻灯片移动到单独的文件中。
假设我们有一个这样的slides.md
文件
## 2nd Slide
This file was included into my presentation.
而在我们的.trumpet
文件中,我们会这样写
slides: |
# Hello
!include slides.md
结果将与以下内容等效
slides: |
# Hello
## 2nd Slide
This file was included into my presentation.
行模式
在那里你也可以只包含某些行的范围。
!include slides.md line 5 # Only the 5th line
!include slides.md line 9-12 # Lines 9 - 12
维基百科摘要
在引用块中显示给定主题的摘要。
命令
!wiki TOPIC [NUM_SENTEMCES]
示例
!wiki "Theme (computing)"
输出
> In computing, a theme is a preset package containing graphical appearance details. A theme
> usually comprises a set of shapes and colors for the graphical control elements, the window
> decoration and the window. Themes are used to customize the look and feel of a piece of
> computer software or of an operating system.