diff --git a/OnlyOneAccessTemplate/Controllers/BaseController.cs b/OnlyOneAccessTemplate/Controllers/BaseController.cs index d8800f6..3d503b1 100644 --- a/OnlyOneAccessTemplate/Controllers/BaseController.cs +++ b/OnlyOneAccessTemplate/Controllers/BaseController.cs @@ -6,7 +6,6 @@ using OnlyOneAccessTemplate.Models; namespace OnlyOneAccessTemplate.Controllers { - public abstract class BaseController : Controller { protected readonly ISiteConfigurationService _siteConfig; @@ -37,6 +36,7 @@ namespace OnlyOneAccessTemplate.Controllers SetupSeoViewBag(config, language, currentUrl); SetupContentViewBag(config, language); + SetupConverterViewBag(language); // Nova configuração específica do conversor base.OnActionExecuting(context); } @@ -118,6 +118,246 @@ namespace OnlyOneAccessTemplate.Controllers ViewBag.ConversionConfig = config.Conversion; } + // Nova função para configurar textos específicos do conversor + protected void SetupConverterViewBag(string language) + { + var converterType = _configuration.GetValue("Converter:Type") ?? "generic"; + var converterName = _configuration.GetValue("Converter:Name") ?? "Conversor Online"; + + switch (language) + { + case "en": + SetupEnglishConverterContent(converterType, converterName); + break; + case "es": + SetupSpanishConverterContent(converterType, converterName); + break; + default: + SetupPortugueseConverterContent(converterType, converterName); + break; + } + } + + protected virtual void SetupPortugueseConverterContent(string converterType, string converterName) + { + // Configurações específicas por tipo de conversor + switch (converterType) + { + case "text-case": + ViewBag.ConverterTitle = "CONVERSOR DE MAIÚSCULAS E MINÚSCULAS"; + ViewBag.ConverterDescription = "Converta texto entre maiúsculas, minúsculas, título e primeira maiúscula"; + ViewBag.Step1Title = "Cole o Texto"; + ViewBag.Step1Description = "Digite ou cole o texto que deseja converter"; + ViewBag.Step2Title = "Escolha o Formato"; + ViewBag.Step2Description = "Selecione o tipo de conversão desejada"; + ViewBag.Step3Title = "Copie o Resultado"; + ViewBag.Step3Description = "Copie o texto convertido"; + ViewBag.InputLabel = "Texto Original"; + ViewBag.OutputLabel = "Texto Convertido"; + ViewBag.InputPlaceholder = "Digite ou cole seu texto aqui..."; + ViewBag.OutputPlaceholder = "O texto convertido aparecerá aqui..."; + ViewBag.ConvertButtonText = "Converter Texto"; + ViewBag.ConverterType = "text"; + ViewBag.OutputType = "text"; + ViewBag.HasAdvancedOptions = true; + break; + + case "csv-json": + ViewBag.ConverterTitle = "CONVERSOR CSV PARA JSON"; + ViewBag.ConverterDescription = "Converta arquivos CSV para formato JSON de forma rápida e fácil"; + ViewBag.Step1Title = "Upload CSV"; + ViewBag.Step1Description = "Selecione um arquivo CSV ou cole o conteúdo"; + ViewBag.Step2Title = "Processar"; + ViewBag.Step2Description = "Aguarde a conversão automática"; + ViewBag.Step3Title = "Baixar JSON"; + ViewBag.Step3Description = "Baixe ou copie o resultado"; + ViewBag.InputLabel = "Arquivo CSV"; + ViewBag.OutputLabel = "Resultado JSON"; + ViewBag.InputPlaceholder = "Cole o conteúdo CSV aqui ou faça upload de um arquivo..."; + ViewBag.OutputPlaceholder = "O JSON convertido aparecerá aqui..."; + ViewBag.ConvertButtonText = "Converter para JSON"; + ViewBag.ConverterType = "text"; // Aceita texto e arquivo + ViewBag.OutputType = "text"; + ViewBag.AcceptedFileTypes = ".csv,.txt"; + ViewBag.FileHelpText = "Tamanho máximo: 10MB. Formatos: CSV, TXT"; + break; + + case "image-ocr": + ViewBag.ConverterTitle = "CONVERSOR DE IMAGEM PARA TEXTO - OCR ONLINE"; + ViewBag.ConverterDescription = "Extraia texto de imagens usando tecnologia de Reconhecimento Óptico de Caracteres"; + ViewBag.Step1Title = "Upload Imagem"; + ViewBag.Step1Description = "Selecione uma imagem com texto"; + ViewBag.Step2Title = "Processar OCR"; + ViewBag.Step2Description = "Aguarde a extração do texto"; + ViewBag.Step3Title = "Copiar Texto"; + ViewBag.Step3Description = "Copie ou baixe o texto extraído"; + ViewBag.InputLabel = "Imagem"; + ViewBag.OutputLabel = "Texto Extraído"; + ViewBag.SelectFileText = "SELECIONAR IMAGEM"; + ViewBag.ConvertButtonText = "Extrair Texto"; + ViewBag.ConverterType = "file"; + ViewBag.OutputType = "text"; + ViewBag.AcceptedFileTypes = ".jpg,.jpeg,.png,.gif,.bmp,.pdf"; + ViewBag.FileHelpText = "Tamanho máximo: 15MB. Formatos: JPG, PNG, GIF, BMP, PDF"; + ViewBag.HasAdvancedOptions = true; + break; + + default: + // Configuração genérica + ViewBag.ConverterTitle = converterName.ToUpper(); + ViewBag.ConverterDescription = "Converta seus arquivos de forma rápida e segura"; + ViewBag.Step1Title = "Entrada"; + ViewBag.Step1Description = "Selecione ou cole seu conteúdo"; + ViewBag.Step2Title = "Processar"; + ViewBag.Step2Description = "Aguarde o processamento"; + ViewBag.Step3Title = "Resultado"; + ViewBag.Step3Description = "Baixe ou copie o resultado"; + ViewBag.ConvertButtonText = "Converter"; + ViewBag.ConverterType = "text"; + ViewBag.OutputType = "text"; + break; + } + + // Textos comuns do conversor + ViewBag.LoadingText = "Processando..."; + ViewBag.ProcessingText = "Convertendo seu arquivo..."; + ViewBag.CopyButtonText = "Copiar"; + ViewBag.ClearButtonText = "Limpar"; + ViewBag.ShareButtonText = "Compartilhar"; + ViewBag.CopiedText = "Copiado!"; + ViewBag.DownloadButtonText = "Baixar"; + ViewBag.DownloadReadyText = "Seu arquivo está pronto!"; + ViewBag.SecurityText = "Seus dados estão seguros conosco"; + ViewBag.DefaultErrorMessage = "Erro ao processar. Tente novamente."; + ViewBag.AdvancedOptionsText = "Opções Avançadas"; + ViewBag.PreviewPlaceholder = "O resultado aparecerá aqui..."; + + // Configurações de benefícios + ViewBag.BenefitsTitle = "Por Que Usar Nossa Ferramenta?"; + ViewBag.BenefitsSubtitle = "Descubra os benefícios de nossa solução"; + ViewBag.FinalCtaTitle = "Pronto para Converter?"; + ViewBag.FinalCtaSubtitle = "Use nossa ferramenta gratuita agora mesmo"; + ViewBag.FinalCtaButtonText = "Começar Conversão"; + + // Features padrão se não especificadas + if (ViewBag.Feature1Title == null) + { + ViewBag.Feature1Title = "Rápido e Fácil"; + ViewBag.Feature1Description = "Conversão instantânea sem complicações"; + ViewBag.Feature2Title = "Seguro"; + ViewBag.Feature2Description = "Seus dados são processados com segurança"; + ViewBag.Feature3Title = "Gratuito"; + ViewBag.Feature3Description = "Use nossa ferramenta sem custos"; + } + } + + protected virtual void SetupEnglishConverterContent(string converterType, string converterName) + { + switch (converterType) + { + case "text-case": + ViewBag.ConverterTitle = "TEXT CASE CONVERTER"; + ViewBag.ConverterDescription = "Convert text between uppercase, lowercase, title case and sentence case"; + ViewBag.Step1Title = "Paste Text"; + ViewBag.Step1Description = "Type or paste the text you want to convert"; + ViewBag.Step2Title = "Choose Format"; + ViewBag.Step2Description = "Select the desired conversion type"; + ViewBag.Step3Title = "Copy Result"; + ViewBag.Step3Description = "Copy the converted text"; + ViewBag.InputLabel = "Original Text"; + ViewBag.OutputLabel = "Converted Text"; + ViewBag.InputPlaceholder = "Type or paste your text here..."; + ViewBag.OutputPlaceholder = "Converted text will appear here..."; + ViewBag.ConvertButtonText = "Convert Text"; + break; + + case "csv-json": + ViewBag.ConverterTitle = "CSV TO JSON CONVERTER"; + ViewBag.ConverterDescription = "Convert CSV files to JSON format quickly and easily"; + ViewBag.Step1Title = "Upload CSV"; + ViewBag.Step1Description = "Select a CSV file or paste content"; + ViewBag.Step2Title = "Process"; + ViewBag.Step2Description = "Wait for automatic conversion"; + ViewBag.Step3Title = "Download JSON"; + ViewBag.Step3Description = "Download or copy the result"; + ViewBag.ConvertButtonText = "Convert to JSON"; + break; + + case "image-ocr": + ViewBag.ConverterTitle = "IMAGE TO TEXT CONVERTER - OCR ONLINE"; + ViewBag.ConverterDescription = "Extract text from images using Optical Character Recognition technology"; + ViewBag.Step1Title = "Upload Image"; + ViewBag.Step1Description = "Select an image with text"; + ViewBag.Step2Title = "Process OCR"; + ViewBag.Step2Description = "Wait for text extraction"; + ViewBag.Step3Title = "Copy Text"; + ViewBag.Step3Description = "Copy or download extracted text"; + ViewBag.SelectFileText = "SELECT IMAGE"; + ViewBag.ConvertButtonText = "Extract Text"; + break; + + default: + ViewBag.ConverterTitle = converterName.ToUpper(); + ViewBag.ConverterDescription = "Convert your files quickly and securely"; + ViewBag.ConvertButtonText = "Convert"; + break; + } + + // Common English texts + ViewBag.LoadingText = "Processing..."; + ViewBag.ProcessingText = "Converting your file..."; + ViewBag.CopyButtonText = "Copy"; + ViewBag.ClearButtonText = "Clear"; + ViewBag.ShareButtonText = "Share"; + ViewBag.CopiedText = "Copied!"; + ViewBag.DownloadButtonText = "Download"; + ViewBag.SecurityText = "Your data is safe with us"; + ViewBag.BenefitsTitle = "Why Use Our Tool?"; + ViewBag.FinalCtaTitle = "Ready to Convert?"; + } + + protected virtual void SetupSpanishConverterContent(string converterType, string converterName) + { + switch (converterType) + { + case "text-case": + ViewBag.ConverterTitle = "CONVERTIDOR DE MAYÚSCULAS Y MINÚSCULAS"; + ViewBag.ConverterDescription = "Convierte texto entre mayúsculas, minúsculas, título y oración"; + ViewBag.ConvertButtonText = "Convertir Texto"; + break; + + case "csv-json": + ViewBag.ConverterTitle = "CONVERTIDOR CSV A JSON"; + ViewBag.ConverterDescription = "Convierte archivos CSV a formato JSON de forma rápida y fácil"; + ViewBag.ConvertButtonText = "Convertir a JSON"; + break; + + case "image-ocr": + ViewBag.ConverterTitle = "CONVERTIDOR DE IMAGEN A TEXTO - OCR EN LÍNEA"; + ViewBag.ConverterDescription = "Extrae texto de imágenes usando tecnología de Reconocimiento Óptico de Caracteres"; + ViewBag.SelectFileText = "SELECCIONAR IMAGEN"; + ViewBag.ConvertButtonText = "Extraer Texto"; + break; + + default: + ViewBag.ConverterTitle = converterName.ToUpper(); + ViewBag.ConverterDescription = "Convierte tus archivos de forma rápida y segura"; + ViewBag.ConvertButtonText = "Convertir"; + break; + } + + // Common Spanish texts + ViewBag.LoadingText = "Procesando..."; + ViewBag.ProcessingText = "Convirtiendo tu archivo..."; + ViewBag.CopyButtonText = "Copiar"; + ViewBag.ClearButtonText = "Limpiar"; + ViewBag.CopiedText = "¡Copiado!"; + ViewBag.SecurityText = "Tus datos están seguros con nosotros"; + ViewBag.BenefitsTitle = "¿Por Qué Usar Nuestra Herramienta?"; + ViewBag.FinalCtaTitle = "¿Listo para Convertir?"; + } + + // Resto dos métodos permanece igual... protected void SetupPortugueseContent() { // Menu @@ -127,104 +367,18 @@ namespace OnlyOneAccessTemplate.Controllers ViewBag.MenuPrivacy = "Privacidade"; ViewBag.MenuTerms = "Termos"; - // Hero Section - ViewBag.DefaultHeroTitle = "Transforme Seu Negócio com Nossa Solução"; - ViewBag.DefaultHeroSubtitle = "Aumente suas vendas em até 300% com nossa metodologia comprovada e suporte especializado."; - ViewBag.DefaultCtaText = "Comece Agora"; - ViewBag.WatchVideoText = "Assistir Vídeo"; - - // Features - ViewBag.DefaultFeaturesTitle = "Por Que Escolher Nossa Solução?"; - ViewBag.DefaultFeaturesSubtitle = "Descubra os benefícios que já transformaram mais de 1000 empresas"; - ViewBag.Feature1Title = "Resultados Rápidos"; - ViewBag.Feature1Description = "Veja os primeiros resultados em até 30 dias"; - ViewBag.Feature2Title = "Suporte 24/7"; - ViewBag.Feature2Description = "Equipe especializada sempre disponível"; - ViewBag.Feature3Title = "Metodologia Comprovada"; - ViewBag.Feature3Description = "Mais de 1000 casos de sucesso documentados"; - - // Form - ViewBag.FormTitle = "Solicite uma Demonstração Gratuita"; - ViewBag.FormSubtitle = "Preencha o formulário e nossa equipe entrará em contato"; - ViewBag.NameLabel = "Nome Completo"; - ViewBag.NamePlaceholder = "Digite seu nome completo"; - ViewBag.EmailLabel = "E-mail"; - ViewBag.EmailPlaceholder = "Digite seu e-mail"; - ViewBag.PhoneLabel = "Telefone"; - ViewBag.PhonePlaceholder = "Digite seu telefone"; - ViewBag.SubmitButtonText = "Solicitar Demonstração"; - ViewBag.LoadingText = "Enviando..."; - - // Quick Form - ViewBag.QuickFormTitle = "Acesso Rápido"; - ViewBag.QuickSubmitText = "Começar Agora"; - ViewBag.QuickConsentText = "Concordo em receber informações por e-mail"; - - // Validation - ViewBag.RequiredFieldMessage = "Este campo é obrigatório"; - ViewBag.EmailValidationMessage = "Digite um e-mail válido"; - ViewBag.PhoneValidationMessage = "Digite um telefone válido"; - ViewBag.ConsentValidationMessage = "Você deve concordar para continuar"; - - // Consent - ViewBag.ConsentText = "Concordo em receber comunicações e com a Política de Privacidade"; - - // Benefits - ViewBag.BenefitsTitle = "O que você vai receber:"; - ViewBag.DefaultBenefit1 = "Consultoria personalizada"; - ViewBag.DefaultBenefit2 = "Suporte técnico especializado"; - ViewBag.DefaultBenefit3 = "Garantia de resultados"; - - // Testimonials - ViewBag.DefaultTestimonialsTitle = "O Que Nossos Clientes Dizem"; - ViewBag.DefaultTestimonialsSubtitle = "Mais de 1000 empresas já transformaram seus resultados"; - SetupPortugueseTestimonials(); - - // CTA - ViewBag.DefaultCtaTitle = "Pronto para Transformar Seu Negócio?"; - ViewBag.DefaultCtaSubtitle = "Junte-se a mais de 1000 empresas que já alcançaram resultados extraordinários"; - ViewBag.DefaultCtaButtonText = "Começar Transformação"; - // Footer - ViewBag.FooterDescription = "Transformando negócios através de soluções inovadoras"; + ViewBag.FooterDescription = "Transformando dados através de soluções inovadoras"; ViewBag.FooterMenuTitle = "Links"; ViewBag.FooterLegalTitle = "Legal"; ViewBag.FooterContactTitle = "Contato"; ViewBag.FooterCopyright = "Todos os direitos reservados."; ViewBag.FooterMadeWith = "Feito com ❤️ no Brasil"; - // Success - ViewBag.SuccessTitle = "Obrigado!"; - ViewBag.SuccessMessage = "Recebemos sua solicitação. Nossa equipe entrará em contato em breve."; - ViewBag.CloseButtonText = "Fechar"; - - // Thank You Page - ViewBag.NextStepsTitle = "O que acontece agora?"; - ViewBag.Step1Title = "Análise"; - ViewBag.Step1Description = "Nossa equipe analisará sua solicitação"; - ViewBag.Step2Title = "Contato"; - ViewBag.Step2Description = "Entraremos em contato em até 24h"; - ViewBag.Step3Title = "Implementação"; - ViewBag.Step3Description = "Iniciaremos sua transformação"; - ViewBag.ContactInfoTitle = "Precisa falar conosco?"; - ViewBag.BackToHomeText = "Voltar ao Início"; - ViewBag.WhatsAppText = "Falar no WhatsApp"; - ViewBag.RedirectConfirmText = "Deseja voltar à página inicial?"; - - // Security - ViewBag.SecurityText = "Seus dados estão seguros conosco"; - - // Time - ViewBag.DaysText = "Dias"; - ViewBag.HoursText = "Horas"; - ViewBag.MinutesText = "Min"; - ViewBag.SecondsText = "Seg"; - // Contact info ViewBag.ContactEmail = "contato@seusite.com"; ViewBag.ContactPhone = "(11) 99999-9999"; ViewBag.ContactAddress = "São Paulo, SP"; - ViewBag.TestimonialsCount = "Mais de 500 avaliações 5 estrelas"; } protected void SetupEnglishContent() @@ -236,104 +390,18 @@ namespace OnlyOneAccessTemplate.Controllers ViewBag.MenuPrivacy = "Privacy"; ViewBag.MenuTerms = "Terms"; - // Hero Section - ViewBag.DefaultHeroTitle = "Transform Your Business with Our Solution"; - ViewBag.DefaultHeroSubtitle = "Increase your sales by up to 300% with our proven methodology and expert support."; - ViewBag.DefaultCtaText = "Get Started"; - ViewBag.WatchVideoText = "Watch Video"; - - // Features - ViewBag.DefaultFeaturesTitle = "Why Choose Our Solution?"; - ViewBag.DefaultFeaturesSubtitle = "Discover the benefits that have already transformed over 1000 companies"; - ViewBag.Feature1Title = "Fast Results"; - ViewBag.Feature1Description = "See first results within 30 days"; - ViewBag.Feature2Title = "24/7 Support"; - ViewBag.Feature2Description = "Specialized team always available"; - ViewBag.Feature3Title = "Proven Method"; - ViewBag.Feature3Description = "Over 1000 documented success cases"; - - // Form - ViewBag.FormTitle = "Request a Free Demo"; - ViewBag.FormSubtitle = "Fill out the form and our team will contact you"; - ViewBag.NameLabel = "Full Name"; - ViewBag.NamePlaceholder = "Enter your full name"; - ViewBag.EmailLabel = "Email"; - ViewBag.EmailPlaceholder = "Enter your email"; - ViewBag.PhoneLabel = "Phone"; - ViewBag.PhonePlaceholder = "Enter your phone"; - ViewBag.SubmitButtonText = "Request Demo"; - ViewBag.LoadingText = "Sending..."; - - // Quick Form - ViewBag.QuickFormTitle = "Quick Access"; - ViewBag.QuickSubmitText = "Start Now"; - ViewBag.QuickConsentText = "I agree to receive information by email"; - - // Validation - ViewBag.RequiredFieldMessage = "This field is required"; - ViewBag.EmailValidationMessage = "Enter a valid email"; - ViewBag.PhoneValidationMessage = "Enter a valid phone"; - ViewBag.ConsentValidationMessage = "You must agree to continue"; - - // Consent - ViewBag.ConsentText = "I agree to receive communications and with the Privacy Policy"; - - // Benefits - ViewBag.BenefitsTitle = "What you'll receive:"; - ViewBag.DefaultBenefit1 = "Personalized consultation"; - ViewBag.DefaultBenefit2 = "Specialized technical support"; - ViewBag.DefaultBenefit3 = "Results guarantee"; - - // Testimonials - ViewBag.DefaultTestimonialsTitle = "What Our Clients Say"; - ViewBag.DefaultTestimonialsSubtitle = "Over 1000 companies have already transformed their results"; - SetupEnglishTestimonials(); - - // CTA - ViewBag.DefaultCtaTitle = "Ready to Transform Your Business?"; - ViewBag.DefaultCtaSubtitle = "Join over 1000 companies that have already achieved extraordinary results"; - ViewBag.DefaultCtaButtonText = "Start Transformation"; - // Footer - ViewBag.FooterDescription = "Transforming businesses through innovative solutions"; + ViewBag.FooterDescription = "Transforming data through innovative solutions"; ViewBag.FooterMenuTitle = "Links"; ViewBag.FooterLegalTitle = "Legal"; ViewBag.FooterContactTitle = "Contact"; ViewBag.FooterCopyright = "All rights reserved."; ViewBag.FooterMadeWith = "Made with ❤️ in Brazil"; - // Success - ViewBag.SuccessTitle = "Thank You!"; - ViewBag.SuccessMessage = "We received your request. Our team will contact you soon."; - ViewBag.CloseButtonText = "Close"; - - // Thank You Page - ViewBag.NextStepsTitle = "What happens next?"; - ViewBag.Step1Title = "Analysis"; - ViewBag.Step1Description = "Our team will analyze your request"; - ViewBag.Step2Title = "Contact"; - ViewBag.Step2Description = "We'll contact you within 24h"; - ViewBag.Step3Title = "Implementation"; - ViewBag.Step3Description = "We'll start your transformation"; - ViewBag.ContactInfoTitle = "Need to talk to us?"; - ViewBag.BackToHomeText = "Back to Home"; - ViewBag.WhatsAppText = "Chat on WhatsApp"; - ViewBag.RedirectConfirmText = "Would you like to return to the home page?"; - - // Security - ViewBag.SecurityText = "Your data is safe with us"; - - // Time - ViewBag.DaysText = "Days"; - ViewBag.HoursText = "Hours"; - ViewBag.MinutesText = "Min"; - ViewBag.SecondsText = "Sec"; - // Contact info ViewBag.ContactEmail = "contact@yoursite.com"; ViewBag.ContactPhone = "+1 (555) 123-4567"; ViewBag.ContactAddress = "New York, NY"; - ViewBag.TestimonialsCount = "Over 500 five-star reviews"; } protected void SetupSpanishContent() @@ -345,149 +413,18 @@ namespace OnlyOneAccessTemplate.Controllers ViewBag.MenuPrivacy = "Privacidad"; ViewBag.MenuTerms = "Términos"; - // Hero Section - ViewBag.DefaultHeroTitle = "Transforma Tu Negocio con Nuestra Solución"; - ViewBag.DefaultHeroSubtitle = "Aumenta tus ventas hasta un 300% con nuestra metodología probada y soporte especializado."; - ViewBag.DefaultCtaText = "Comenzar Ahora"; - ViewBag.WatchVideoText = "Ver Video"; - - // Features - ViewBag.DefaultFeaturesTitle = "¿Por Qué Elegir Nuestra Solución?"; - ViewBag.DefaultFeaturesSubtitle = "Descubre los beneficios que ya han transformado más de 1000 empresas"; - ViewBag.Feature1Title = "Resultados Rápidos"; - ViewBag.Feature1Description = "Ve los primeros resultados en 30 días"; - ViewBag.Feature2Title = "Soporte 24/7"; - ViewBag.Feature2Description = "Equipo especializado siempre disponible"; - ViewBag.Feature3Title = "Metodología Probada"; - ViewBag.Feature3Description = "Más de 1000 casos de éxito documentados"; - - // Form - ViewBag.FormTitle = "Solicita una Demo Gratuita"; - ViewBag.FormSubtitle = "Completa el formulario y nuestro equipo te contactará"; - ViewBag.NameLabel = "Nombre Completo"; - ViewBag.NamePlaceholder = "Ingresa tu nombre completo"; - ViewBag.EmailLabel = "Correo"; - ViewBag.EmailPlaceholder = "Ingresa tu correo"; - ViewBag.PhoneLabel = "Teléfono"; - ViewBag.PhonePlaceholder = "Ingresa tu teléfono"; - ViewBag.SubmitButtonText = "Solicitar Demo"; - ViewBag.LoadingText = "Enviando..."; - - // Quick Form - ViewBag.QuickFormTitle = "Acceso Rápido"; - ViewBag.QuickSubmitText = "Comenzar Ahora"; - ViewBag.QuickConsentText = "Acepto recibir información por correo"; - - // Validation - ViewBag.RequiredFieldMessage = "Este campo es obligatorio"; - ViewBag.EmailValidationMessage = "Ingresa un correo válido"; - ViewBag.PhoneValidationMessage = "Ingresa un teléfono válido"; - ViewBag.ConsentValidationMessage = "Debes aceptar para continuar"; - - // Consent - ViewBag.ConsentText = "Acepto recibir comunicaciones y la Política de Privacidad"; - - // Benefits - ViewBag.BenefitsTitle = "Lo que recibirás:"; - ViewBag.DefaultBenefit1 = "Consultoría personalizada"; - ViewBag.DefaultBenefit2 = "Soporte técnico especializado"; - ViewBag.DefaultBenefit3 = "Garantía de resultados"; - - // Testimonials - ViewBag.DefaultTestimonialsTitle = "Lo Que Dicen Nuestros Clientes"; - ViewBag.DefaultTestimonialsSubtitle = "Más de 1000 empresas ya han transformado sus resultados"; - SetupSpanishTestimonials(); - - // CTA - ViewBag.DefaultCtaTitle = "¿Listo para Transformar Tu Negocio?"; - ViewBag.DefaultCtaSubtitle = "Únete a más de 1000 empresas que ya han logrado resultados extraordinarios"; - ViewBag.DefaultCtaButtonText = "Comenzar Transformación"; - // Footer - ViewBag.FooterDescription = "Transformando negocios a través de soluciones innovadoras"; + ViewBag.FooterDescription = "Transformando datos a través de soluciones innovadoras"; ViewBag.FooterMenuTitle = "Enlaces"; ViewBag.FooterLegalTitle = "Legal"; ViewBag.FooterContactTitle = "Contacto"; ViewBag.FooterCopyright = "Todos los derechos reservados."; ViewBag.FooterMadeWith = "Hecho con ❤️ en Brasil"; - // Success - ViewBag.SuccessTitle = "¡Gracias!"; - ViewBag.SuccessMessage = "Recibimos tu solicitud. Nuestro equipo te contactará pronto."; - ViewBag.CloseButtonText = "Cerrar"; - - // Thank You Page - ViewBag.NextStepsTitle = "¿Qué pasa ahora?"; - ViewBag.Step1Title = "Análisis"; - ViewBag.Step1Description = "Nuestro equipo analizará tu solicitud"; - ViewBag.Step2Title = "Contacto"; - ViewBag.Step2Description = "Te contactaremos en 24h"; - ViewBag.Step3Title = "Implementación"; - ViewBag.Step3Description = "Comenzaremos tu transformación"; - ViewBag.ContactInfoTitle = "¿Necesitas hablar con nosotros?"; - ViewBag.BackToHomeText = "Volver al Inicio"; - ViewBag.WhatsAppText = "Hablar por WhatsApp"; - ViewBag.RedirectConfirmText = "¿Te gustaría volver a la página principal?"; - - // Security - ViewBag.SecurityText = "Tus datos están seguros con nosotros"; - - // Time - ViewBag.DaysText = "Días"; - ViewBag.HoursText = "Horas"; - ViewBag.MinutesText = "Min"; - ViewBag.SecondsText = "Seg"; - // Contact info ViewBag.ContactEmail = "contacto@tusitioweb.com"; ViewBag.ContactPhone = "+34 123 456 789"; ViewBag.ContactAddress = "Madrid, España"; - ViewBag.TestimonialsCount = "Más de 500 reseñas de 5 estrellas"; - } - - protected void SetupPortugueseTestimonials() - { - ViewBag.Testimonial1Quote = "Aumentamos nossas vendas em 250% em apenas 3 meses. Incrível!"; - ViewBag.Testimonial1Name = "Maria Silva"; - ViewBag.Testimonial1Position = "CEO, TechStart"; - - ViewBag.Testimonial2Quote = "O suporte é excepcional. Sempre prontos a ajudar quando precisamos."; - ViewBag.Testimonial2Name = "João Santos"; - ViewBag.Testimonial2Position = "Diretor, InovaCorp"; - - ViewBag.Testimonial3Quote = "A metodologia realmente funciona. Resultados visíveis desde o primeiro mês."; - ViewBag.Testimonial3Name = "Ana Costa"; - ViewBag.Testimonial3Position = "Gerente, GrowBiz"; - } - - protected void SetupEnglishTestimonials() - { - ViewBag.Testimonial1Quote = "We increased our sales by 250% in just 3 months. Amazing!"; - ViewBag.Testimonial1Name = "Mary Johnson"; - ViewBag.Testimonial1Position = "CEO, TechStart"; - - ViewBag.Testimonial2Quote = "The support is exceptional. Always ready to help when we need it."; - ViewBag.Testimonial2Name = "John Smith"; - ViewBag.Testimonial2Position = "Director, InovaCorp"; - - ViewBag.Testimonial3Quote = "The methodology really works. Visible results from the first month."; - ViewBag.Testimonial3Name = "Sarah Davis"; - ViewBag.Testimonial3Position = "Manager, GrowBiz"; - } - - protected void SetupSpanishTestimonials() - { - ViewBag.Testimonial1Quote = "Aumentamos nuestras ventas un 250% en solo 3 meses. ¡Increíble!"; - ViewBag.Testimonial1Name = "María García"; - ViewBag.Testimonial1Position = "CEO, TechStart"; - - ViewBag.Testimonial2Quote = "El soporte es excepcional. Siempre listos para ayudar cuando lo necesitamos."; - ViewBag.Testimonial2Name = "Carlos López"; - ViewBag.Testimonial2Position = "Director, InovaCorp"; - - ViewBag.Testimonial3Quote = "La metodología realmente funciona. Resultados visibles desde el primer mes."; - ViewBag.Testimonial3Name = "Ana Rodríguez"; - ViewBag.Testimonial3Position = "Gerente, GrowBiz"; } protected void SetupHreflangUrls(string currentUrl, string currentLanguage) @@ -523,4 +460,4 @@ namespace OnlyOneAccessTemplate.Controllers } } } -} +} \ No newline at end of file diff --git a/OnlyOneAccessTemplate/Controllers/ConverterController.cs b/OnlyOneAccessTemplate/Controllers/ConverterController.cs new file mode 100644 index 0000000..2f25fcc --- /dev/null +++ b/OnlyOneAccessTemplate/Controllers/ConverterController.cs @@ -0,0 +1,129 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; +using OnlyOneAccessTemplate.Services.OnlyOneAccessTemplate.Services; +using OnlyOneAccessTemplate.Services; +using OnlyOneAccessTemplate.Models; + +namespace OnlyOneAccessTemplate.Controllers +{ + public class ConverterController : BaseController + { + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + private readonly Dictionary _converterTypes; + + public ConverterController( + ISiteConfigurationService siteConfig, + ILanguageService languageService, + ISeoService seoService, + IMemoryCache cache, + IConfiguration configuration, + IServiceProvider serviceProvider, + ILogger logger + ) + : base(siteConfig, languageService, seoService, cache, configuration) + { + _serviceProvider = serviceProvider; + this._logger = logger; + + // Registrar tipos de conversores disponíveis + _converterTypes = new Dictionary + { + ["text-case"] = typeof(TextCaseConverterService), + ["csv-json"] = typeof(CsvToJsonConverterService), + ["image-ocr"] = typeof(ImageToTextConverterService) + // Adicionar novos conversores aqui + }; + } + + [HttpPost("api/convert/{converterType}")] + public async Task Convert(string converterType, [FromForm] ConversionRequestDto requestDto) + { + try + { + if (!_converterTypes.ContainsKey(converterType)) + { + return BadRequest(new { success = false, message = "Conversor não encontrado" }); + } + + var converterService = (IConverterService)_serviceProvider.GetRequiredService(_converterTypes[converterType]); + + var request = new ConversionRequest( + Language: requestDto.Language ?? GetCurrentLanguage(), + InputType: requestDto.InputType, + TextInput: requestDto.TextInput, + FileInput: requestDto.FileInput, + UrlInput: requestDto.UrlInput, + Options: requestDto.Options + ); + + // Validar entrada + if (!await converterService.ValidateInputAsync(request)) + { + return BadRequest(new { success = false, message = "Entrada inválida" }); + } + + // Executar conversão + var result = await converterService.ConvertAsync(request); + + if (!result.Success) + { + return BadRequest(new { success = false, message = result.ErrorMessage }); + } + + // Retornar resultado baseado no tipo de saída + if (!string.IsNullOrEmpty(result.OutputText)) + { + return Ok(new + { + success = true, + outputText = result.OutputText, + metadata = result.Metadata + }); + } + else if (result.OutputFile != null) + { + return File(result.OutputFile, result.OutputMimeType ?? "application/octet-stream", + result.OutputFileName ?? "converted_file"); + } + else + { + return Ok(new + { + success = true, + previewHtml = result.PreviewHtml, + metadata = result.Metadata + }); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Erro na conversão {ConverterType}", converterType); + return StatusCode(500, new { success = false, message = "Erro interno do servidor" }); + } + } + + [HttpGet("config/{converterType}")] + public IActionResult GetConverterConfig(string converterType) + { + try + { + if (!_converterTypes.ContainsKey(converterType)) + { + return NotFound(new { success = false, message = "Conversor não encontrado" }); + } + + var converterService = (IConverterService)_serviceProvider.GetRequiredService(_converterTypes[converterType]); + var language = GetCurrentLanguage(); + var config = converterService.GetConfiguration(language); + + return Ok(new { success = true, config }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Erro ao buscar configuração do conversor {ConverterType}", converterType); + return StatusCode(500, new { success = false, message = "Erro interno do servidor" }); + } + } + } +} diff --git a/OnlyOneAccessTemplate/Models/ConversionRequestDto.cs b/OnlyOneAccessTemplate/Models/ConversionRequestDto.cs new file mode 100644 index 0000000..5e21aed --- /dev/null +++ b/OnlyOneAccessTemplate/Models/ConversionRequestDto.cs @@ -0,0 +1,12 @@ +namespace OnlyOneAccessTemplate.Models +{ + public class ConversionRequestDto + { + public string? Language { get; set; } + public string InputType { get; set; } = "text"; + public string? TextInput { get; set; } + public IFormFile? FileInput { get; set; } + public string? UrlInput { get; set; } + public Dictionary? Options { get; set; } + } +} diff --git a/OnlyOneAccessTemplate/Models/FormField.cs b/OnlyOneAccessTemplate/Models/FormField.cs index b4cbb3b..0cc9e97 100644 --- a/OnlyOneAccessTemplate/Models/FormField.cs +++ b/OnlyOneAccessTemplate/Models/FormField.cs @@ -9,7 +9,6 @@ public bool Required { get; init; } = false; public string ValidationRegex { get; init; } = string.Empty; public int Order { get; init; } = 0; - - public Dictionary> Properties { get; set; } + public Dictionary Properties { get; init; } = new(); } } diff --git a/OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj b/OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj index 6a43939..71e9333 100644 --- a/OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj +++ b/OnlyOneAccessTemplate/OnlyOneAccessTemplate.csproj @@ -6,6 +6,10 @@ enable + + + + @@ -15,4 +19,16 @@ + + + + + + <_ContentIncludedByDefault Remove="Views\Shared\_AdvancedOptions.cshtml" /> + + + + + + diff --git a/OnlyOneAccessTemplate/Program.cs b/OnlyOneAccessTemplate/Program.cs index ab3765d..a89f901 100644 --- a/OnlyOneAccessTemplate/Program.cs +++ b/OnlyOneAccessTemplate/Program.cs @@ -35,8 +35,17 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +// Converter Services - Registrar todos os conversores disponveis +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Adicione aqui novos conversores conforme necessrio: +// builder.Services.AddScoped(); + // HttpClient for external calls builder.Services.AddHttpClient(); +builder.Services.AddHttpClient(); // Response Compression builder.Services.AddResponseCompression(options => @@ -50,6 +59,11 @@ builder.Services.AddResponseCaching(); // Memory Cache builder.Services.AddMemoryCache(); +// Logging +builder.Logging.ClearProviders(); +builder.Logging.AddConsole(); +builder.Logging.AddDebug(); + var app = builder.Build(); // Configure the HTTP request pipeline @@ -72,6 +86,16 @@ app.UseResponseCaching(); app.UseRouting(); // Custom routing for multilingual support +app.MapControllerRoute( + name: "converter-api", + pattern: "converter/api/{action}/{converterType?}", + defaults: new { controller = "Converter" }); + +app.MapControllerRoute( + name: "converter-config", + pattern: "converter/config/{converterType}", + defaults: new { controller = "Converter", action = "GetConverterConfig" }); + app.MapControllerRoute( name: "default-pt", pattern: "{controller=Home}/{action=Index}/{id?}"); @@ -101,4 +125,34 @@ app.MapGet("/robots.txt", async (ISiteConfigurationService siteConfig) => return Results.Content(robots, "text/plain"); }); +// Health check endpoint +app.MapGet("/health", () => Results.Ok(new { status = "healthy", timestamp = DateTime.UtcNow })); + +// Initialize default data on startup (only in development) +if (app.Environment.IsDevelopment()) +{ + using var scope = app.Services.CreateScope(); + var siteConfigService = scope.ServiceProvider.GetRequiredService(); + var logger = scope.ServiceProvider.GetRequiredService>(); + + try + { + // Verificar se j existem configuraes + var languages = new[] { "pt", "en", "es" }; + foreach (var lang in languages) + { + var configExists = await siteConfigService.ConfigurationExistsAsync(lang); + if (!configExists) + { + logger.LogInformation("Criando configurao padro para idioma: {Language}", lang); + _ = await siteConfigService.GetConfigurationAsync(lang); // Isso criar a configurao padro + } + } + } + catch (Exception ex) + { + logger.LogError(ex, "Erro ao inicializar dados padro"); + } +} + app.Run(); \ No newline at end of file diff --git a/OnlyOneAccessTemplate/Services/ConverterService.cs b/OnlyOneAccessTemplate/Services/ConverterService.cs new file mode 100644 index 0000000..711c951 --- /dev/null +++ b/OnlyOneAccessTemplate/Services/ConverterService.cs @@ -0,0 +1,206 @@ +using global::OnlyOneAccessTemplate.Controllers; +using global::OnlyOneAccessTemplate.Services.OnlyOneAccessTemplate.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; + +namespace OnlyOneAccessTemplate.Services +{ + + namespace OnlyOneAccessTemplate.Services + { + // Interface principal para conversores + public interface IConverterService + { + string ConverterType { get; } + string ConverterName { get; } + Task ConvertAsync(ConversionRequest request); + Task ValidateInputAsync(ConversionRequest request); + ConverterConfiguration GetConfiguration(string language); + } + + // Configuração específica do conversor + public record ConverterConfiguration + { + public string ConverterType { get; init; } = "text"; // "text", "file", "url" + public string OutputType { get; init; } = "text"; // "text", "download", "preview" + public string[] AcceptedFileTypes { get; init; } = Array.Empty(); + public int MaxFileSize { get; init; } = 10 * 1024 * 1024; // 10MB + public bool HasAdvancedOptions { get; init; } = false; + public bool AllowShare { get; init; } = false; + public Dictionary LocalizedTexts { get; init; } = new(); + } + + // Request de conversão + public record ConversionRequest( + string Language, + string InputType, // "text", "file", "url" + string? TextInput = null, + IFormFile? FileInput = null, + string? UrlInput = null, + Dictionary? Options = null + ); + + // Resultado da conversão + public record ConversionResult( + bool Success, + string? OutputText = null, + byte[]? OutputFile = null, + string? OutputFileName = null, + string? OutputMimeType = null, + string? PreviewHtml = null, + string? ErrorMessage = null, + Dictionary? Metadata = null + ); + + // Serviço base para conversores + public abstract class BaseConverterService : IConverterService + { + protected readonly ILogger _logger; + protected readonly IConfiguration _configuration; + + public abstract string ConverterType { get; } + public abstract string ConverterName { get; } + + protected BaseConverterService(ILogger logger, IConfiguration configuration) + { + _logger = logger; + _configuration = configuration; + } + + public abstract Task ConvertAsync(ConversionRequest request); + + public virtual async Task ValidateInputAsync(ConversionRequest request) + { + var config = GetConfiguration(request.Language); + + // Validação básica baseada no tipo + switch (request.InputType) + { + case "text": + return !string.IsNullOrWhiteSpace(request.TextInput); + + case "file": + if (request.FileInput == null || request.FileInput.Length == 0) + return false; + + // Verificar tamanho do arquivo + if (request.FileInput.Length > config.MaxFileSize) + return false; + + // Verificar tipo do arquivo se especificado + if (config.AcceptedFileTypes.Length > 0) + { + var extension = Path.GetExtension(request.FileInput.FileName); + return config.AcceptedFileTypes.Contains(extension, StringComparer.OrdinalIgnoreCase); + } + return true; + + case "url": + return Uri.TryCreate(request.UrlInput, UriKind.Absolute, out _); + + default: + return false; + } + } + + public abstract ConverterConfiguration GetConfiguration(string language); + + protected virtual Dictionary GetLocalizedTexts(string language) + { + return language switch + { + "en" => GetEnglishTexts(), + "es" => GetSpanishTexts(), + _ => GetPortugueseTexts() + }; + } + + protected virtual Dictionary GetPortugueseTexts() + { + return new Dictionary + { + ["ConverterTitle"] = "CONVERSOR ONLINE", + ["ConverterDescription"] = "Converta seus arquivos de forma rápida e segura", + ["Step1Title"] = "Upload", + ["Step1Description"] = "Selecione ou cole seu conteúdo", + ["Step2Title"] = "Configurar", + ["Step2Description"] = "Escolha as opções de conversão", + ["Step3Title"] = "Converter", + ["Step3Description"] = "Baixe o resultado", + ["InputLabel"] = "Entrada", + ["OutputLabel"] = "Resultado", + ["SelectFileText"] = "Selecionar Arquivo", + ["ConvertButtonText"] = "Converter", + ["LoadingText"] = "Processando...", + ["ProcessingText"] = "Convertendo seu arquivo...", + ["CopyButtonText"] = "Copiar", + ["ClearButtonText"] = "Limpar", + ["ShareButtonText"] = "Compartilhar", + ["CopiedText"] = "Copiado!", + ["DownloadButtonText"] = "Baixar", + ["DownloadReadyText"] = "Seu arquivo está pronto!", + ["SecurityText"] = "Seus dados estão seguros conosco", + ["DefaultErrorMessage"] = "Erro ao processar. Tente novamente." + }; + } + + protected virtual Dictionary GetEnglishTexts() + { + return new Dictionary + { + ["ConverterTitle"] = "ONLINE CONVERTER", + ["ConverterDescription"] = "Convert your files quickly and securely", + ["Step1Title"] = "Upload", + ["Step1Description"] = "Select or paste your content", + ["Step2Title"] = "Configure", + ["Step2Description"] = "Choose conversion options", + ["Step3Title"] = "Convert", + ["Step3Description"] = "Download the result", + ["InputLabel"] = "Input", + ["OutputLabel"] = "Output", + ["SelectFileText"] = "Select File", + ["ConvertButtonText"] = "Convert", + ["LoadingText"] = "Processing...", + ["ProcessingText"] = "Converting your file...", + ["CopyButtonText"] = "Copy", + ["ClearButtonText"] = "Clear", + ["ShareButtonText"] = "Share", + ["CopiedText"] = "Copied!", + ["DownloadButtonText"] = "Download", + ["DownloadReadyText"] = "Your file is ready!", + ["SecurityText"] = "Your data is safe with us", + ["DefaultErrorMessage"] = "Processing error. Please try again." + }; + } + + protected virtual Dictionary GetSpanishTexts() + { + return new Dictionary + { + ["ConverterTitle"] = "CONVERTIDOR EN LÍNEA", + ["ConverterDescription"] = "Convierte tus archivos de forma rápida y segura", + ["Step1Title"] = "Subir", + ["Step1Description"] = "Selecciona o pega tu contenido", + ["Step2Title"] = "Configurar", + ["Step2Description"] = "Elige las opciones de conversión", + ["Step3Title"] = "Convertir", + ["Step3Description"] = "Descarga el resultado", + ["InputLabel"] = "Entrada", + ["OutputLabel"] = "Resultado", + ["SelectFileText"] = "Seleccionar Archivo", + ["ConvertButtonText"] = "Convertir", + ["LoadingText"] = "Procesando...", + ["ProcessingText"] = "Convirtiendo tu archivo...", + ["CopyButtonText"] = "Copiar", + ["ClearButtonText"] = "Limpiar", + ["ShareButtonText"] = "Compartir", + ["CopiedText"] = "¡Copiado!", + ["DownloadButtonText"] = "Descargar", + ["DownloadReadyText"] = "¡Tu archivo está listo!", + ["SecurityText"] = "Tus datos están seguros con nosotros", + ["DefaultErrorMessage"] = "Error al procesar. Inténtalo de nuevo." + }; + } + } + } +} diff --git a/OnlyOneAccessTemplate/Services/CsvToJsonConverterService.cs b/OnlyOneAccessTemplate/Services/CsvToJsonConverterService.cs new file mode 100644 index 0000000..4076ddf --- /dev/null +++ b/OnlyOneAccessTemplate/Services/CsvToJsonConverterService.cs @@ -0,0 +1,114 @@ +using OnlyOneAccessTemplate.Services.OnlyOneAccessTemplate.Services; + +namespace OnlyOneAccessTemplate.Services +{ + public class CsvToJsonConverterService : BaseConverterService + { + public override string ConverterType => "csv-json"; + public override string ConverterName => "CSV to JSON Converter"; + + public CsvToJsonConverterService(ILogger logger, IConfiguration configuration) + : base(logger, configuration) { } + + public override async Task ConvertAsync(ConversionRequest request) + { + try + { + string csvContent; + + if (request.InputType == "file" && request.FileInput != null) + { + using var reader = new StreamReader(request.FileInput.OpenReadStream()); + csvContent = await reader.ReadToEndAsync(); + } + else if (request.InputType == "text" && !string.IsNullOrEmpty(request.TextInput)) + { + csvContent = request.TextInput; + } + else + { + return new ConversionResult(false, ErrorMessage: "Nenhum conteúdo CSV fornecido"); + } + + var lines = csvContent.Split('\n', StringSplitOptions.RemoveEmptyEntries); + if (lines.Length < 2) + { + return new ConversionResult(false, ErrorMessage: "CSV deve ter pelo menos cabeçalho e uma linha de dados"); + } + + var headers = lines[0].Split(',').Select(h => h.Trim().Trim('"')).ToArray(); + var jsonObjects = new List>(); + + for (int i = 1; i < lines.Length; i++) + { + var values = lines[i].Split(',').Select(v => v.Trim().Trim('"')).ToArray(); + var obj = new Dictionary(); + + for (int j = 0; j < Math.Min(headers.Length, values.Length); j++) + { + obj[headers[j]] = values[j]; + } + + jsonObjects.Add(obj); + } + + var jsonResult = System.Text.Json.JsonSerializer.Serialize(jsonObjects, new System.Text.Json.JsonSerializerOptions + { + WriteIndented = true, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }); + + return new ConversionResult(true, OutputText: jsonResult); + } + catch (Exception ex) + { + _logger.LogError(ex, "Erro na conversão CSV para JSON"); + return new ConversionResult(false, ErrorMessage: "Erro ao converter CSV para JSON"); + } + } + + public override ConverterConfiguration GetConfiguration(string language) + { + var texts = GetLocalizedTexts(language); + texts["ConverterTitle"] = language switch + { + "en" => "CSV TO JSON CONVERTER", + "es" => "CONVERTIDOR CSV A JSON", + _ => "CONVERSOR CSV PARA JSON" + }; + + texts["ConverterDescription"] = language switch + { + "en" => "Convert CSV files to JSON format quickly and easily", + "es" => "Convierte archivos CSV a formato JSON de forma rápida y fácil", + _ => "Converta arquivos CSV para formato JSON de forma rápida e fácil" + }; + + texts["InputPlaceholder"] = language switch + { + "en" => "Paste your CSV content here or upload a file...", + "es" => "Pega tu contenido CSV aquí o sube un archivo...", + _ => "Cole seu conteúdo CSV aqui ou faça upload de um arquivo..." + }; + + texts["FileHelpText"] = language switch + { + "en" => "Max file size: 10MB. Supported formats: .csv, .txt", + "es" => "Tamaño máximo: 10MB. Formatos soportados: .csv, .txt", + _ => "Tamanho máximo: 10MB. Formatos suportados: .csv, .txt" + }; + + return new ConverterConfiguration + { + ConverterType = "text", // Aceita tanto texto quanto arquivo + OutputType = "text", + AcceptedFileTypes = new[] { ".csv", ".txt" }, + MaxFileSize = 10 * 1024 * 1024, + HasAdvancedOptions = false, + AllowShare = true, + LocalizedTexts = texts + }; + } + } + +} diff --git a/OnlyOneAccessTemplate/Services/ImageToTextConverterService.cs b/OnlyOneAccessTemplate/Services/ImageToTextConverterService.cs new file mode 100644 index 0000000..760613d --- /dev/null +++ b/OnlyOneAccessTemplate/Services/ImageToTextConverterService.cs @@ -0,0 +1,94 @@ +using OnlyOneAccessTemplate.Services.OnlyOneAccessTemplate.Services; + +namespace OnlyOneAccessTemplate.Services +{ + public class ImageToTextConverterService : BaseConverterService + { + private readonly HttpClient _httpClient; + + public override string ConverterType => "image-ocr"; + public override string ConverterName => "Image to Text (OCR)"; + + public ImageToTextConverterService(ILogger logger, + IConfiguration configuration, HttpClient httpClient) + : base(logger, configuration) + { + _httpClient = httpClient; + } + + public override async Task ConvertAsync(ConversionRequest request) + { + try + { + if (request.FileInput == null) + { + return new ConversionResult(false, ErrorMessage: "Nenhuma imagem fornecida"); + } + + // Aqui você integraria com um serviço de OCR real como: + // - Azure Computer Vision + // - Google Cloud Vision + // - AWS Textract + // - Tesseract local + + // Por agora, simular processamento + await Task.Delay(2000); // Simular processamento + + // Exemplo de resultado simulado + var extractedText = $"Texto extraído da imagem: {request.FileInput.FileName}\n\n" + + "Este é um exemplo de texto que seria extraído da imagem usando OCR.\n" + + "Em uma implementação real, aqui estaria o texto real da imagem."; + + return new ConversionResult(true, OutputText: extractedText); + } + catch (Exception ex) + { + _logger.LogError(ex, "Erro na conversão de imagem para texto"); + return new ConversionResult(false, ErrorMessage: "Erro ao processar imagem"); + } + } + + public override ConverterConfiguration GetConfiguration(string language) + { + var texts = GetLocalizedTexts(language); + texts["ConverterTitle"] = language switch + { + "en" => "IMAGE TO TEXT CONVERTER - OCR ONLINE", + "es" => "CONVERTIDOR DE IMAGEN A TEXTO - OCR EN LÍNEA", + _ => "CONVERSOR DE IMAGEM PARA TEXTO - OCR ONLINE" + }; + + texts["ConverterDescription"] = language switch + { + "en" => "Extract text from images using Optical Character Recognition technology", + "es" => "Extrae texto de imágenes usando tecnología de Reconocimiento Óptico de Caracteres", + _ => "Extraia texto de imagens usando tecnologia de Reconhecimento Óptico de Caracteres" + }; + + texts["SelectFileText"] = language switch + { + "en" => "SELECT IMAGE", + "es" => "SELECCIONAR IMAGEN", + _ => "SELECIONAR IMAGEM" + }; + + texts["FileHelpText"] = language switch + { + "en" => "Max file size: 15MB. Supported formats: JPG, PNG, PDF, TIFF", + "es" => "Tamaño máximo: 15MB. Formatos soportados: JPG, PNG, PDF, TIFF", + _ => "Tamanho máximo: 15MB. Formatos suportados: JPG, PNG, PDF, TIFF" + }; + + return new ConverterConfiguration + { + ConverterType = "file", + OutputType = "text", + AcceptedFileTypes = new[] { ".jpg", ".jpeg", ".png", ".pdf", ".tiff", ".bmp" }, + MaxFileSize = 15 * 1024 * 1024, + HasAdvancedOptions = true, + AllowShare = false, // OCR pode conter informações sensíveis + LocalizedTexts = texts + }; + } + } +} diff --git a/OnlyOneAccessTemplate/Services/TextCaseConverterService.cs b/OnlyOneAccessTemplate/Services/TextCaseConverterService.cs new file mode 100644 index 0000000..bcee31c --- /dev/null +++ b/OnlyOneAccessTemplate/Services/TextCaseConverterService.cs @@ -0,0 +1,84 @@ +using OnlyOneAccessTemplate.Services.OnlyOneAccessTemplate.Services; + +namespace OnlyOneAccessTemplate.Services +{ + public class TextCaseConverterService : BaseConverterService + { + public override string ConverterType => "text-case"; + public override string ConverterName => "Text Case Converter"; + + public TextCaseConverterService(ILogger logger, IConfiguration configuration) + : base(logger, configuration) { } + + public override async Task ConvertAsync(ConversionRequest request) + { + try + { + if (string.IsNullOrEmpty(request.TextInput)) + { + return new ConversionResult(false, ErrorMessage: "Texto não fornecido"); + } + + var caseType = request.Options?.GetValueOrDefault("caseType", "upper")?.ToString() ?? "upper"; + + var result = caseType switch + { + "upper" => request.TextInput.ToUpperInvariant(), + "lower" => request.TextInput.ToLowerInvariant(), + "title" => System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(request.TextInput.ToLower()), + "sentence" => char.ToUpper(request.TextInput[0]) + request.TextInput.Substring(1).ToLower(), + _ => request.TextInput + }; + + return new ConversionResult(true, OutputText: result); + } + catch (Exception ex) + { + _logger.LogError(ex, "Erro na conversão de texto"); + return new ConversionResult(false, ErrorMessage: "Erro ao converter texto"); + } + } + + public override ConverterConfiguration GetConfiguration(string language) + { + var texts = GetLocalizedTexts(language); + texts["ConverterTitle"] = language switch + { + "en" => "TEXT CASE CONVERTER", + "es" => "CONVERTIDOR DE MAYÚSCULAS Y MINÚSCULAS", + _ => "CONVERSOR DE MAIÚSCULAS E MINÚSCULAS" + }; + + texts["ConverterDescription"] = language switch + { + "en" => "Convert text between uppercase, lowercase, title case and sentence case", + "es" => "Convierte texto entre mayúsculas, minúsculas, título y oración", + _ => "Converta texto entre maiúsculas, minúsculas, título e primeira maiúscula" + }; + + texts["InputPlaceholder"] = language switch + { + "en" => "Enter your text here...", + "es" => "Ingresa tu texto aquí...", + _ => "Digite seu texto aqui..." + }; + + texts["OutputPlaceholder"] = language switch + { + "en" => "Converted text will appear here...", + "es" => "El texto convertido aparecerá aquí...", + _ => "O texto convertido aparecerá aqui..." + }; + + return new ConverterConfiguration + { + ConverterType = "text", + OutputType = "text", + HasAdvancedOptions = true, + AllowShare = true, + LocalizedTexts = texts + }; + } + } + +} diff --git a/OnlyOneAccessTemplate/Views/Home/Index.cshtml b/OnlyOneAccessTemplate/Views/Home/Index.cshtml index 66d63e7..3fef93a 100644 --- a/OnlyOneAccessTemplate/Views/Home/Index.cshtml +++ b/OnlyOneAccessTemplate/Views/Home/Index.cshtml @@ -1,212 +1,255 @@ -@model OnlyOneAccessTemplate.Models.PageContent +@model PageContent; + @{ - ViewData["Title"] = Model?.MetaTitle ?? Model?.Title ?? ViewBag.Title; + ViewData["Title"] = ViewBag.Title ?? "Conversor Online"; Layout = "~/Views/Shared/_Layout.cshtml"; } -@section Head { - - - - - - -} - - -@{ - var heroBlock = Model?.Blocks?.FirstOrDefault(b => b.Type == "hero"); -} -@await Html.PartialAsync("Components/_Hero", heroBlock) - - -@{ - var featuresBlock = Model?.Blocks?.FirstOrDefault(b => b.Type == "features"); -} -@await Html.PartialAsync("Components/_Features", featuresBlock) - - -@if (Model?.Blocks?.Any(b => b.Type == "benefits") == true) -{ - var benefitsBlock = Model.Blocks.First(b => b.Type == "benefits"); -
-
-
-
-

- @benefitsBlock.Title -

-

- @benefitsBlock.Content + +

+
+
+
+ +
+

+ @(ViewBag.ConverterTitle ?? "CONVERSOR ONLINE") +

+

+ @(ViewBag.ConverterDescription ?? "Converta seus arquivos de forma rápida e segura")

-
-
-
-
-
- -
-
-
Resultado Garantido
-

Metodologia comprovada com mais de 1000 casos de sucesso documentados.

-
-
- -
-
- -
-
-
Implementação Rápida
-

Veja os primeiros resultados em até 30 dias após a implementação.

-
-
- -
-
- -
-
-
Suporte Especializado
-

Equipe dedicada para garantir o seu sucesso em cada etapa.

-
-
-
- -
- @if (!string.IsNullOrEmpty(benefitsBlock.ImageUrl)) - { - @benefitsBlock.Title - } - else - { -
-
-
-
-

1000+

- Clientes Atendidos -
+ +
+
+ +
+
+
+ 1 +
@(ViewBag.Step1Title ?? "Upload")
+ @(ViewBag.Step1Description ?? "Selecione seu arquivo")
-
-
-

95%

- Taxa de Sucesso -
+
+
+
+ 2 +
@(ViewBag.Step2Title ?? "Processar")
+ @(ViewBag.Step2Description ?? "Aguarde o processamento")
-
-
-

24h

- Suporte -
+
+
+
+ 3 +
@(ViewBag.Step3Title ?? "Download")
+ @(ViewBag.Step3Description ?? "Baixe o resultado")
+ + +
+ @await Html.PartialAsync("_ConverterWidget") +
+ + +
+
+
+ + @(ViewBag.SecurityText ?? "Seus dados estão seguros") +
+
+
+
+ + @(ViewBag.FileInfoText ?? "Processamento rápido e seguro") +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+

@(ViewBag.BenefitsTitle ?? "Por Que Usar Nossa Ferramenta?")

+

@(ViewBag.BenefitsSubtitle ?? "Descubra os benefícios de nossa solução")

+
+
+
+ @{ + bool hasFeatureBlocks = false; + if (Model != null && Model.Blocks != null) + { + var featureBlocks = Model.Blocks.Where(b => b.Type == "features").ToList(); + if (featureBlocks.Any()) + { + hasFeatureBlocks = true; + var firstFeatureBlock = featureBlocks.First(); + if (firstFeatureBlock.Properties != null && firstFeatureBlock.Properties.ContainsKey("feature_list")) + { + var featureList = firstFeatureBlock.Properties["feature_list"] as System.Collections.IEnumerable; + if (featureList != null) + { + foreach (var featureObj in featureList) + { + var featureDict = featureObj as Dictionary; + if (featureDict != null) + { +
+
+
+ +
+
@(featureDict.GetValueOrDefault("title", "Funcionalidade"))
+ @(featureDict.GetValueOrDefault("description", "Descrição da funcionalidade")) +
+
+ } + } + } + } } + } + } + + @if (!hasFeatureBlocks) + { + +
+
+
+ +
+
@(ViewBag.Feature1Title ?? "Rápido e Fácil")
+ @(ViewBag.Feature1Description ?? "Conversão instantânea") +
+
+
+
+
+ +
+
@(ViewBag.Feature2Title ?? "Seguro")
+ @(ViewBag.Feature2Description ?? "Dados protegidos") +
+
+
+
+
+ +
+
@(ViewBag.Feature3Title ?? "Confiável")
+ @(ViewBag.Feature3Description ?? "Resultados precisos") +
+
+
+
+
+ +
+
Rápido
+ Conversão em segundos +
+
+ } +
+
+
+ + +@{ + bool hasTestimonialBlocks = false; + if (Model != null && Model.Blocks != null) + { + var testimonialBlocks = Model.Blocks.Where(b => b.Type == "testimonials").ToList(); + if (testimonialBlocks.Any()) + { + hasTestimonialBlocks = true; + } + } +} + +@if (hasTestimonialBlocks) +{ +
+
+
+
+

@(ViewBag.DefaultTestimonialsTitle ?? "O Que Nossos Clientes Dizem")

+

@(ViewBag.TestimonialsCount ?? "Avaliações positivas")

+
+
+
+
+
+
+

"@(ViewBag.Testimonial1Quote ?? "Excelente ferramenta!")"

+
@(ViewBag.Testimonial1Name ?? "Cliente Satisfeito")
+ @(ViewBag.Testimonial1Position ?? "Usuário") +
+
+
+
+
+
+

"@(ViewBag.Testimonial2Quote ?? "Muito útil e fácil de usar!")"

+
@(ViewBag.Testimonial2Name ?? "Outro Cliente")
+ @(ViewBag.Testimonial2Position ?? "Usuário") +
+
+
+
+
+
+

"@(ViewBag.Testimonial3Quote ?? "Recomendo para todos!")"

+
@(ViewBag.Testimonial3Name ?? "Mais um Cliente")
+ @(ViewBag.Testimonial3Position ?? "Usuário") +
+
} - -@{ - var testimonialsBlock = Model?.Blocks?.FirstOrDefault(b => b.Type == "testimonials"); -} -@await Html.PartialAsync("Components/_Testimonials", testimonialsBlock) - - -@{ - var conversionConfig = ViewBag.ConversionConfig as OnlyOneAccessTemplate.Models.ConversionConfig; -} -@await Html.PartialAsync("Components/_ConversionForm", conversionConfig) - - -@{ - var ctaBlock = Model?.Blocks?.FirstOrDefault(b => b.Type == "cta"); -} -@await Html.PartialAsync("Components/_CTA", ctaBlock) + +
+
+
+
+

@(ViewBag.FinalCtaTitle ?? "Pronto para Converter?")

+

@(ViewBag.FinalCtaSubtitle ?? "Use nossa ferramenta gratuita agora mesmo")

+ + @(ViewBag.FinalCtaButtonText ?? "Começar Conversão") + +
+
+
+
+ @section Scripts { - - - + + @{ + var converterType = ViewBag.ConverterType ?? "generic"; + var jsFileName = $"~/js/converters/{converterType.ToString().ToLower()}-converter.js"; + } + } \ No newline at end of file diff --git a/OnlyOneAccessTemplate/Views/Shared/_AdvancedOptions.cshtml b/OnlyOneAccessTemplate/Views/Shared/_AdvancedOptions.cshtml new file mode 100644 index 0000000..04b0239 --- /dev/null +++ b/OnlyOneAccessTemplate/Views/Shared/_AdvancedOptions.cshtml @@ -0,0 +1,202 @@ +@* Views/Shared/_AdvancedOptions.cshtml *@ + +
+ @{ + var converterType = ViewBag.ConverterType?.ToString() ?? "text"; + } + + @if (converterType == "text-case") + { + +
+
+ + +
Escolha como você quer converter o texto
+
+
+ +
+ + +
+
+ + +
+
+
+ } + else if (converterType == "csv-json") + { + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ } + else if (converterType == "image-ocr") + { + +
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ } + else if (converterType == "json-csv") + { + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ } + else + { + +
+
+ + +
+
+ + +
+
+ } + + +
+
+
+ + +
+
+
+
+ + \ No newline at end of file diff --git a/OnlyOneAccessTemplate/Views/Shared/_ConverterWidget.cshtml b/OnlyOneAccessTemplate/Views/Shared/_ConverterWidget.cshtml new file mode 100644 index 0000000..f54b686 --- /dev/null +++ b/OnlyOneAccessTemplate/Views/Shared/_ConverterWidget.cshtml @@ -0,0 +1,270 @@ +@* Views/Shared/_ConverterWidget.cshtml *@ + + +
+
+
+ +
+
+ + + + @if (ViewBag.ConverterType == "file") + { +
+ +
+ +

+ +

+ @ViewBag.FileHelpText + +
+
+ } + + + @if (ViewBag.ConverterType == "text") + { + +
@ViewBag.InputHelpText
+ } + + + @if (ViewBag.ConverterType == "url") + { + +
@ViewBag.InputHelpText
+ } +
+ + + @if (ViewBag.HasAdvancedOptions == true) + { +
+ +
+ @{ + try + { + await Html.RenderPartialAsync("_AdvancedOptions"); + } + catch + { + +
+ Opções avançadas não disponíveis para este conversor. +
+ } + } +
+
+ } +
+ + +
+
+ + + + + + +
+ @if (ViewBag.OutputType == "text") + { + + } + else if (ViewBag.OutputType == "download") + { + + } + else if (ViewBag.OutputType == "preview") + { +
+
+ +

@ViewBag.PreviewPlaceholder

+
+
+ } +
+ + + + + + +
+
+
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/OnlyOneAccessTemplate/Views/Shared/_TestimonialsSection.cshtml b/OnlyOneAccessTemplate/Views/Shared/_TestimonialsSection.cshtml new file mode 100644 index 0000000..7844f5f --- /dev/null +++ b/OnlyOneAccessTemplate/Views/Shared/_TestimonialsSection.cshtml @@ -0,0 +1,56 @@ +@* Views/Shared/_TestimonialsSection.cshtml *@ +@model OnlyOneAccessTemplate.Models.ContentBlock + +
+ @{ + var testimonials = new[] + { + new { Quote = ViewBag.Testimonial1Quote ?? "Excelente ferramenta, muito fácil de usar!", Name = ViewBag.Testimonial1Name ?? "Maria Silva", Position = ViewBag.Testimonial1Position ?? "Usuária" }, + new { Quote = ViewBag.Testimonial2Quote ?? "Economizou muito do meu tempo no trabalho.", Name = ViewBag.Testimonial2Name ?? "João Santos", Position = ViewBag.Testimonial2Position ?? "Profissional" }, + new { Quote = ViewBag.Testimonial3Quote ?? "Recomendo para todos que precisam converter arquivos.", Name = ViewBag.Testimonial3Name ?? "Ana Costa", Position = ViewBag.Testimonial3Position ?? "Cliente" } + }; + } + + @foreach (var testimonial in testimonials) + { +
+
+
+
+ +
+

+ "@testimonial.Quote" +

+
+
+
+ @testimonial.Name.Substring(0, 1) +
+
+
+
@testimonial.Name
+ @testimonial.Position +
+
+
+
+
+ } +
+ + +
+
+
+
+ @for (int i = 1; i <= 5; i++) + { + + } +
+ 4.9/5 + @(ViewBag.TestimonialsCount ?? "Mais de 500 avaliações positivas") +
+
+
\ No newline at end of file diff --git a/OnlyOneAccessTemplate/appsettings.Development.json b/OnlyOneAccessTemplate/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/OnlyOneAccessTemplate/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/OnlyOneAccessTemplate/appsettings.Production.json b/OnlyOneAccessTemplate/appsettings.Production.json new file mode 100644 index 0000000..a911d78 --- /dev/null +++ b/OnlyOneAccessTemplate/appsettings.Production.json @@ -0,0 +1,18 @@ +{ + "ConnectionStrings": { + "MongoDB": "mongodb+srv://usuario:senha@cluster.mongodb.net/text_case_converter_db?retryWrites=true&w=majority" + }, + + "SEO": { + "DefaultDomain": "https://maiusculasminusculas.com", + "GoogleTagManagerId": "GTM-REAL123", + "GoogleAnalyticsId": "GA-REAL456" + }, + + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.AspNetCore": "Warning" + } + } +} \ No newline at end of file diff --git a/OnlyOneAccessTemplate/appsettings.json b/OnlyOneAccessTemplate/appsettings.json index a73c1fc..a352ef2 100644 --- a/OnlyOneAccessTemplate/appsettings.json +++ b/OnlyOneAccessTemplate/appsettings.json @@ -1,31 +1,43 @@ { + // Exemplo 1: Conversor de Maiúsculas/Minúsculas + "Converter": { + "Type": "text-case", + "Name": "Conversor de Maiúsculas e Minúsculas" + }, + + // Exemplo 2: Conversor CSV para JSON + // "Converter": { + // "Type": "csv-json", + // "Name": "Conversor CSV para JSON" + // }, + + // Exemplo 3: Conversor OCR (Imagem para Texto) + // "Converter": { + // "Type": "image-ocr", + // "Name": "Conversor de Imagem para Texto" + // }, + + "ConnectionStrings": { + "MongoDB": "mongodb://admin:c4rn31r0@k3sw2:27017,k3ss1:27017/?authSource=admin" + }, + + "MongoDB": { + "DatabaseName": "text_case_converter_db" + }, + + "SEO": { + "DefaultDomain": "https://maiusculasminusculas.com", + "DefaultSiteName": "Conversor de Maiúsculas e Minúsculas Online", + "GoogleTagManagerId": "GTM-XXXXXXX", + "GoogleAnalyticsId": "GA-XXXXXXXX" + }, + "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*", - "ConnectionStrings": { - "MongoDB": "mongodb://admin:c4rn31r0@k3sw2:27017,k3ss1:27017/?authSource=admin" - }, - "MongoDB": { - "DatabaseName": "ConversionSite", - "Collections": { - "SiteConfigurations": "site_configurations", - "ConversionData": "conversion_data", - "Analytics": "analytics" - } - }, - "SEO": { - "DefaultSiteName": "Seu Site de Conversão", - "DefaultDomain": "https://seusite.com", - "GoogleTagManagerId": "GTM-XXXXXXX", - "GoogleAnalyticsId": "GA-XXXXXXXX", - "FacebookPixelId": "XXXXXXXXX" - }, - "ResponseCaching": { - "Duration": 300, - "VaryByHeader": "Accept-Language" - } -} \ No newline at end of file + + "AllowedHosts": "*" +} diff --git a/OnlyOneAccessTemplate/wwwroot/js/converters/text-case-converter.js b/OnlyOneAccessTemplate/wwwroot/js/converters/text-case-converter.js new file mode 100644 index 0000000..42caa28 --- /dev/null +++ b/OnlyOneAccessTemplate/wwwroot/js/converters/text-case-converter.js @@ -0,0 +1,413 @@ +// wwwroot/js/converters/text-case-converter.js +// Implementação específica para conversor de maiúsculas/minúsculas + +let converterConfig = null; + +// Função principal chamada pelo widget base +async function performConversion(formData) { + const textInput = formData.get('inputText'); + const caseType = formData.get('caseType') || 'upper'; + + if (!textInput || textInput.trim() === '') { + throw new Error('Por favor, insira algum texto para converter'); + } + + // Fazer requisição para o backend + const requestData = new FormData(); + requestData.append('inputType', 'text'); + requestData.append('textInput', textInput); + requestData.append('language', document.documentElement.lang || 'pt'); + + // Adicionar opções + const options = { caseType: caseType }; + requestData.append('options', JSON.stringify(options)); + + const response = await fetch('/converter/api/convert/text-case', { + method: 'POST', + body: requestData + }); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error.message || 'Erro na conversão'); + } + + const result = await response.json(); + + // Mostrar resultado + showConversionResult(result.outputText); +} + +// Função para mostrar o resultado +function showConversionResult(outputText) { + const outputArea = document.getElementById('outputArea'); + const outputTextElement = document.getElementById('outputText'); + const successActions = document.getElementById('successActions'); + + if (outputTextElement) { + outputTextElement.value = outputText; + outputArea.style.display = 'block'; + successActions.style.display = 'block'; + } +} + +// Inicialização específica do conversor +function initializeConverter() { + loadConverterConfig(); + setupAdvancedOptions(); +} + +// Carregar configuração do conversor +async function loadConverterConfig() { + try { + const response = await fetch('/converter/config/text-case'); + if (response.ok) { + converterConfig = await response.json(); + updateUIWithConfig(converterConfig.config); + } + } catch (error) { + console.error('Erro ao carregar configuração:', error); + } +} + +// Atualizar UI com configuração +function updateUIWithConfig(config) { + const texts = config.localizedTexts; + + // Atualizar textos localizados + Object.keys(texts).forEach(key => { + const elements = document.querySelectorAll(`[data-text="${key}"]`); + elements.forEach(el => { + if (el.tagName === 'INPUT' && (el.type === 'button' || el.type === 'submit')) { + el.value = texts[key]; + } else { + el.textContent = texts[key]; + } + }); + }); +} + +// Configurar opções avançadas +function setupAdvancedOptions() { + const advancedContainer = document.getElementById('advancedSettings'); + if (advancedContainer) { + advancedContainer.innerHTML = ` +
+
+ + +
+
+ `; + } +} + +// wwwroot/js/converters/csv-json-converter.js +// Implementação específica para conversor CSV para JSON + +async function performConversion(formData) { + const textInput = formData.get('inputText'); + const fileInput = formData.get('file'); + + if (!textInput && !fileInput) { + throw new Error('Por favor, forneça conteúdo CSV ou faça upload de um arquivo'); + } + + const requestData = new FormData(); + + if (fileInput && fileInput.size > 0) { + requestData.append('inputType', 'file'); + requestData.append('fileInput', fileInput); + } else { + requestData.append('inputType', 'text'); + requestData.append('textInput', textInput); + } + + requestData.append('language', document.documentElement.lang || 'pt'); + + const response = await fetch('/converter/api/convert/csv-json', { + method: 'POST', + body: requestData + }); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error.message || 'Erro na conversão'); + } + + const result = await response.json(); + + // Mostrar resultado formatado + showJsonResult(result.outputText); +} + +function showJsonResult(jsonText) { + const outputTextElement = document.getElementById('outputText'); + const successActions = document.getElementById('successActions'); + + if (outputTextElement) { + // Formatar JSON para melhor visualização + try { + const parsed = JSON.parse(jsonText); + outputTextElement.value = JSON.stringify(parsed, null, 2); + } catch { + outputTextElement.value = jsonText; + } + + document.getElementById('outputArea').style.display = 'block'; + successActions.style.display = 'block'; + + // Adicionar botão de download + addDownloadButton(jsonText); + } +} + +function addDownloadButton(content) { + const successActions = document.getElementById('successActions'); + + // Verificar se já existe botão de download + if (document.getElementById('downloadJsonBtn')) return; + + const downloadBtn = document.createElement('button'); + downloadBtn.id = 'downloadJsonBtn'; + downloadBtn.type = 'button'; + downloadBtn.className = 'btn btn-sm btn-outline-success'; + downloadBtn.innerHTML = ' Baixar JSON'; + + downloadBtn.addEventListener('click', () => { + const blob = new Blob([content], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'converted.json'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }); + + successActions.appendChild(downloadBtn); +} + +function initializeConverter() { + // CSV específico: permitir preview dos dados + setupCsvPreview(); +} + +function setupCsvPreview() { + const textInput = document.getElementById('inputText'); + if (textInput) { + textInput.addEventListener('input', debounce(showCsvPreview, 500)); + } +} + +function showCsvPreview() { + const textInput = document.getElementById('inputText'); + const csvContent = textInput.value.trim(); + + if (csvContent.length > 0) { + try { + const lines = csvContent.split('\n').slice(0, 5); // Mostrar só 5 linhas + const preview = lines.map(line => + line.split(',').map(cell => `${cell.trim()}`).join('') + ).map(row => `${row}`).join(''); + + // Mostrar preview se houver elemento para isso + const previewContainer = document.getElementById('csvPreview'); + if (previewContainer) { + previewContainer.innerHTML = ` + Preview (primeiras 5 linhas): + + ${preview} +
+ `; + } + } catch (error) { + // Ignorar erros de preview + } + } +} + +// Utility function +function debounce(func, wait) { + let timeout; + return function executedFunction(...args) { + const later = () => { + clearTimeout(timeout); + func(...args); + }; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + }; +} + +// wwwroot/js/converters/image-ocr-converter.js +// Implementação específica para conversor de imagem para texto (OCR) + +async function performConversion(formData) { + const fileInput = formData.get('file'); + + if (!fileInput || fileInput.size === 0) { + throw new Error('Por favor, selecione uma imagem'); + } + + // Validar tipo de arquivo + const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/bmp', 'application/pdf']; + if (!allowedTypes.includes(fileInput.type)) { + throw new Error('Formato de arquivo não suportado. Use JPG, PNG, GIF, BMP ou PDF.'); + } + + // Validar tamanho (15MB) + if (fileInput.size > 15 * 1024 * 1024) { + throw new Error('Arquivo muito grande. Tamanho máximo: 15MB'); + } + + const requestData = new FormData(); + requestData.append('inputType', 'file'); + requestData.append('fileInput', fileInput); + requestData.append('language', document.documentElement.lang || 'pt'); + + // Adicionar opções de OCR se houver + const ocrLanguage = formData.get('ocrLanguage') || 'por'; + const options = { ocrLanguage: ocrLanguage }; + requestData.append('options', JSON.stringify(options)); + + const response = await fetch('/converter/api/convert/image-ocr', { + method: 'POST', + body: requestData + }); + + if (!response.ok) { + const error = await response.json(); + throw new Error(error.message || 'Erro no processamento da imagem'); + } + + const result = await response.json(); + + // Mostrar resultado do OCR + showOcrResult(result.outputText, fileInput); +} + +function showOcrResult(extractedText, originalFile) { + const outputTextElement = document.getElementById('outputText'); + const successActions = document.getElementById('successActions'); + + if (outputTextElement) { + outputTextElement.value = extractedText; + document.getElementById('outputArea').style.display = 'block'; + successActions.style.display = 'block'; + + // Mostrar preview da imagem + showImagePreview(originalFile); + + // Adicionar botão para salvar texto + addSaveTextButton(extractedText); + } +} + +function showImagePreview(file) { + const previewContainer = document.getElementById('imagePreview'); + if (previewContainer && file.type.startsWith('image/')) { + const reader = new FileReader(); + reader.onload = function (e) { + previewContainer.innerHTML = ` +
+ Imagem processada:
+ Preview +
+ `; + }; + reader.readAsDataURL(file); + } +} + +function addSaveTextButton(text) { + const successActions = document.getElementById('successActions'); + + if (document.getElementById('saveTextBtn')) return; + + const saveBtn = document.createElement('button'); + saveBtn.id = 'saveTextBtn'; + saveBtn.type = 'button'; + saveBtn.className = 'btn btn-sm btn-outline-success'; + saveBtn.innerHTML = ' Salvar Texto'; + + saveBtn.addEventListener('click', () => { + const blob = new Blob([text], { type: 'text/plain;charset=utf-8' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'texto-extraido.txt'; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }); + + successActions.appendChild(saveBtn); +} + +function initializeConverter() { + setupAdvancedOcrOptions(); + setupImagePreview(); +} + +function setupAdvancedOcrOptions() { + const advancedContainer = document.getElementById('advancedSettings'); + if (advancedContainer) { + advancedContainer.innerHTML = ` +
+
+ + +
+
+ + +
+
+ `; + } +} + +function setupImagePreview() { + const fileInput = document.getElementById('fileInput'); + if (fileInput) { + fileInput.addEventListener('change', function (e) { + const file = e.target.files[0]; + if (file && file.type.startsWith('image/')) { + const reader = new FileReader(); + reader.onload = function (event) { + let previewContainer = document.getElementById('imagePreview'); + if (!previewContainer) { + previewContainer = document.createElement('div'); + previewContainer.id = 'imagePreview'; + fileInput.parentNode.appendChild(previewContainer); + } + + previewContainer.innerHTML = ` +
+ Preview +
+ `; + }; + reader.readAsDataURL(file); + } + }); + } +} \ No newline at end of file