एक समाचार पत्र सदस्यता सेवा पीटी. 1 | - आवश्यकताएं और सदस्यता पृष्ठ (हिन्दी (Hindi))

एक समाचार पत्र सदस्यता सेवा पीटी. 1 | - आवश्यकताएं और सदस्यता पृष्ठ

Saturday, 21 September 2024

//

12 minute read

परिचय

अन्य लोगों के ब्लॉगों को पढ़ते समय मैंने देखा कि उनमें से बहुत से उपscription सेवा है जो उपयोगकर्ताओं को एक ईमेल भेजने की अनुमति देता है जो उन पर उस ब्लॉग से पोस्ट्स के साथ सप्ताह में भेजा जाता है मैंने इस के अपने संस्करण को लागू करने का निर्णय किया और यह बताने के लिए कि मैं इसे कैसे करता हूँ

मुझे लगता है कि कोई वास्तव में इस का उपयोग करेगा नहीं

चरण

इसलिए इस सेवा को बनाने के लिए मैंने निम्नलिखित आवश्यकताओं पर निर्णय लिया।

  1. एक लचीला सदस्यता पृष्ठ जो उपयोगकर्ताओं को कुछ लचीलीता देता है
    1. उपयोगकर्ता केवल ईमेल में डालते हैं
    2. ईमेल का भाषा चुनने की क्षमता
    3. ईमेल की आवृत्ति चुनने की क्षमता
      • यदि मासिक माह का दिन चुनें तो यह भेजा जाता है
      • यदि सप्ताह का दिन चुनें तो यह भेजा जाता है
      • दिन का समय महत्वपूर्ण नहीं है
      • जब भी मैं ब्लॉग करता हूँ स्वचालित पोस्टिंग को एक डाक भेजने के लिए अनुमति दें.
    4. उपयोगकर्ता को उन श्रेणियों का चयन करने के लिए अनुमति दें जिनमें वे रुचि रखते हैं
  2. साधारण सदस्यता हटाने की अनुमति दें
  3. डाक की पूर्वावलोकन दें जिसे वे प्राप्त करेंगे
  4. उपयोगकर्ता को अपने प्राथमिकताओं को किसी भी समय बदलने की अनुमति दें.
  5. एक अलग सेवा जो ईमेल भेजने का काम करती है
    • जब भी कोई नया पोस्ट बनाया जाता है तो यह सेवा ब्लॉग सेवा द्वारा बुलाया जाएगा
    • इस सेवा के बाद सभी ग्राहकों को ईमेल भेजेगा
    • यह ईमेल भेजने की अनुसूची बनाने के लिए हैंगफायर का उपयोग करेगा

इसका प्रभाव यह है कि मेरे पास बहुत काम करना है

सदस्यता पृष्ठ

मैं एक सदस्यता पृष्ठ लिखने के साथ fun भाग से शुरू किया। SPAसे ); मेरा उमामी विश्लेषण मैं देखता हूँ कि मोबाइल उपकरणों से उपयोगकर्ताओं का एक उचित अनुपात इस stire तक पहुँचता है

उमामु प्लेटफार्म्स

मैं भी चाहता था कि सदस्यता पृष्ठ कैसे उपयोग करना स्पष्ट हो स्टीव क्रुग दर्शन जहां एक पृष्ठ उपयोग के लिए स्पष्ट होना चाहिए और उपयोगकर्ता को यह कैसे प्रयोग करने के बारे में सोचने की आवश्यकता नहीं है

इसका मतलब है कि डिफ़ॉल्ट बहुत से उपयोगकर्ताओं को प्रयोग करना चाहेंगे

  1. साप्ताहिक ईमेल
  2. अंग्रेजी भाषा
  3. सभी श्रेणियों को चुना
  4. एक सोमवार पर ईमेल भेजा गया

अगर ये गलत साबित होते हैं तो मैं इसे बाद में बदल सकता हूँ

तो यह एक पृष्ठ है मैं बना रहा हूँ

सदस्यता पृष्ठ

पृष्ठ के लिए कोड

इस साइट के अन्य भागों की तरह मैं कोड को जितना संभव हो उतना सरल बनाना चाहता था

Subscription Page
@using Mostlylucid.Shared
@using Mostlylucid.Shared.Helpers
@model Mostlylucid.EmailSubscription.Models.EmailSubscribeViewModel

<form x-data="{schedule :'@Model.SubscriptionType'}" x-init="$watch('schedule', value => console.log(value))" hx-boost="true" asp-action="Save" asp-controller="EmailSubscription" 
      hx-target="#contentcontainer" hx-swap="#outerHTML">
    <div class="flex flex-col mb-4">
        <div class="flex flex-wrap lg:flex-nowrap lg:space-x-4 space-y-4 lg:space-y-0 items-start">
            <label class="input input-bordered flex items-center gap-2 mb-2 dark:bg-custom-dark-bg bg-white w-full lg:w-2/3">
                <i class='bx bx-envelope'></i>
                <input type="email" class="grow text-black dark:text-white bg-transparent border-0"
                       asp-for="Email" placeholder="Email (optional)"/>
            </label>
            <div class="grid grid-cols-2 sm:grid-cols-[repeat(auto-fit,minmax(100px,1fr))] w-full lg:w-1/3">
                @{
                    var frequency = Enum.GetValues(typeof(SubscriptionType)).Cast<SubscriptionType>().ToList();
                }
                @foreach (var freq in frequency)
                {
                    <div class="flex items-center w-auto h-full min-h-[30px] lg:mb-0 mb-3">
                        <input x-model="schedule" id="@freq" type="radio" value="@freq.ToString()" name="SubscriptionType" class="hidden peer">
                        <label for="@freq" class="ml-2 text-sm font-medium text-white 
                bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
                peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                            @freq.EnumDisplayName()
                        </label>
                    </div>
                }
            </div>
        </div>
        @{
            var languages = LanguageConverter.LanguageMap;
        }

        <div class="grid grid-cols-[repeat(auto-fit,minmax(85px,1fr))] mt-4 gap-2 pl-6 large:pl-0 w-auto">
            @foreach (var language in languages)
            {
                var [email protected] == language.Key ? "checked" : "";
                <div class="tooltip lg:mb-0 mb-2" data-tip="@language.Value)"  >
                    <div class="flex items-center justify-center w-[85px] h-full min-h-[70px]">
                        <input id="@language.Key" type="radio" value="@language.Key" @isChecked name="language" class="hidden peer">
                        <label for="@language.Key" class="flex flex-col items-center justify-center text-sm font-medium text-white bg-blue-dark opacity-50 peer-checked:opacity-100 w-full h-full">
                            <img src="/img/flags/@(language.Key).svg" asp-append-version="true" class="border-gray-light border rounded-l w-full h-full object-cover" alt="@language.Value">
                        </label>
                    </div>

                </div>
            }
        </div>
        <div class="mt-3 border-neutral-400 dark:border-neutral-600 border rounded-lg" x-data="{ hideCategories: false, showCategories: false }">
            <h4
                class="px-5 py-1 bg-neutral-500 bg-opacity-10 rounded-lg font-body text-primary dark:text-white w-full flex justify-between items-center cursor-pointer"
                x-on:click="if(!hideCategories) { showCategories = !showCategories }">
                <span class="flex flex-row items-center space-x-1">
                    Categories
                    <label class="label cursor-pointer ml-4" x-on:click.stop="">
                        all
                    </label>
                    <input type="checkbox" x-on:click.stop="" x-model="hideCategories" asp-for="AllCategories" class="toggle toggle-info toggle-sm" />
                </span>
                <span>
                    <i
                        class="bx text-2xl"
                        x-show="!hideCategories"
                        :class="showCategories ? 'bx-chevron-up' : 'bx-chevron-down'"></i>
                </span>
            </h4>

            <div class="flex flex-wrap gap-2 pt-2 pl-5 pr-5 pb-2"
                x-show="showCategories"
                x-cloak
                x-transition:enter="max-h-0 opacity-0"
                x-transition:enter-end="max-h-screen opacity-100"
                x-transition:leave="max-h-screen opacity-100"
                x-transition:leave-end="max-h-0 opacity-0">
                <div class="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] mt-4 w-full">
                    @foreach (var category in Model.Categories)
                    {
                        var categoryKey = category.Replace(" ", "_").Replace(".", "_").Replace("-", "_");
                        <div class="flex items-center w-auto h-full min-h-[50px]">
                            <input id="@categoryKey" type="checkbox" value="@category"  name="@nameof(Model.SelectedCategories)" class="hidden peer">
                            <label for="@categoryKey" class="ml-2 text-sm font-medium text-white 
            bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
            peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                                @category
                            </label>
                        </div>
                    }
                </div>
            </div></div>


        <div :class="{ 'opacity-50 pointer-events-none': schedule !== 'Weekly' }" class=" mt-2 border-neutral-400 dark:border-neutral-600 border rounded-lg" >
            <h4
                class="px-5 py-1 bg-neutral-500 bg-opacity-10 rounded-lg font-body text-primary dark:text-white w-full flex justify-between items-center cursor-pointer"
               >
                <span class="flex flex-row items-center space-x-1 ">
                    Day of Week to Send On
                    
                  
                </span>
               
            </h4>

        <div class="grid grid-cols-3 sm:grid-cols-[repeat(auto-fit,minmax(80px,1fr))] my-2 w-full lg:w-1/2" x-show="schedule === 'Weekly'">
            @foreach (var day in Model.DaysOfWeek)
            {
                var checkedDay = day.ToString() == Model.Day ? "checked" : "";
                <div class="flex items-center w-auto h-full min-h-[50px]">
                    <input id="@day" type="radio" value="@day" name="day" @checkedDay class="hidden peer">
                    <label for="@day" class="ml-2 text-sm font-medium text-white 
            bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
            peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                        @day.ToString()
                    </label>
                </div>
            }
        </div>

            </div>
        <div :class="{ 'opacity-50 pointer-events-none': schedule !== 'Monthly' }" class=" mt-2 border-neutral-400 dark:border-neutral-600 border rounded-lg" >
            <h4
                class="px-5 py-1 bg-neutral-500 bg-opacity-10 rounded-lg font-body text-primary dark:text-white w-full flex justify-between items-center cursor-pointer">
                <span class="flex flex-row items-center space-x-1 ">
                    Day of Month to Send On
                </span>
            </h4>
            <div class="grid grid-cols-[repeat(auto-fit,minmax(35px,1fr))] w-full mx-2" x-show="schedule === 'Monthly'">
                @for(int i=1; i<32; i++)
                {
                    var checkedMonthDay = i == Model.DayOfMonth ? "checked" : "";
                    <div class="flex items-center w-auto my-2 h-full min-h-[35px]">
                        <input id="Day_@i" type="radio" value="@i" name="daypfmonth" @checkedMonthDay class="hidden peer">
                        <label for="Day_@i" class="ml-2 text-sm font-medium text-white 
            bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
            peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                             @i.GetOrdinal()
                        </label>
                    </div>
                }
            </div>
        </div>
        @* Action Buttons *@
        <div class="flex flex-row gap-2 mt-4">
            <button type="submit" class="btn btn-primary">Subscribe</button>
            <button type="reset" class="btn-warning btn">Reset</button>
        </div>
    </div>
</form>
आप देख सकते हैं कि यह काफी सरल है क्योंकि यह चला जाता है
<div class="grid grid-cols-2 sm:grid-cols-[repeat(auto-fit,minmax(100px,1fr))] w-full lg:w-1/3">
 @{
var frequency = Enum.GetValues(typeof(SubscriptionType)).Cast<SubscriptionType>().ToList();
 }
 @foreach (var freq in frequency)
{
<div class="flex items-center w-auto h-full min-h-[30px] lg:mb-0 mb-3">
     <input x-model="schedule" id="@freq" type="radio" value="@freq.ToString()" name="SubscriptionType" class="hidden peer">
      <label for="@freq" class="ml-2 text-sm font-medium text-white 
                bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
                peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                            @freq.EnumDisplayName()
      </label>
</div>
}
</div>

आप देख सकते हैं कि यह सीएसएस आधारित है peer यह निर्दिष्ट करने के लिए सीएसएस यूटिलिटी कि जब लेबल पर क्लिक किया जाता है तो इनपुट को सेट करें

मैं यह पृष्ठ में बाद में उपयोग करता हूँ कि कौन से चयनक को निर्धारित करने के लिए उपयोगकर्ताओं के लिए उपलब्ध कराएँ

<div :class="{ 'opacity-50 pointer-events-none': schedule !== 'Monthly' }" class=" mt-2 border-neutral-400 dark:border-neutral-600 border rounded-lg" >
   <h4
       class="px-5 py-1 bg-neutral-500 bg-opacity-10 rounded-lg font-body text-primary dark:text-white w-full flex justify-between items-center cursor-pointer">
       <span class="flex flex-row items-center space-x-1 ">
           Day of Month to Send On
       </span>
   </h4>
   <div class="grid grid-cols-[repeat(auto-fit,minmax(35px,1fr))] w-full mx-2" x-show="schedule === 'Monthly'">
       @for(int i=1; i<32; i++)
       {
           var checkedMonthDay = i == Model.DayOfMonth ? "checked" : "";
           <div class="flex items-center w-auto my-2 h-full min-h-[35px]">
               <input id="Day_@i" type="radio" value="@i" name="daypfmonth" @checkedMonthDay class="hidden peer">
               <label for="Day_@i" class="ml-2 text-sm font-medium text-white 
   bg-blue-dark border-gray-light border rounded-xl px-1 py-2 w-full 
   peer-checked:text-blue-600 peer-checked:dark:bg-green text-center justify-center">
                    @i.GetOrdinal()
               </label>
           </div>
       }
   </div>
</div>

आप देख सकते हैं कि मेरे पास एक Alpine.js css टेम्प्लेट वर्ग है जो तत्व की अपारदर्शिता \50%\ पर सेट करता है और यदि अनुसूची मासिक के लिए सेट नहीं है तो संकेतक घटनाओं को अक्षम करता है

:class="{ 'opacity-50 pointer-events-none': schedule !== 'Monthly' }" 

यह मोनेहली दिन चयनक भी छुपाता है यदि अनुसूची मासिक के लिए सेट नहीं है

x-show="schedule === 'Monthly'"

इसलिए, यह अनुसूची पृष्ठ के jist है. मैं अगले पोस्ट में बैकएण्ड को कवर करता हूँ

अगला कदम

अगले पोस्ट में मैं यह bulding समाप्त करने के बाद 'll (\when I post the new structural changes to the project to allow me to use a separate web application for Hanfgire and the email sending service Mostlylucid सेवाओं के आदान-प्रदान को अनुमति देने वाले अनेक परियोजनाओं में

  1. Mostlylucid मुख्य वेबसाइट परियोजना

  2. Mostlylucid.SchedulerService यह मुख्य हैंगफायर परियोजना है जो डेटाबेस पहुँचेगा

  3. Mostlylucid.Services - जहां सेवाएं रहती हैं जो शीर्ष स्तर परियोजनाओं को डेटा लौटाती है

  4. Mostlylucid.Shared सभी परियोजनाओं में उपयोग किए जाने वाले सहायक और स्थिरांक

  5. Mostlylucid.DbContext परियोजना के लिए डाटाबेस संदर्भ

आप यह देख सकते हैं यह सिस्टम वास्तुकला में काफी अधिक जटिलता जोड़ता है, लेकिन इस मामले में यह आवश्यक है कि परियोजना को संरक्षित और scalable बनाए रखना मैं इस श्रृंखला के बाकी में यह कैसे किया करता हूँ कवरll

अंत में

मुझे अभी भी यह सब करने के लिए एक टन कार्य करना है।

Finding related posts...
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.