Dashboard Temp Share Shortlinks Frames API

HTMLify

Read Repo Generator
Views: 24 | Author: devwajahat
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>README Generator</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.js"></script>
</head>
<body class="bg-gray-50 text-gray-900 p-4 md:p-10 font-sans">
    <div class="max-w-7xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-8">
        <div class="bg-white p-6 rounded-lg shadow-md space-y-6">
            <h1 class="text-2xl font-bold border-b pb-2">README Builder</h1>
            
            <div class="space-y-4">
                <div>
                    <label class="block text-sm font-medium">Project Title</label>
                    <input type="text" id="r-title" class="mt-1 block w-full border border-gray-300 rounded-md p-2 focus:ring-blue-500 focus:border-blue-500">
                </div>
                <div>
                    <label class="block text-sm font-medium">Subtitle / Catchphrase</label>
                    <input type="text" id="r-subtitle" class="mt-1 block w-full border border-gray-300 rounded-md p-2 focus:ring-blue-500 focus:border-blue-500">
                </div>
                <div class="flex items-center">
                    <input type="checkbox" id="r-toc" class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
                    <label class="ml-2 text-sm font-medium">Include Table of Contents</label>
                </div>
            </div>

            <div>
                <label class="block text-sm font-medium mb-1">Introduction Paragraph</label>
                <div id="r-intro"></div>
            </div>

            <div class="space-y-4">
                <div>
                    <label class="block text-sm font-medium">Project Screenshot URL</label>
                    <input type="text" id="r-screenshot" class="mt-1 block w-full border border-gray-300 rounded-md p-2">
                </div>
                <div>
                    <label class="block text-sm font-medium">YouTube Video URL</label>
                    <input type="text" id="r-youtube" class="mt-1 block w-full border border-gray-300 rounded-md p-2">
                </div>
                <div>
                    <label class="block text-sm font-medium">Tech Stack (comma separated, e.g. react, nodejs, laravel)</label>
                    <input type="text" id="r-tech" class="mt-1 block w-full border border-gray-300 rounded-md p-2">
                </div>
            </div>

            <div class="space-y-4">
                <div>
                    <label class="block text-sm font-medium">User Instructions</label>
                    <textarea id="r-user-inst" rows="3" class="mt-1 block w-full border border-gray-300 rounded-md p-2"></textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium">Getting Started / Dev Instructions</label>
                    <textarea id="r-dev-inst" rows="3" class="mt-1 block w-full border border-gray-300 rounded-md p-2"></textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium">Contributor Expectations</label>
                    <textarea id="r-contrib" rows="3" class="mt-1 block w-full border border-gray-300 rounded-md p-2"></textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium">Known Issues</label>
                    <textarea id="r-issues" rows="3" class="mt-1 block w-full border border-gray-300 rounded-md p-2"></textarea>
                </div>
                <div>
                    <label class="block text-sm font-medium">Support (Buy Me a Coffee Username)</label>
                    <input type="text" id="r-coffee" class="mt-1 block w-full border border-gray-300 rounded-md p-2">
                </div>
            </div>

            <button id="generate-btn" class="w-full bg-blue-600 text-white font-bold py-3 px-4 rounded-md hover:bg-blue-700 transition">
                Generate README.md
            </button>
        </div>

        <div class="bg-gray-900 rounded-lg shadow-md p-6 flex flex-col">
            <h2 class="text-xl font-bold text-white mb-4">Generated Markdown</h2>
            <textarea id="output-markdown" readonly class="w-full flex-grow bg-gray-800 text-green-400 font-mono text-sm p-4 rounded border border-gray-700 focus:outline-none focus:ring-1 focus:ring-green-500"></textarea>
            <button id="copy-btn" class="mt-4 bg-gray-700 text-white font-bold py-2 px-4 rounded hover:bg-gray-600 transition">
                Copy to Clipboard
            </button>
        </div>
    </div>

    <script>
        $(document).ready(function() {
            $('#r-intro').summernote({
                height: 150,
                toolbar: [
                    ['style', ['style']],
                    ['font', ['bold', 'underline', 'clear']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['insert', ['link']],
                    ['view', ['codeview']]
                ]
            });

            function extractYouTubeID(url) {
                let match = url.match(/(?:youtu\.be\/|youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/);
                return match ? match[1] : null;
            }

            $('#generate-btn').click(function() {
                let md = "";
                let title = $('#r-title').val().trim();
                let subtitle = $('#r-subtitle').val().trim();
                let useToc = $('#r-toc').is(':checked');
                let introHtml = $('#r-intro').summernote('isEmpty') ? "" : $('#r-intro').summernote('code');
                let screenshot = $('#r-screenshot').val().trim();
                let youtube = $('#r-youtube').val().trim();
                let tech = $('#r-tech').val().trim();
                let userInst = $('#r-user-inst').val().trim();
                let devInst = $('#r-dev-inst').val().trim();
                let contrib = $('#r-contrib').val().trim();
                let issues = $('#r-issues').val().trim();
                let coffee = $('#r-coffee').val().trim();

                if (title) md += `# ${title}\n\n`;
                if (subtitle) md += `> ${subtitle}\n\n`;

                let sections = [];
                if (introHtml && introHtml !== '<p><br></p>') sections.push('Introduction');
                if (screenshot || youtube) sections.push('Visuals');
                if (tech) sections.push('Tech Stack');
                if (userInst) sections.push('User Instructions');
                if (devInst) sections.push('Getting Started');
                if (contrib) sections.push('Contributor Expectations');
                if (issues) sections.push('Known Issues');
                if (coffee) sections.push('Support');

                if (useToc && sections.length > 0) {
                    md += `## Table of Contents\n\n`;
                    sections.forEach(function(sec) {
                        let link = sec.toLowerCase().replace(/\s+/g, '-');
                        md += `- [${sec}](#${link})\n`;
                    });
                    md += `\n`;
                }

                if (introHtml && introHtml !== '<p><br></p>') {
                    md += `## Introduction\n\n${introHtml}\n\n`;
                }

                if (screenshot || youtube) {
                    md += `## Visuals\n\n`;
                    if (screenshot) {
                        md += `![Project Screenshot](${screenshot})\n\n`;
                    }
                    if (youtube) {
                        let ytID = extractYouTubeID(youtube);
                        if (ytID) {
                            md += `[![YouTube Video](https://img.youtube.com/vi/${ytID}/0.jpg)](${youtube})\n\n`;
                        } else {
                            md += `[Watch YouTube Video](${youtube})\n\n`;
                        }
                    }
                }

                if (tech) {
                    md += `## Tech Stack\n\n`;
                    let techArr = tech.split(',');
                    techArr.forEach(function(t) {
                        let cleanTech = t.trim();
                        if (cleanTech) {
                            let encodedTech = encodeURIComponent(cleanTech);
                            md += `![${cleanTech}](https://img.shields.io/badge/-${encodedTech}-blue?style=flat-square&logo=${encodedTech.toLowerCase()}&logoColor=white) `;
                        }
                    });
                    md += `\n\n`;
                }

                if (userInst) {
                    md += `## User Instructions\n\n${userInst}\n\n`;
                }

                if (devInst) {
                    md += `## Getting Started\n\n${devInst}\n\n`;
                }

                if (contrib) {
                    md += `## Contributor Expectations\n\n${contrib}\n\n`;
                }

                if (issues) {
                    md += `## Known Issues\n\n${issues}\n\n`;
                }

                if (coffee) {
                    md += `## Support\n\n[![Buy Me A Coffee](https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png)](https://www.buymeacoffee.com/${coffee})\n\n`;
                }

                $('#output-markdown').val(md);
            });

            $('#copy-btn').click(function() {
                let outText = $('#output-markdown').val();
                if (outText) {
                    navigator.clipboard.writeText(outText).then(function() {
                        let btn = $('#copy-btn');
                        let originalText = btn.text();
                        btn.text('Copied!').removeClass('bg-gray-700').addClass('bg-green-600');
                        setTimeout(function() {
                            btn.text(originalText).removeClass('bg-green-600').addClass('bg-gray-700');
                        }, 2000);
                    });
                }
            });
        });
    </script>
</body>
</html>