v1.0.0
This commit is contained in:
parent
0fcf42b47b
commit
443dceb8ca
2 changed files with 566609 additions and 230 deletions
263
assets/css/admin.css
Normal file
263
assets/css/admin.css
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
/**
|
||||
* Admin Styles for Documentation Markdown Plugin
|
||||
*
|
||||
* @package RobotsTxt\DocumentationMarkdown
|
||||
* @author ROBOTSTXT
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
.robotstxt-docmd-settings {
|
||||
max-width: 900px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-intro {
|
||||
background: #fff;
|
||||
border-left: 4px solid #2271b1;
|
||||
padding: 15px 20px;
|
||||
margin: 20px 0;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.robotstxt-docmd-intro p.description {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-info {
|
||||
background: #f6f7f7;
|
||||
border: 1px solid #c3c4c7;
|
||||
padding: 20px;
|
||||
margin-top: 30px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-info h2 {
|
||||
margin-top: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-info p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.form-table th {
|
||||
padding: 20px 10px 20px 0;
|
||||
}
|
||||
|
||||
.form-table td {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.form-table input[type="url"],
|
||||
.form-table input[type="password"] {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.form-table .description {
|
||||
color: #646970;
|
||||
font-style: normal;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.form-table .notice.inline {
|
||||
margin-left: 0;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.form-table .notice.inline ol {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.form-table .notice.inline ol li {
|
||||
margin-bottom: 8px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.form-table .notice.inline em {
|
||||
color: #646970;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Mappings Page */
|
||||
.robotstxt-docmd-mappings,
|
||||
.robotstxt-docmd-edit-mapping {
|
||||
max-width: 1200px;
|
||||
}
|
||||
|
||||
/* Statistics Dashboard */
|
||||
.robotstxt-docmd-stats {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
background: #f6f7f7;
|
||||
padding: 15px 20px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #646970;
|
||||
margin-bottom: 8px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.bulk-actions {
|
||||
border-top: 1px solid #c3c4c7;
|
||||
padding-top: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Empty State */
|
||||
.robotstxt-docmd-empty {
|
||||
background: #fff;
|
||||
border: 1px dashed #c3c4c7;
|
||||
padding: 40px 20px;
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-empty p {
|
||||
font-size: 16px;
|
||||
color: #646970;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Mappings Table */
|
||||
.robotstxt-docmd-mappings table {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-mappings table th,
|
||||
.robotstxt-docmd-mappings table td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-mappings table td code {
|
||||
background: #f6f7f7;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-mappings table td small {
|
||||
display: block;
|
||||
color: #646970;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Status Badges */
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.status-badge.status-enabled {
|
||||
background: #d7f0db;
|
||||
color: #1e4620;
|
||||
}
|
||||
|
||||
.status-badge.status-disabled {
|
||||
background: #f0f0f1;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.status-badge.status-never {
|
||||
background: #f0f0f1;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.status-badge.status-pending {
|
||||
background: #fcf9e8;
|
||||
color: #8a6d3b;
|
||||
}
|
||||
|
||||
.status-badge.status-success {
|
||||
background: #d7f0db;
|
||||
color: #1e4620;
|
||||
}
|
||||
|
||||
.status-badge.status-error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #d63638;
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Action Buttons */
|
||||
.robotstxt-docmd-mappings .button {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-mappings .button:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.sync-mapping-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Edit Mapping Form */
|
||||
.robotstxt-docmd-edit-mapping .form-table input[type="text"],
|
||||
.robotstxt-docmd-edit-mapping .form-table select {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-edit-mapping .required {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media screen and (max-width: 782px) {
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.bulk-actions {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.robotstxt-docmd-mappings .button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
155
assets/js/admin.js
Normal file
155
assets/js/admin.js
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/**
|
||||
* Admin JavaScript
|
||||
*
|
||||
* Handles AJAX functionality for documentation mappings.
|
||||
*
|
||||
* @package RobotsTxt\DocumentationMarkdown
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Sync a single mapping via AJAX
|
||||
*/
|
||||
function syncMapping(mappingId, button) {
|
||||
const $button = $(button);
|
||||
const originalText = $button.text();
|
||||
|
||||
// Disable button and show loading state
|
||||
$button.prop('disabled', true).text(robotstxtDocMd.strings.syncing);
|
||||
|
||||
$.ajax({
|
||||
url: robotstxtDocMd.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'robotstxt_docmd_sync_mapping',
|
||||
nonce: robotstxtDocMd.nonce,
|
||||
mapping_id: mappingId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Update sync status badge
|
||||
const $row = $button.closest('tr');
|
||||
const $statusCell = $row.find('td').eq(4); // Sync Status column
|
||||
$statusCell.html(response.data.sync_status);
|
||||
|
||||
// Update last sync time
|
||||
const $lastSyncCell = $row.find('td').eq(5); // Last Sync column
|
||||
if (response.data.mapping.last_sync) {
|
||||
$lastSyncCell.text(response.data.mapping.last_sync);
|
||||
}
|
||||
|
||||
// Show success message
|
||||
showNotice(response.data.message, 'success');
|
||||
} else {
|
||||
showNotice(robotstxtDocMd.strings.syncError + ' ' + response.data.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
showNotice(robotstxtDocMd.strings.syncError + ' ' + error, 'error');
|
||||
},
|
||||
complete: function() {
|
||||
// Re-enable button
|
||||
$button.prop('disabled', false).text(originalText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync all active mappings via AJAX
|
||||
*/
|
||||
function syncAllMappings() {
|
||||
const $button = $('#sync-all-mappings');
|
||||
const originalText = $button.text();
|
||||
|
||||
// Disable button and show loading state
|
||||
$button.prop('disabled', true).text(robotstxtDocMd.strings.syncingAll);
|
||||
|
||||
$.ajax({
|
||||
url: robotstxtDocMd.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'robotstxt_docmd_sync_all',
|
||||
nonce: robotstxtDocMd.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showNotice(response.data.message, 'success');
|
||||
|
||||
// Reload page to show updated statuses
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 1500);
|
||||
} else {
|
||||
showNotice(robotstxtDocMd.strings.syncError + ' ' + response.data.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
showNotice(robotstxtDocMd.strings.syncError + ' ' + error, 'error');
|
||||
},
|
||||
complete: function() {
|
||||
// Re-enable button
|
||||
$button.prop('disabled', false).text(originalText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show admin notice
|
||||
*/
|
||||
function showNotice(message, type) {
|
||||
const $notice = $('<div class="notice notice-' + type + ' is-dismissible"><p>' + message + '</p></div>');
|
||||
|
||||
// Insert after the h1
|
||||
$('.wrap h1').after($notice);
|
||||
|
||||
// Make it dismissible
|
||||
$(document).trigger('wp-updates-notice-added');
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
setTimeout(function() {
|
||||
$notice.fadeOut(400, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Document ready
|
||||
$(document).ready(function() {
|
||||
// Sync single mapping button click
|
||||
$('.sync-mapping-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const mappingId = $(this).data('mapping-id');
|
||||
syncMapping(mappingId, this);
|
||||
});
|
||||
|
||||
// Sync all mappings button click
|
||||
$('#sync-all-mappings').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
syncAllMappings();
|
||||
});
|
||||
|
||||
// Form validation
|
||||
$('form[action*="robotstxt_docmd_save_mapping"]').on('submit', function(e) {
|
||||
const title = $('#title').val().trim();
|
||||
const repoOwner = $('#repo_owner').val().trim();
|
||||
const repoName = $('#repo_name').val().trim();
|
||||
const filePath = $('#file_path').val().trim();
|
||||
|
||||
if (!title || !repoOwner || !repoName || !filePath) {
|
||||
e.preventDefault();
|
||||
showNotice('Please fill in all required fields.', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate file path ends with .md or .markdown
|
||||
if (!/\.(md|markdown)$/i.test(filePath)) {
|
||||
e.preventDefault();
|
||||
showNotice('File path must end with .md or .markdown', 'error');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
Loading…
Reference in a new issue