visuddhinanda 2 yıl önce
ebeveyn
işleme
fd3cede667

+ 31 - 0
app/Tools/Markdown.php

@@ -0,0 +1,31 @@
+<?php
+namespace App\Tools;
+use Illuminate\Support\Str;
+
+class Markdown
+{
+    public static function render($text){
+        return Markdown::marked($text);
+    }
+    public static function marked($text){
+            $host = env('MORUS_RPC_SERVER');
+            $client = new \Mint\Morus\V1\MarkdownClient($host, [
+                'credentials' => \Grpc\ChannelCredentials::createInsecure(),
+            ]);
+            $request = new \Mint\Morus\V1\MarkdownToHtmlRequest();
+            $request->setPayload($text);
+            $request->setSanitize(true);
+            list($response, $status) = $client->ToHtml($request)->wait();
+            if ($status->code !== \Grpc\STATUS_OK) {
+                return "ERROR: " . $status->code . ", " . $status->details;
+            }
+            return $response->getPayload();
+    }
+    public static function parsedown($text){
+        $Parsedown = new \Parsedown();
+        return $Parsedown->text($text);
+    }
+    public static function strdown($text){
+        return Str::markdown($text);
+    }
+}

BIN
grpc/GPBMetadata/Morus.php


+ 34 - 0
grpc/Mint/Morus/V1/MarkdownClient.php

@@ -0,0 +1,34 @@
+<?php
+// GENERATED CODE -- DO NOT EDIT!
+
+namespace Mint\Morus\V1;
+
+/**
+ * ----------------------------------------------------------------------------
+ */
+class MarkdownClient extends \Grpc\BaseStub {
+
+    /**
+     * @param string $hostname hostname
+     * @param array $opts channel options
+     * @param \Grpc\Channel $channel (optional) re-use channel object
+     */
+    public function __construct($hostname, $opts, $channel = null) {
+        parent::__construct($hostname, $opts, $channel);
+    }
+
+    /**
+     * @param \Mint\Morus\V1\MarkdownToHtmlRequest $argument input argument
+     * @param array $metadata metadata
+     * @param array $options call options
+     * @return \Grpc\UnaryCall
+     */
+    public function ToHtml(\Mint\Morus\V1\MarkdownToHtmlRequest $argument,
+      $metadata = [], $options = []) {
+        return $this->_simpleRequest('/mint.morus.v1.Markdown/ToHtml',
+        $argument,
+        ['\Mint\Morus\V1\MarkdownToHtmlResponse', 'decode'],
+        $metadata, $options);
+    }
+
+}

+ 85 - 0
grpc/Mint/Morus/V1/MarkdownToHtmlRequest.php

@@ -0,0 +1,85 @@
+<?php
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: morus.proto
+
+namespace Mint\Morus\V1;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>mint.morus.v1.MarkdownToHtmlRequest</code>
+ */
+class MarkdownToHtmlRequest extends \Google\Protobuf\Internal\Message
+{
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     */
+    protected $payload = '';
+    /**
+     * Generated from protobuf field <code>bool sanitize = 2;</code>
+     */
+    protected $sanitize = false;
+
+    /**
+     * Constructor.
+     *
+     * @param array $data {
+     *     Optional. Data for populating the Message object.
+     *
+     *     @type string $payload
+     *     @type bool $sanitize
+     * }
+     */
+    public function __construct($data = NULL) {
+        \GPBMetadata\Morus::initOnce();
+        parent::__construct($data);
+    }
+
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     * @return string
+     */
+    public function getPayload()
+    {
+        return $this->payload;
+    }
+
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     * @param string $var
+     * @return $this
+     */
+    public function setPayload($var)
+    {
+        GPBUtil::checkString($var, True);
+        $this->payload = $var;
+
+        return $this;
+    }
+
+    /**
+     * Generated from protobuf field <code>bool sanitize = 2;</code>
+     * @return bool
+     */
+    public function getSanitize()
+    {
+        return $this->sanitize;
+    }
+
+    /**
+     * Generated from protobuf field <code>bool sanitize = 2;</code>
+     * @param bool $var
+     * @return $this
+     */
+    public function setSanitize($var)
+    {
+        GPBUtil::checkBool($var);
+        $this->sanitize = $var;
+
+        return $this;
+    }
+
+}
+

+ 58 - 0
grpc/Mint/Morus/V1/MarkdownToHtmlResponse.php

@@ -0,0 +1,58 @@
+<?php
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: morus.proto
+
+namespace Mint\Morus\V1;
+
+use Google\Protobuf\Internal\GPBType;
+use Google\Protobuf\Internal\RepeatedField;
+use Google\Protobuf\Internal\GPBUtil;
+
+/**
+ * Generated from protobuf message <code>mint.morus.v1.MarkdownToHtmlResponse</code>
+ */
+class MarkdownToHtmlResponse extends \Google\Protobuf\Internal\Message
+{
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     */
+    protected $payload = '';
+
+    /**
+     * Constructor.
+     *
+     * @param array $data {
+     *     Optional. Data for populating the Message object.
+     *
+     *     @type string $payload
+     * }
+     */
+    public function __construct($data = NULL) {
+        \GPBMetadata\Morus::initOnce();
+        parent::__construct($data);
+    }
+
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     * @return string
+     */
+    public function getPayload()
+    {
+        return $this->payload;
+    }
+
+    /**
+     * Generated from protobuf field <code>string payload = 1;</code>
+     * @param string $var
+     * @return $this
+     */
+    public function setPayload($var)
+    {
+        GPBUtil::checkString($var, True);
+        $this->payload = $var;
+
+        return $this;
+    }
+
+}
+