com.github.slugify.Slugify Java Examples

The following examples show how to use com.github.slugify.Slugify. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostEditFragment.java    From quill with MIT License 5 votes vote down vote up
public void onPublishUnpublishClicked() {
    int msg = R.string.alert_publish;
    String targetStatus = Post.PUBLISHED;
    if (mPost.isPublished()) {
        msg = R.string.alert_unpublish;
        targetStatus = Post.DRAFT;
    }
    @Post.Status final String finalTargetStatus = targetStatus;
    new AlertDialog.Builder(mActivity)
            .setMessage(msg)
            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                if (finalTargetStatus.equals(mPost.getStatus())) {
                    Crashlytics.logException(new IllegalStateException("UI is messed up, " +
                            "desired post status is same as current status!"));
                }
                // This will not be triggered when updating a published post, that goes through
                // onSaveClicked(). It is assumed the user will ALWAYS want to synchronize the
                // slug with the title as long as it's being published now (even if it was
                // published and then unpublished earlier).
                if (Post.PUBLISHED.equals(finalTargetStatus)) {
                    // update the title in memory first, from the latest value in UI
                    mPost.setTitle(mPostTitleEditView.getText().toString());
                    mPost.setSlug(new Slugify().slugify(mPost.getTitle()));
                }
                saveToServerExplicitly(finalTargetStatus);
            })
            .setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss())
            .create().show();
}
 
Example #2
Source File: PublicoAlvoControllerTest.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    given(servicos.findBySegmentoDaSociedade(CIDADAOS)).willReturn(asList(
            SERVICO.withNome("XXXX").withSegmentosDaSociedade(asList(CIDADAOS, EMPRESAS)),
            SERVICO.withNome("AAAA").withSegmentosDaSociedade(asList(CIDADAOS, EMPRESAS))));

    given(servicos.findBySegmentoDaSociedade(EMPRESAS)).willReturn(asList(
            SERVICO.withNome("FFFF").withSegmentosDaSociedade(asList(CIDADAOS, EMPRESAS)),
            SERVICO.withNome("AAAA").withSegmentosDaSociedade(asList(CIDADAOS, EMPRESAS))));

    publicosAlvo = new PublicoAlvoController(servicos, new Slugify());
}
 
Example #3
Source File: IndexController.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Autowired
IndexController(ServicosEmDestaque servicosEmDestaque, AreasDeInteresseEmDestaque areasDestaque, OrgaoRepositoryUtil orgaos, Slugify slugify) {
    this.destaques = servicosEmDestaque;
    this.areasDestaque = areasDestaque;
    this.orgaos = orgaos;
    this.slugify = slugify;
}
 
Example #4
Source File: IndexControllerTest.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Before
@SneakyThrows
public void setUp() {
    slugify = new Slugify();
    destaquesManuais = new ServicosEmDestaque(servicos, destaques, piwikClient, false);
    destaquesAutomaticos = new ServicosEmDestaque(servicos, destaques, piwikClient, true);

    given(servicos.findAll(any(PageRequest.class)))
            .willReturn(new PageImpl<>(singletonList(SERVICO)));
}
 
Example #5
Source File: ImportadorServicos.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Autowired
ImportadorServicos(PortalDeServicosIndex indices,
                   ServicoRepository servicoRepository,
                   Siorg siorg,
                   Slugify slugify,
                   LeitorDeArquivos leitorDeArquivos) {
    this.indices = indices;
    this.servicoRepository = servicoRepository;
    this.siorg = siorg;
    this.slugify = slugify;
    this.leitorDeArquivos = leitorDeArquivos;
}
 
Example #6
Source File: ImportadorParaPaginasDeOrgao.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@Autowired
public ImportadorParaPaginasDeOrgao(Slugify slugify, ConteudoParser parser, OrgaoRepository orgaoRepository, LeitorDeArquivos leitorDeArquivos) {
    this.slugify = slugify;
    this.parser = parser;
    this.orgaoRepository = orgaoRepository;
    this.leitorDeArquivos = leitorDeArquivos;
}
 
Example #7
Source File: PaginaTematica.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@SneakyThrows
public static PaginaTematica fromServico(ServicoXML servico) {
    return new PaginaTematica()
            .withId(new Slugify().slugify(servico.getNome()))
            .withTipoConteudo(SERVICO.getNome())
            .withNome(servico.getNome())
            .withConteudo(servico.getDescricao());
}
 
Example #8
Source File: PaginaEstatica.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@SneakyThrows
public static PaginaEstatica fromServico(ServicoXML servico) {
    return new PaginaEstatica()
            .withId(new Slugify().slugify(servico.getNome()))
            .withTipoConteudo(SERVICO.getNome())
            .withNome(servico.getNome())
            .withConteudo(servico.getDescricao());
}
 
Example #9
Source File: PaginaTematica.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
public PaginaTematicaFormatter(PaginaTematicaRepository paginas, Slugify slugify) {
    this.paginas = paginas;
    this.slugify = slugify;
}
 
Example #10
Source File: GhostApiTest.java    From quill with MIT License 4 votes vote down vote up
@BeforeClass
public static void setupSlugify() throws IOException {
    SLUGIFY = new Slugify();
}
 
Example #11
Source File: SiorgTest.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    siorg = new Siorg(restTemplate, new Slugify(), new OrgaoUtils());
}
 
Example #12
Source File: ServicoXMLFormatterTest.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    given(orgaoRepository.obterOrgao(any()))
            .willReturn(PAGINA_ORGAO);
    formatter = new ServicoXML.Formatter(new Slugify(), servicos, orgaoRepository);
}
 
Example #13
Source File: SlugifyConfig.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Bean
public Slugify slugify() throws IOException {
    return new Slugify();
}
 
Example #14
Source File: SlugifyConfig.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@SneakyThrows
public static String slugify(String str) {
    Slugify s = new Slugify();
    s.setCustomReplacements(Collections.singletonMap("_", "-"));
    return s.slugify(str);
}
 
Example #15
Source File: PaginaEstatica.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
public PaginaEstaticaFormatter(PaginaEstaticaRepository paginas, Slugify slugify) {
    this.paginas = paginas;
    this.slugify = slugify;
}
 
Example #16
Source File: SlugifySlugProvider.java    From realworld-api-quarkus with MIT License 4 votes vote down vote up
public SlugifySlugProvider(Slugify slugify) {
  this.slugify = slugify;
}
 
Example #17
Source File: PublicoAlvoController.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
PublicoAlvoController(ServicoRepository servicos, Slugify slugify) {
    this.servicos = servicos;
    this.slugify = slugify;
}
 
Example #18
Source File: Siorg.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
public Siorg(RestTemplate restTemplate, Slugify slugify, OrgaoUtils orgaoUtils) {
    this.restTemplate = restTemplate;
    this.slugify = slugify;
    this.orgaoUtils = orgaoUtils;
}
 
Example #19
Source File: ServicoXML.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
public Formatter(Slugify slugify, ServicoRepository servicos, OrgaoRepositoryUtil orgaoRepositoryUtil) {
    this.slugify = slugify;
    this.servicos = servicos;
    this.orgaoRepositoryUtil = orgaoRepositoryUtil;
}
 
Example #20
Source File: OrgaoXML.java    From portal-de-servicos with MIT License 4 votes vote down vote up
@Autowired
public PaginaOrgaoFormatter(OrgaoRepository orgaoRepository, Siorg siorg, Slugify slugify) {
    this.orgaoRepository = orgaoRepository;
    this.siorg = siorg;
    this.slugify = slugify;
}
 
Example #21
Source File: PathUtils.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static String slugify(Collection<String> pathComponents) {
  Slugify slg = new Slugify();
  return slg.slugify(constructFullPath(pathComponents));
}
 
Example #22
Source File: PathUtils.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static String slugify(Collection<String> pathComponents) {
  Slugify slg = new Slugify();
  return slg.slugify(constructFullPath(pathComponents));
}
 
Example #23
Source File: Post.java    From spring-microservice-sample with GNU General Public License v3.0 4 votes vote down vote up
@PrePersist
public void slugify(){
    this.slug = new Slugify().slugify(this.title);
}
 
Example #24
Source File: SlugIdentityProvider.java    From elepy with Apache License 2.0 4 votes vote down vote up
public SlugIdentityProvider(int maxLength, String... slugFieldNames) {
    this.maxLength = maxLength;
    this.slugify = new Slugify();
    this.slugFieldNames = slugFieldNames;
}
 
Example #25
Source File: ApplicationConfig.java    From realworld-api-quarkus with MIT License 4 votes vote down vote up
@Singleton
@Produces
public Slugify slugify() {
  return new Slugify();
}