Add custom source input for manually adding communities
- Add 'Custom Source' text input field to polling form - Allows manual entry of subreddits (r/subreddit) or RSS URLs - Custom input overrides dropdown selection if filled - Dropdown becomes optional when custom source is entered - Backend prioritizes custom_source_id over dropdown source_id 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
5
app.py
5
app.py
@@ -1347,9 +1347,14 @@ def admin_polling_add():
|
|||||||
|
|
||||||
platform = request.form.get('platform')
|
platform = request.form.get('platform')
|
||||||
source_id = request.form.get('source_id')
|
source_id = request.form.get('source_id')
|
||||||
|
custom_source_id = request.form.get('custom_source_id')
|
||||||
display_name = request.form.get('display_name')
|
display_name = request.form.get('display_name')
|
||||||
poll_interval = int(request.form.get('poll_interval', 60))
|
poll_interval = int(request.form.get('poll_interval', 60))
|
||||||
|
|
||||||
|
# Use custom source if provided, otherwise use dropdown
|
||||||
|
if custom_source_id and custom_source_id.strip():
|
||||||
|
source_id = custom_source_id.strip()
|
||||||
|
|
||||||
if not platform or not source_id or not display_name:
|
if not platform or not source_id or not display_name:
|
||||||
flash('Missing required fields', 'error')
|
flash('Missing required fields', 'error')
|
||||||
return redirect(url_for('admin_polling'))
|
return redirect(url_for('admin_polling'))
|
||||||
|
|||||||
@@ -223,6 +223,13 @@
|
|||||||
<select class="form-select" name="source_id" id="source_id" required onchange="updateDisplayName()">
|
<select class="form-select" name="source_id" id="source_id" required onchange="updateDisplayName()">
|
||||||
<option value="">Select source...</option>
|
<option value="">Select source...</option>
|
||||||
</select>
|
</select>
|
||||||
|
<p class="help-text">Or enter custom source below</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label" for="custom_source_id">Custom Source (optional)</label>
|
||||||
|
<input type="text" class="form-input" name="custom_source_id" id="custom_source_id" placeholder="e.g., r/technology or https://example.com/feed.xml">
|
||||||
|
<p class="help-text">For Reddit: r/subreddit | For RSS: full URL | Leave blank to use dropdown</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -370,6 +377,16 @@
|
|||||||
displayNameInput.value = selectedOption.dataset.displayName;
|
displayNameInput.value = selectedOption.dataset.displayName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle custom source input - make dropdown optional when custom is filled
|
||||||
|
document.getElementById('custom_source_id').addEventListener('input', function() {
|
||||||
|
const sourceSelect = document.getElementById('source_id');
|
||||||
|
if (this.value.trim()) {
|
||||||
|
sourceSelect.removeAttribute('required');
|
||||||
|
} else {
|
||||||
|
sourceSelect.setAttribute('required', 'required');
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user